Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 5, 2025

As of PHP 8.4, (hooked) properties can be declared as abstract.

Notes:

  • The "abstract" modifier is not supported in constructor property promotion as that wouldn't make sense.
  • The "abstract" modifier is also not supported for interface properties as those are implicitly abstract (but that's not the concern of this sniff).

This commit adds a new sniff to detect abstract properties as supported in PHP 8.4.

For this sniff to function correctly, the PHPCSUtils minimum version needs to be v 1.1.2, which includes support for abstract properties via the Variables::getMemberProperties() method.

Includes tests.
Includes documentation.

Refs:

As of PHP 8.4, (hooked) properties can be declared as `abstract`.

Notes:
* The "abstract" modifier is not supported in constructor property promotion as that wouldn't make sense.
* The "abstract" modifier is also not supported for interface properties as those are implicitly abstract (but that's not the concern of this sniff).

This commit adds a new sniff to detect abstract properties as supported in PHP 8.4.

For this sniff to function correctly, the PHPCSUtils minimum version needs to be v 1.1.2, which includes support for abstract properties via the `Variables::getMemberProperties()` method.

Includes tests.
Includes documentation.

Refs:
* https://wiki.php.net/rfc/property-hooks#abstract_properties
* php/php-src 13455
* php/php-src@780a828
@jrfnl jrfnl force-pushed the php-8.4/new-newabstractpropertiessniff branch from 7536cc3 to a9f38a8 Compare September 5, 2025 18:31
@wimg wimg merged commit 7c65fb5 into develop Sep 8, 2025
49 checks passed
@wimg wimg deleted the php-8.4/new-newabstractpropertiessniff branch September 8, 2025 14:45
@jrfnl jrfnl added the PHP: 8.4 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