-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Description
PHP 7.1 introduced the "short list syntax", i.e. using the short array syntax instead of calling list().
Ref: http://php.net/manual/en/migration71.new-features.php#migration71.new-features.symmetric-array-destructuring
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_LISTtokens 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.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Ready for Release