Closed jrfnl closed 1 year ago
Since I posted this, this change has been reverted and the T_RETURN_TYPE
and T_ARRAY_HINT
have been completely deprecated (to be removed in v 4.0).
So, while the actual change is now different, the principle of the issue still stands: we need to check whether any adjustments need to be made in WPCS to deal with these tokenizer changes.
More info in the upstream issue (referenced above).
Also, it looks like the
AbstractClassRestriction
sniff currently does not check for param/return type type declarations when checking if a discouraged/forbidden class is being used, so that sniff will need adjusting anyhow and will need to take both methods of tokenization into account as long as PHPCS < 3.3.0 is still supported.
The above will be addressed with the (future) switch to the PHPCSUtils abstract for class use. Other than that, I don't think there is anything much to do here, so closing.
PHPCS 3.3.0 will change the way class based return type declarations are tokenized.
Previously, a class based return type was tokenized as:
ClassName
=>T_STRING
NSName\NSSubName\ClassName
=>T_STRING
+T_NS_SEPARATOR
+T_STRING
+T_NS_SEPARATOR
+T_STRING
Now they will be tokenized as one
T_RETURN_TYPE
token.Also, the
getMethodProperties()
method will now return information on the return type.Based on the existing unit tests, this currently does not break anything.
All the same, the sniffs should be examined to make sure that we're not missing any unit test cases for this and adjusted where necessary.
Also, it looks like the
AbstractClassRestriction
sniff currently does not check for param/return type type declarations when checking if a discouraged/forbidden class is being used, so that sniff will need adjusting anyhow and will need to take both methods of tokenization into account as long as PHPCS < 3.3.0 is still supported.Refs: