PHP 7.4/8.0 | Generic/LowerCaseType: add support for union types and typed properties #3153
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.
File::getMethodProperties(): add new
return_type_end_tokenindex to return valueWith union types, even non-class return types may consist of multiple tokens, so having access to the stackPtr for the exact end of the return type becomes relevant for sniffs which include fixers.
This commit adds a
return_type_end_tokenindex key to the array return value of theFile::getMethodProperties()method.Generic/LowerCaseType: minor tweak to a unit test
... to verify and safeguard that spacing within a type cast is not touched by the sniff.
Generic/LowerCaseType: refactor [1] - move array to property
Move the
$phpTypesarray to a property and add the new types introduced in PHP 8.0 to it.Generic/LowerCaseType: refactor [2] - remove duplicate code
Extract duplicate code out to a separate method and call the method instead.
PHP 8.0 | Generic/LowerCaseType: refactor [3] - allow for union types
Allow for union types, as introduced in PHP 8.0, in return and parameter type declarations.
Includes unit tests.
PHP 7.4 | Generic/LowerCaseType: add support for typed properties
PHP 7.4 introduced typed properties, but this sniff did not examine those yet.
Includes unit tests.
Partially fixes #2968.