nunomaduro / mock-final-classes
Allows mocking of final methods and classes in PHP.
Fund package maintenance!
nunomaduro
Patreon
www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L
Installs: 495 584
Dependents: 23
Suggesters: 0
Security: 0
Stars: 97
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
- dg/bypass-finals: ^1.1
Requires (Dev)
- localheinz/phpstan-rules: ^0.10.0
- phpstan/phpstan: ^0.11.8
- phpstan/phpstan-strict-rules: ^0.11.1
- phpunit/phpunit: ^7.0|^8.0|^9.3
- thecodingmachine/phpstan-strict-rules: ^0.11.1
This package is auto-updated.
Last update: 2024-11-10 11:14:44 UTC
README
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?
- First, we run the file autoload.php using Composer Autoload.
- Then, we determine if you are running a supported test framework
- 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.