Conversation
... to benefit from new functionality related to PHP 8.3, 8.4 and PHPCS 4.0. As the minimum supported PHPCS version for PHPCSUtils 1.1.0 is PHPCS 3.13.0, the minimum PHPCS version has also been raised. Refs: * https://github.com/PHPCSStandards/PHPCSUtils/releases/tag/1.1.0
…er needed PHPCS 3.12.2 fixed a PHP tokenization inconsistency directly related to what this sniff is detecting. > - Tokenizer/PHP: a PHP open tag at the very end of a file will now always be tokenized as T_OPEN_TAG, independently of the PHP version. > Previously, a PHP open tag at the end of a file was not tokenized as an open tag on PHP < 7.4 and the tokenization would depend on the short_open_tag setting. As the PHPCS tokenization will now be the same PHP cross-version, we can remove the work-arounds which were in place to accommodate the previous difference in tokenization. Ref: * PHPCSStandards/PHP_CodeSniffer 937
…ial exception The following PHPCSUtils 1.1.0 change was causing the tests to fail: > `UseStatements::getType()` will now handle unfinished closure `use` statements (parse errors) more consistently and return `'closure'` for those cases. This change means that during live coding, in specific cases where a closure declaration is incomplete, the `UseStatements::getType()` method will still correctly detect the `use` as a closure `use`. However, the `FunctionDeclarations::getParameters()` method will not handle such incomplete code and will throw an exception as the parameters imported via the closure `use` cannot be reliably retrieved. Fixed now by catching this potential exception.
> . 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 named arguments passed to `exit()`/`die()` to the `NewNamedParameters` sniff. Includes tests. Note: sniff updates for the other aspects of this PHP 8.4 feature will be pulled separately. 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
This was referenced Jul 5, 2025
wimg
approved these changes
Jul 6, 2025
This was referenced Jul 6, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the release of PHPCS 3.12.2, one test is failing on older PHP versions.
Since the release of PHPCSUtils 1.1.0, another two tests are failing.
This PR is intended to unblock contributors by fixing these CI failures.
Other updates which can/should be made for the more recent PHPCS versions and related to PHPCSUtils 1.1.0 will follow in separate PRs.
Composer: raise the minimum supported PHPCSUtils version to 1.1.0
... to benefit from new functionality related to PHP 8.3, 8.4 and PHPCS 4.0.
As the minimum supported PHPCS version for PHPCSUtils 1.1.0 is PHPCS 3.13.0, the minimum PHPCS version has also been raised.
Refs:
Miscellaneous/NewPHPOpenTagEOF: remove work-arounds which are no longer needed
PHPCS 3.12.2 fixed a PHP tokenization inconsistency directly related to what this sniff is detecting.
As the PHPCS tokenization will now be the same PHP cross-version, we can remove the work-arounds which were in place to accommodate the previous difference in tokenization.
Ref:
FunctionDeclarations/ForbiddenVariableNamesInClosureUse: catch potential exception
The following PHPCSUtils 1.1.0 change was causing the tests to fail:
This change means that during live coding, in specific cases where a closure declaration is incomplete, the
UseStatements::getType()method will still correctly detect theuseas a closureuse.However, the
FunctionDeclarations::getParameters()method will not handle such incomplete code and will throw an exception as the parameters imported via the closureusecannot be reliably retrieved.Fixed now by catching this potential exception.
PHP 8.4 | NewNamedParameters: handle named params passed to exit/die
This commit adds detection of the use of named arguments passed to
exit()/die()to theNewNamedParameterssniff.Includes tests.
Note: sniff updates for the other aspects of this PHP 8.4 feature will be pulled separately.
Refs:
Related to #1731