Skip to content

PHP 8.3 | Keywords/ForbiddenNames: add support for detecting forbidden names in combination with typed constants#1859

Merged
wimg merged 1 commit intodevelopfrom
php-8.3/forbiddennames-add-support-for-typed-constants
Aug 13, 2025
Merged

PHP 8.3 | Keywords/ForbiddenNames: add support for detecting forbidden names in combination with typed constants#1859
wimg merged 1 commit intodevelopfrom
php-8.3/forbiddennames-add-support-for-typed-constants

Conversation

@jrfnl
Copy link
Copy Markdown
Member

@jrfnl jrfnl commented Aug 13, 2025

PHP 8.3 introduced typed constants.

While the types themselves should not lead to false positives as the PHP native types are considered "other reserved keywords" and can be used as (class) constant names, so wouldn't be flagged, the sniff as-was would not find the actual name of the constant for typed constants, which could result in false negatives.

Fixed now.

Includes tests.

Ref:

…n names in combination with typed constants

PHP 8.3 introduced typed constants.

While the types themselves should not lead to false positives as the PHP native types are considered "other reserved keywords" and can be used as (class) constant names, so wouldn't be flagged, the sniff as-was would not find the _actual_ name of the constant for typed constants, which could result in false negatives.

Fixed now.

Includes tests.

Ref:
* https://www.php.net/manual/en/reserved.other-reserved-words.php
@jrfnl jrfnl added this to the 10.0.0 milestone Aug 13, 2025
@jrfnl jrfnl added Type: enhancement PR: quick merge PR only contains relatively simple changes PR: ready for review labels Aug 13, 2025
@wimg wimg enabled auto-merge August 13, 2025 19:51
@wimg wimg merged commit 9d6591c into develop Aug 13, 2025
47 of 49 checks passed
@wimg wimg deleted the php-8.3/forbiddennames-add-support-for-typed-constants branch August 13, 2025 20:08
@github-actions github-actions bot removed PR: ready for review PR: quick merge PR only contains relatively simple changes labels Aug 13, 2025
@jrfnl jrfnl added the PHP: 8.3 label Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants