-
Notifications
You must be signed in to change notification settings - Fork 812
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
Phan: functionify and statusify exit()
and die()
#41167
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Beta plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Debug Helper plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Backup plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Vaultpress plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Boost plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Search plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Social plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Starter Plugin plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Videopress plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Super Cache plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Wpcomsh plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Automattic For agencies client plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Classic Theme helper plugin plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
@@ -4,5 +4,6 @@ | |||
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable | |||
die( $arg ); | |||
} else { | |||
// @phan-suppress-current-line UnusedPluginSuppression @phan-suppress-next-line PhanParamTooFewInternal -- Phan bug with PHP 8.4: https://github.com/phan/phan/issues/4888 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why you went with suppression here instead of adding a zero as with everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it's a test specifically for the no-arg variant of die()
(a valid variant despite what Phan claims on PHP 8.4), so adding an arg defaults the point of that test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left two separate comments before, then found another thing and decided to start a review in case I found more. And of course I didn't find anything else.
Also, I wasn't aware of how much CRM likes to exit
! Oh boy!
* non-CRM: exit → exit( 0 ) * CRM: exit → exit( 0 ) * non-CRM: exit() → exit( 0 ) * CRM: exit() → exit( 0 ) * die → die(0) * Suppress invalid Phan error on valid tests * die() → die(0) * Add changelogs * Suppress unneeded suppression warnings on PHP 8.2 * Oops * Rework code to satisfy Phan bug * Remove redundant exits * Correct PHPDoc * Update baseline * Remove comments
Due to phan/phan#4888, running Phan on PHP 8.4 resulted in many false-positives. This PR changes our codebase to use the following:
exit
→exit( 0 )
exit()
→exit( 0 )
die
→die( 0 )
die()
→die( 0 )
While we don't have plans to enforce this syntax going forward, it doesn't hurt to be consistent. The function-style calls have been around since PHP 4, and PHP 8.4 changed them to be behave more like functions:
https://www.php.net/manual/en/migration84.incompatible.php#migration84.incompatible.core.exit
Likewise, while the status code isn't required, it does default to
0
and being explicit is arguably good practice anyway.I also updated some code that was surfacing errors likely related to the known Phan bug.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
In
trunk
one gets 701 errors from Phan when running PHP 8.4.