-
-
Notifications
You must be signed in to change notification settings - Fork 205
PHP 8.4 | Handle "Exit as function call" in various sniffs #1807
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
Conversation
|
Rebased without changes after the merge of #1806 and marked as "ready for review". |
4520a6c to
57c5439
Compare
|
Temporarily moving this to draft as I found another situation which needs to be handled (exit/die as fully qualified function) and will (most likely) mean that all commits related to this PHP change need to be updated. |
57c5439 to
40dccb5
Compare
40dccb5 to
711a1ed
Compare
|
I've updated the test code in this PR to include fully qualified calls to I've also added a new error to the Rebased after the merge of #1900. 🤞🏻 I expect the build to pass now. |
711a1ed to
b7408bc
Compare
…able > . The exit (and die) language constructs now behave more like a function. > They can be passed liked callables, are affected by the strict_types > declare statement, and now perform the usual type coercions instead of > casting any non-integer value to a string. > As such, passing invalid types to exit/die may now result in a TypeError > being thrown. > RFC: https://wiki.php.net/rfc/exit-as-function This commit adds detection of the use of `exit()`/`die()` as a first class callable to the `NewFirstClassCallables` sniff. Includes tests. Includes updated documentation. Refs: * https://wiki.php.net/rfc/exit-as-function * https://github.com/php/php-src/blob/8853cf3ae950a1658054f286117bc8f77f724f00/UPGRADING#L40-L46 * php/php-src 13486 * php/php-src@a79c70f Related to 1731
…xit/die > . The exit (and die) language constructs now behave more like a function. > They can be passed liked callables, are affected by the strict_types > declare statement, and now perform the usual type coercions instead of > casting any non-integer value to a string. > As such, passing invalid types to exit/die may now result in a TypeError > being thrown. > RFC: https://wiki.php.net/rfc/exit-as-function This commit adds detection of the use of trailing comma's in `exit()`/`die()` to the `NewFunctionCallTrailingComma` sniff. Includes tests. Refs: * https://wiki.php.net/rfc/exit-as-function * https://github.com/php/php-src/blob/8853cf3ae950a1658054f286117bc8f77f724f00/UPGRADING#L40-L46 * php/php-src 13486 * php/php-src@a79c70f Related to 1731
…ll` sniff > . The exit (and die) language constructs now behave more like a function. > They can be passed liked callables, are affected by the strict_types > declare statement, and now perform the usual type coercions instead of > casting any non-integer value to a string. > As such, passing invalid types to exit/die may now result in a TypeError > being thrown. > RFC: https://wiki.php.net/rfc/exit-as-function This commit adds a new sniff which: 1. Will flag use of `exit`/`die` as fully qualified function calls, which is not allowed prior to PHP 8.4. 2. Tries to detect parameter values which will either be interpreted differently or will (likely) result in a TypeError on PHP 8.4. Calls to `exit()`/`die()` for which the parameter type cannot be determined are silently ignored to prevent false positives. Includes tests. Includes documentation. Refs: * https://wiki.php.net/rfc/exit-as-function * https://github.com/php/php-src/blob/8853cf3ae950a1658054f286117bc8f77f724f00/UPGRADING#L40-L46 * php/php-src 13486 * php/php-src@a79c70f * php/php-src 15433 * php/php-src@4c5767f Related to 1731
…andling FQN exit/die ... which is allowed since PHP 8.4... _sigh_
b7408bc to
c9dd0a1
Compare
PR #1806 also contains one commit - 297d6b1 - which, by rights, should be part of this PR.
PHP 8.4 | NewFirstClassCallables: handle exit/die as first class callable
This commit adds detection of the use of
exit()/die()as a first class callable to theNewFirstClassCallablessniff.Includes tests.
Includes updated documentation.
Refs:
Related to #1731
PHP 8.4 | NewFunctionCallTrailingComma: handle trailing comma's for exit/die
This commit adds detection of the use of trailing comma's in
exit()/die()to theNewFunctionCallTrailingCommasniff.Includes tests.
Refs:
Related to #1731
PHP 8.4 | ✨ New
PHPCompatibility.ParameterValues.NewExitAsFunctionCallsniffThis commit adds a new sniff which:
exit/dieas fully qualified function calls, which is not allowed prior to PHP 8.4.Calls to
exit()/die()for which the parameter type cannot be determined are silently ignored to prevent false positives.Includes tests.
Includes documentation.
Refs:
Related to #1731
PHP 8.4 | FunctionUse/NewNamedParameters: update tests to safeguard handling FQN exit/die
... which is allowed since PHP 8.4... sigh
Follow up to #1806 which already updated the sniff itself.