nunomaduro/mock-final-classes

Allows mocking of final methods and classes in PHP.

v1.2.0 2023-05-14 23:33 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT b13fc71acd9d6f1e2de8209217103cbd2035871f

  • Nuno Maduro <enunomaduro.woop@gmail.com>

phpphpunitmockclassclassesfinal

This package is auto-updated.

Last update: 2026-06-10 23:05:12 UTC


README

👁 Mock final classes example

👁 Build Status
👁 Total Downloads
👁 Latest Version
👁 License
👁 YouTube Channel Subscribers

Created by, and is maintained by Nuno Maduro, and once installed it automatically allows mocking of final methods and classes.

💡 Installation & Usage

Requires PHP 7.1+

First, install the package using Composer:

composer require --dev nunomaduro/mock-final-classes

That's it! You can now mock final methods and classes. 🏄‍♂️

🤯 How it works?

  1. First, we run the file autoload.php using Composer Autoload.
  2. Then, we determine if you are running a supported test framework
  3. Then, we use the library dg/bypass-finals to remove final keywords from source code on-the-fly: https://github.com/nunomaduro/mock-final-classes/src/Runner.php#L31.

👏🏻 Credits

Most of the work is done by the library dg/bypass-finals, so make sure you support the maintainer here: Donate. Thank you!

Mock Final Classes is an open-sourced software licensed under the MIT license.