Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 25, 2025

. 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:

Related to #1849

…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
@wimg wimg merged commit 6fa2ce2 into develop Oct 27, 2025
76 checks passed
@wimg wimg deleted the php-8.5/new-newstaticavizproperties-sniff branch October 27, 2025 20:36
@jrfnl jrfnl added the PHP: 8.5 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.

3 participants