PHP 8.0 | TypeDeclaration sniffs: examine properties declared in the constructor correctly by jrfnl · Pull Request #1447 · PHPCompatibility/PHPCompatibility

added 2 commits

December 26, 2022 02:28
…tructor

Typed properties declared via a class constructor should also be examined by the `NewTypedProperties` sniff as the allowed types for properties are different than those for parameters.

Includes:
* Adding `T_FUNCTION` to the tokens to be examined.
* Splitting the "type checking" logic off into its own method to allow for multiple properties declared in a constructor.

Includes unit tests.

Ref: https://wiki.php.net/rfc/constructor_promotion
Properties declared via a class constructor follow the property type rules, not the parameter type rules, so ignore them for this sniff. These will be examined in the `NewTypedProperties` sniff instead.

Includes unit tests.

@jrfnl jrfnl mentioned this pull request

Dec 26, 2022

40 tasks

wimg

wimg approved these changes Dec 30, 2022

@wimg wimg deleted the php-8.0/newtypedproperties-newparamtype-support-constructor-property-promotion branch

December 30, 2022 15:38