-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare for PHP 8.4 #146
Comments
Thank you @jrfnl! For point 3, I can give you more info. TL;DR: We should probably use exceptions. -- Patchwork can only replace functions that exist. So when we use Brain Monkey to replace a function that doesn't exist, Brain Monkey first declares a dummy function that only triggers an error. This means that the test will fail if the code under test executes the function without the developer setting expectations for it. On every test, in That means we have two possible cases in the next tests:
Given this workflow, replacing It currently uses For example, image a test code like this: public function testThatSomethingThrows()
{
$this->expectException(Exception::class);
$something = new Something();
$something->execute();
} In this case, if In summary, we have two options:
I think the latter is the lesser risk, so maybe we go for that. |
Thanks for that explanation @gmazzap!
I've found the definition now (in a heredoc, which is why I didn't find it initially via (bleeding-edge) PHPCompatibility).
I agree the second option is best, but would like to throw a variant of that in the mix: The only "problem" is that This could be defined like the below and would then still be PSR4 compliant. namespace Brain\Monkey\Expectation\Exception;
if (PHP_VERSION_ID >= 70000) {
class UndefinedFunction extends \Error {}
} else {
class UndefinedFunction extends \Exception {}
} |
P.S.: the name of the new exception is, of course, open for discussion, my comment is mostly about the principle of how to handle this. |
Hi @jrfnl and thanks for you input. I'm unsure about extending
So, all considered, I think the problems outweigh the benefits. I guess that having some |
PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`, with the recommendation being to replace these type of calls with either an Exception or an `exit` statement. This commit fixes the one instance found in this codebase by introducing a new `MissingFunctionExpectations` exception. Includes updating the related tests (and test names) to match. Ref: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error Related to #146
PHP 8.4 deprecates passing `E_USER_ERROR` to `trigger_error()`, with the recommendation being to replace these type of calls with either an Exception or an `exit` statement. This commit fixes the one instance found in this codebase by introducing a new `MissingFunctionExpectations` exception. Includes updating the related tests (and test names) to match. Ref: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error Related to #146
And we're ready! 🎉 Patchwork just released version 2.2.0, which adds runtime support for PHP 8.4. V 2.2.0 does have a minimum PHP version of 7.1, but that shouldn't be an issue. When people install via Composer and are running on PHP < 7.1, Composer will just give them the last 2.1.x version, which will work fine on PHP < 7.1. And when people install via Composer with PHP 7.1+ (including PHP 8.4), they will get v 2.2.0 (or a later release once available) and that should take care of the PHP 8.4 compat issues. @gmazzap I'd recommend tagging a new BrainMonkey release over the next few days to get the BrainMonkey specific PHP 8.4 patches out into the world. If people then update with |
@gmazzap Ping ? |
@jrfnl Sorry haven't feel well. Just to confirm, there's nothing else to do here just tag, right? |
@gmazzap Nothing based on the last time I checked, though that is a few weeks back. Might be good to trigger a test run against the current PHP 8.4 just to verify, but I expect we should be good. I won't have time to double-check until the weekend. |
Double-checked & confirmed.
As far as I'm concerned, nothing blocking the release anymore. |
Thankd @jrfnl Release is out https://github.com/Brain-WP/BrainMonkey/releases/tag/2.6.2 |
I've just manually triggered a test run and the PHP 8.4 build is currently failing for a variety of reasons.
PR to fix this upcoming.See PHP 8.4 | Fix implicitly nullable parameter #147E_USER_ERROR
totrigger_error()
.This needs investigation.See PHP 8.4 | Fix passingE_USER_ERROR
totrigger_error()
#149The text was updated successfully, but these errors were encountered: