Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nunomaduro/mock-final-classes
🏄♂️ Allows mocking final classes in PHP.
https://github.com/nunomaduro/mock-final-classes
Last synced: 2 days ago
JSON representation
🏄♂️ Allows mocking final classes in PHP.
- Host: GitHub
- URL: https://github.com/nunomaduro/mock-final-classes
- Owner: nunomaduro
- License: mit
- Created: 2019-06-05T21:17:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-10T08:45:09.000Z (over 1 year ago)
- Last Synced: 2025-02-12T17:12:39.378Z (9 days ago)
- Language: PHP
- Homepage: https://nunomaduro.com
- Size: 352 KB
- Stars: 99
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
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+](https://php.net/releases/)**
First, install the package using [Composer](https://getcomposer.org):
```bash
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](https://github.com/nunomaduro/mock-final-classes/blob/master/autoload.php) using [Composer Autoload](https://github.com/nunomaduro/mock-final-classes/blob/8628de25120b6106421d7730457c45ac668ecef9/composer.json#L35).
2. Then, we determine if you are running a supported test framework
- [ParaTest](https://github.com/nunomaduro/mock-final-classes/blob/master/src/Frameworks/ParaTest.php)
- [Pest](https://github.com/nunomaduro/mock-final-classes/blob/master/src/Frameworks/Pest.php)
- [PHPUnit](https://github.com/nunomaduro/mock-final-classes/blob/master/src/Frameworks/PhpUnit.php)
3. Then, we use the library [dg/bypass-finals](https://github.com/dg/bypass-finals) to remove final keywords from source code on-the-fly: [https://github.com/nunomaduro/mock-final-classes/src/Runner.php#L31](https://github.com/nunomaduro/mock-final-classes/blob/8628de25120b6106421d7730457c45ac668ecef9/src/Runner.php#L31).## 👏🏻 Credits
Most of the work is done by the library [dg/bypass-finals](https://github.com/dg/bypass-finals), so make sure you support the maintainer here: [Donate](https://nette.org/make-donation?to=bypass-finals). Thank you!
---
Mock Final Classes is an open-sourced software licensed under the [MIT license](LICENSE.md).