You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now I can imagine that in some situations it would be useful to be able to make the distinction whether something is used as a short list vs a short array.
There are two ways this can be done:
Introduce T_OPEN_SHORT_LIST/T_CLOSE_SHORT_LIST tokens and let the Tokenizer handle it.
The downside of this first solution is that in a lot of cases - especially when sniffing for code style -, I imagine that short list/array should be treated the same, so those sniff would then need to add two additional tokens to sniff for.
Introduce a utility function which can make the distinction and can be called by select sniffs if/when needed.
For the PHPCompatibility standard, I have already created the utility function (solution 2), including extensive unit tests for it.
See: PHPCompatibility/PHPCompatibility#635
If there would be interest in having such a utility function in PHPCS itself, I'd be happy to pull it here.
See the original issue for an extensive discussion on the topic.
My current line of thinking is to add a nested_brackets index to the token array. This would allow for sniffs to figure out if they are dealing with a (nested) short list or a short array much more easily.
I'm tentatively earmarking this ticket for 4.0, but it may well be moved to a later release.
The text was updated successfully, but these errors were encountered:
Repost from squizlabs/PHP_CodeSniffer#1984:
See the original issue for an extensive discussion on the topic.
My current line of thinking is to add a
nested_brackets
index to the token array. This would allow for sniffs to figure out if they are dealing with a (nested) short list or a short array much more easily.I'm tentatively earmarking this ticket for 4.0, but it may well be moved to a later release.
The text was updated successfully, but these errors were encountered: