Treat constructors as implicitly void-typed for the purposes of prependCodeToFunctions() - #214
Conversation
jrfnl
left a comment
There was a problem hiding this comment.
@antecedent I've been running the BrainMonkey tests with this branch to see whether it would fix the test failures BrainMonkey was seeing on PHP 8.6.
As things were, half the test failures were fixed. Looking at what remained showed me the oversight, namely that the same PHP RFC also forbids returning from a __destruct() method.
I've tried to fix that with the additional two commits (sorry, didn't mean to push to this branch, but as I did, the commits are here now), but while the fix works *, the test I added does not.
* The reason I'm saying the fix works is that the BrainMonkey tests pass on PHP 8.6 with the additional fix in place.
Hope this helps.
273d773 to
6aee010
Compare
|
Thank you @jrfnl! It looks like the missing link was I found it striking that Patchwork did not throw anything from the |
Yes, that would explain it. Sorry I missed that. Should we also add some tests with an anonymous class with a
If you mean that Patchwork should throw an exception when |
|
I added the extra assertions with an anonymous class. I also discovered that PHP 7.4 changed the behavior of anonymous classes with respect to The preceding is also something that we might want to address later, but I think we are good to go with this particular PR? |
👍🏻
Correct. This is a documented backward compatibility break in PHP 7.4: https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.get-declared-classes I'm also now wondering, now you've mentioned I can see the I haven't looked into the Patchwork wiring deeply enough to know whether there is an issue here or not, but consider Also: with the above in mind -
Agreed. Let's open issues as a reminder for those things moved to "later" and in the mean time, let's get this PR merged and released as it will unblock other projects using Patchwork for testing their PHP 8.6 readiness. |
See #213.
The title assumes
use function Patchwork\CodeManipulation\Actions\Generic\prependCodeToFunctions.