antecedent / patchwork

Method redefinition (monkey-patching) functionality for PHP.
https://antecedent.github.io/patchwork/
MIT License
444 stars 40 forks source link

Latest doctrine/instantiator bugs out with patchwork #64

Closed krodyrobi closed 7 years ago

krodyrobi commented 7 years ago

Versions

Dependency Version
PHPUnit 5.7. and 6.2.
Doctrine/instantiator 1.1.0
PHP 5.6 and 7.1
Patchwork 2.0.7

MCV example

patchwork-doctrine-master.zip

Temporary workaround

Add "doctrine/instantiator": "1.0.x-dev" to composer.json

Edit

Quick-fixed in patchwork==2.0.8. Redefining void hinted functions will be supported in future versions, now they are skipped.

krodyrobi commented 7 years ago

Cross-linking https://github.com/sebastianbergmann/phpunit/issues/2746

tfrommen commented 7 years ago

Hey there,

thanks for fixing this. But ... it's not working for me.

I have a repository that depends on Patchwork and PHPUnit 5.7, and thus Instantiator (which I get as version 1.1.0).

Still the fatal error keeps on coming. Any idea why that is?

krodyrobi commented 7 years ago

In your composer.json replace to "antecedent/patchwork": "^2.0", and issue a composer update. It should download 2.0.8 as of yesterday.

tfrommen commented 7 years ago

I am using 2.0.8.

antecedent commented 7 years ago

Also, if there's a cache-path in patchwork.json, please manually clear the folder it refers to.

tfrommen commented 7 years ago

Thanks for the info. However, I don't use any patchwork.json ( I'm not redefining core stuff such as exit), and the cache/ folder is also not present.

antecedent commented 7 years ago

Please use {"blacklist": ["/path/to/Instantiator.php"]} for now. I apologize for any inconvenience caused by this bug, and will investigate it further later today.

tfrommen commented 7 years ago

No problem, and thanks! For now, I just fix Instantiator to v1.0.5 where it doesn't have the void return type hint, so no fatal error.

Rarst commented 7 years ago

Also having issues with 2.0.8, any failing test or anything produces the fatal error in Instantiator.

Not doing anything with Patchwork directly, using it via Brain Monkey. Downgrading to Instantiator 1.0.5 seems to help for now.

cc @gmazzap

antecedent commented 7 years ago

This time, I have successfully reproduced the bug with an actual copy of doctrine/instantiator 1.1, and made a second attempt at the fix.

Rarst commented 7 years ago

Seems to have gotten my issue this time! No errors with 2.0.9 and Instantiator 1.1 so far, thaaank you. :)

tfrommen commented 7 years ago

Wow, nice one, @antecedent! Thanks! Damn use-ing closures, right? 😀

krodyrobi commented 7 years ago

Yep it seems to have solved the issue completely. Thank you!