File::getMemberProperties(): removed parse error warning #991
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Tests: rename various test case files
... to allow for adding additional test case files containing parse errors.
File::getMemberProperties(): removed parse error warning
The
File::getMemberProperties()
method used to be inconsistent in how it handled variable tokens which were not property declarations.RuntimeException
"'$stackPtr is not a class member var'".enum
orinterface
construct, it would register a warning about a possible parse error and return an empty array.This parse error warning has now been removed.
As, as of PHP 8.4, declaring (hooked) properties in an interface is no longer a parse error (see the Property Hooks RFC), properties declared in interfaces will now be analyzed by the function, like any other property, and will return an array of information about the property.
For "properties" declared in enums, which is still not allowed in PHP, the method will throw the
RuntimeException
"'$stackPtr is not a class member var'".Includes updated unit tests for the
File::getMemberProperties()
method.Includes a review of all uses of the
File::getMemberProperties()
method in PHPCS native sniffs and updating the code where necessary.Includes adding/updating tests with properties in interfaces and enums for each of those sniffs.
Suggested changelog entry
Added:
Changed:
Internal.ParseError.InterfaceHasMemberVar
and theInternal.ParseError.EnumHasMemberVar
error codes have been removed.RuntimeException
- "$stackPtr is not a class member var" - for properties declared in enums (parse error).Related issues/external references
Closes squizlabs/PHP_CodeSniffer#2455
Also related to #734