GitHub - dg/bypass-finals: Removes final keywords from source code on-the-fly an...
source link: https://github.com/dg/bypass-finals
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
readme.md
Bypass Finals
Introduction
Removes final keywords from source code on-the-fly and allows mocking of final methods and classes. It can be used together with any test tool such as PHPUnit, Mockery or Nette Tester.
Installation
The recommended way to install is through Composer:
composer require dg/bypass-finals --dev
It requires PHP version 5.6 and supports PHP up to 7.3.
Usage
Simply call this:
DG\BypassFinals::enable();
You need to enable it before the classes you want to remove the final are loaded. So call it as soon as possible,
preferably right after vendor/autoload.php
in loaded.
You can choose to only bypass finals in specific files:
DG\BypassFinals::setWhitelist([ 'relative/path/to/file.php' ]); DG\BypassFinals::enable();
This gives you finer control and can solve issues with certain frameworks and libraries.
If you like it, please make a donation now. Thank you!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK