1010
1111namespace  PHPCSUtils \Tokens ;
1212
13- use  PHPCSUtils \Tokens \TokenHelper ;
14- 
1513/** 
1614 * Collections of related tokens as often used and needed for sniffs. 
1715 * 
@@ -234,6 +232,28 @@ class Collections
234232        \T_CLOSE_TAG           => \T_CLOSE_TAG ,
235233    ];
236234
235+     /** 
236+      * Tokens used for "names", be it namespace, OO, function or constant names. 
237+      * 
238+      * Includes the tokens introduced in PHP 8.0 for "Namespaced names as single token". 
239+      * 
240+      * Note: the PHP 8.0 namespaced name tokens are backfilled in PHPCS since PHPCS 3.5.7, 
241+      * but are not used yet (the PHP 8.0 tokenization is "undone" in PHPCS). 
242+      * As of PHPCS 4.0.0, these tokens _will_ be used and the PHP 8.0 tokenization is respected. 
243+      * 
244+      * @link https://wiki.php.net/rfc/namespaced_names_as_token 
245+      * 
246+      * @since 1.0.0-alpha4 Use the {@see Collections::nameTokens()} method for access. 
247+      * 
248+      * @return array <int|string> => <int|string> 
249+      */ 
250+     private  static  $ nameTokens
251+         \T_STRING                => \T_STRING ,
252+         \T_NAME_QUALIFIED        => \T_NAME_QUALIFIED ,
253+         \T_NAME_FULLY_QUALIFIED  => \T_NAME_FULLY_QUALIFIED ,
254+         \T_NAME_RELATIVE         => \T_NAME_RELATIVE ,
255+     ];
256+ 
237257    /** 
238258     * DEPRECATED: Object operators. 
239259     * 
@@ -673,7 +693,7 @@ public static function controlStructureTokens()
673693    public  static  function  functionCallTokens ()
674694    {
675695        // Function calls and class instantiation. 
676-         $ tokensself ::nameTokens () ;
696+         $ tokensself ::$ nameTokens
677697        $ tokensT_VARIABLE ] = \T_VARIABLE ;
678698
679699        // Class instantiation only. 
@@ -797,17 +817,19 @@ public static function namespacedNameTokens()
797817            \T_NAMESPACE     => \T_NAMESPACE ,
798818        ];
799819
800-         $ tokensself ::nameTokens () ;
820+         $ tokensself ::$ nameTokens
801821
802822        return  $ tokens
803823    }
804824
805825    /** 
806826     * The tokens used for "names", be it namespace, OO, function or constant names. 
807827     * 
808-      * Includes the tokens introduced in PHP 8.0 for "Namespaced names as single token" when available . 
828+      * Includes the tokens introduced in PHP 8.0 for "Namespaced names as single token". 
809829     * 
810-      * Note: this is a method, not a property as the PHP 8.0 identifier name tokens may not exist. 
830+      * Note: the PHP 8.0 namespaced name tokens are backfilled in PHPCS since PHPCS 3.5.7, 
831+      * but are not used yet (the PHP 8.0 tokenization is "undone" in PHPCS). 
832+      * As of PHPCS 4.0.0, these tokens _will_ be used and the PHP 8.0 tokenization is respected. 
811833     * 
812834     * @link https://wiki.php.net/rfc/namespaced_names_as_token 
813835     * 
@@ -817,28 +839,7 @@ public static function namespacedNameTokens()
817839     */ 
818840    public  static  function  nameTokens ()
819841    {
820-         $ tokens
821-             \T_STRING  => \T_STRING ,
822-         ];
823- 
824-         /* 
825-          * PHP >= 8.0 in combination with PHPCS < 3.5.7 and all PHP versions in combination 
826-          * with PHPCS >= 3.5.7, though when using PHPCS 3.5.7 < 4.0.0, these tokens are 
827-          * not yet in use, i.e. the PHP 8.0 change is "undone" for PHPCS 3.x. 
828-          */ 
829-         if  (TokenHelper::tokenExists ('T_NAME_QUALIFIED ' ) === true ) {
830-             $ tokensT_NAME_QUALIFIED ] = \T_NAME_QUALIFIED ;
831-         }
832- 
833-         if  (TokenHelper::tokenExists ('T_NAME_FULLY_QUALIFIED ' ) === true ) {
834-             $ tokensT_NAME_FULLY_QUALIFIED ] = \T_NAME_FULLY_QUALIFIED ;
835-         }
836- 
837-         if  (TokenHelper::tokenExists ('T_NAME_RELATIVE ' ) === true ) {
838-             $ tokensT_NAME_RELATIVE ] = \T_NAME_RELATIVE ;
839-         }
840- 
841-         return  $ tokens
842+         return  self ::$ nameTokens
842843    }
843844
844845    /** 
0 commit comments