dg / bypass-finals

Removes `final` and `readonly` 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 or Mockery.
Other
487 stars 30 forks source link

Bypass finals not work because token `final` is elsewhere #32

Closed zeleznypa closed 2 years ago

zeleznypa commented 2 years ago

For some reason the dg/bypass-finals try to find final in $token[0] but on my computer the final is in $token[1]

Snímek obrazovky 2022-08-19 v 12 24 25

And because of that, the dg/bypass-finals not working

zeleznypa commented 2 years ago

The code is not working for me, but for another reason, that I'm not able to detect why.

Generated $code in this part at the end does not contain final, but the PhpUnit still fail on error PHPUnit\Framework\MockObject\ClassIsFinalException: Class "FinalClass" is declared "final" and cannot be doubled

The environment is

PHP 8.1.9 (cli) (built: Aug  4 2022 21:09:01) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans