PHP 8.4 | Handle "Exit as function call" in various sniffs by jrfnl · Pull Request #1807 · PHPCompatibility/PHPCompatibility
jrfnl
mentioned this pull request
58 tasks
Base automatically changed from feature/composer-update-for-phpcsutils-1.1.0 to develop
July 6, 2025 13:28
jrfnl
marked this pull request as ready for review
jrfnl
marked this pull request as draft
jrfnl
marked this pull request as ready for review
…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
wimg approved these changes Sep 8, 2025
wimg
deleted the
php-8.4/exit-as-function-call
branch
jrfnl
mentioned this pull request
jrfnl
mentioned this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters