PHPCSStandards/PHPCSUtils

is_token_namespaced() doesn't take into account __NAMESPACE__ concatenation

Opened this issue ยท 1 comments

๐Ÿ‘‹ When using the helper function is_token_namespaced(), it doesn't appear to pick up when the magic constant of __NAMESPACE__ is being concatenated:

https://github.com/WordPress/WordPress-Coding-Standards/blob/06966b26d8deb06a91a5c0f99a04802a6ff5e5bf/WordPress/Sniff.php#L1648-L1671

e.g. The below would return false:

__NAMESPACE__ . '\FOO_BAR';

I think we can just add a check if the token is T_NS_C.

Please let me know if I can provide any additional information!

jrfnl commented

The thing with this is that the actual token is not namespaced as constant encapsed text strings are not subject to the concept of namespaces.

__NAMESPACE__ returns a text string after all.

This method is not in this library for now anyway, but I'll have a think about this if/when I decide to add it.