PHP 8.5 | :sparkles: New `PHPCompatibility.Classes.NewStaticAvizProperties` sniff (RFC) by jrfnl · Pull Request #1950 · PHPCompatibility/PHPCompatibility

@jrfnl

…iff (RFC)

> . Added asymmetric visibility support for static properties.
>   RFC: https://wiki.php.net/rfc/static-aviz

The use of asymmetric visibility keywords in general is flagged for PHP < 8.4 via the `NewKeywords` sniff (see 1809).

PHP 8.5 now allows for asymmetric visibility to be used for static properties, which was explicitly excluded in the PHP 8.4 RFC.

This new sniff detects code allowed since the PHP 8.5 change.

Note: this does mean that code _may_ be flagged by both sniffs:
* For PHP 8.4 for the use of the keywords.
* For PHP 8.5 specifically for the use of the keywords with static properties.

I did consider moving the "general" check from the `NewKeywords` sniff to this new sniff, but that would be a breaking change for the error code for the PHP 8.4 error without much added benefit, other than potentially preventing two notices about slightly different aspects of the same issue.

Refs:
* https://wiki.php.net/rfc/static-aviz
* https://github.com/php/php-src/blob/34721745833b4c9e69ed22f1b17c4c1c421f7179/UPGRADING#L194-L195
* php/php-src 16486
* php/php-src@1f6fdde

Related to 1849

@jrfnl jrfnl mentioned this pull request

Oct 25, 2025

70 tasks

wimg

wimg approved these changes Oct 27, 2025

@wimg wimg deleted the php-8.5/new-newstaticavizproperties-sniff branch

October 27, 2025 20:36

@jrfnl jrfnl mentioned this pull request

Nov 19, 2025