PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Source for file PHP.php

Documentation is available at PHP.php

  1. <?php
  2. /**
  3.  * Tokenizes PHP code.
  4.  *
  5.  * @author    Greg Sherwood <gsherwood@squiz.net>
  6.  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  7.  * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  8.  */
  9.  
  10. namespace PHP_CodeSniffer\Tokenizers;
  11.  
  12. use PHP_CodeSniffer\Util;
  13.  
  14. class PHP extends Tokenizer
  15. {
  16.  
  17.  
  18.     /**
  19.      * A list of tokens that are allowed to open a scope.
  20.      *
  21.      * This array also contains information about what kind of token the scope
  22.      * opener uses to open and close the scope, if the token strictly requires
  23.      * an opener, if the token can share a scope closer, and who it can be shared
  24.      * with. An example of a token that shares a scope closer is a CASE scope.
  25.      *
  26.      * @var array 
  27.      */
  28.     public $scopeOpeners = array(
  29.                             T_IF            => array(
  30.                                                 'start'  => array(
  31.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  32.                                                              T_COLON              => T_COLON,
  33.                                                             ),
  34.                                                 'end'    => array(
  35.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  36.                                                              T_ENDIF               => T_ENDIF,
  37.                                                              T_ELSE                => T_ELSE,
  38.                                                              T_ELSEIF              => T_ELSEIF,
  39.                                                             ),
  40.                                                 'strict' => false,
  41.                                                 'shared' => false,
  42.                                                 'with'   => array(
  43.                                                              T_ELSE   => T_ELSE,
  44.                                                              T_ELSEIF => T_ELSEIF,
  45.                                                             ),
  46.                                                ),
  47.                             T_TRY           => array(
  48.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  49.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  50.                                                 'strict' => true,
  51.                                                 'shared' => false,
  52.                                                 'with'   => array(),
  53.                                                ),
  54.                             T_CATCH         => array(
  55.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  56.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  57.                                                 'strict' => true,
  58.                                                 'shared' => false,
  59.                                                 'with'   => array(),
  60.                                                ),
  61.                             T_FINALLY       => array(
  62.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  63.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  64.                                                 'strict' => true,
  65.                                                 'shared' => false,
  66.                                                 'with'   => array(),
  67.                                                ),
  68.                             T_ELSE          => array(
  69.                                                 'start'  => array(
  70.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  71.                                                              T_COLON              => T_COLON,
  72.                                                             ),
  73.                                                 'end'    => array(
  74.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  75.                                                              T_ENDIF               => T_ENDIF,
  76.                                                             ),
  77.                                                 'strict' => false,
  78.                                                 'shared' => false,
  79.                                                 'with'   => array(
  80.                                                              T_IF     => T_IF,
  81.                                                              T_ELSEIF => T_ELSEIF,
  82.                                                             ),
  83.                                                ),
  84.                             T_ELSEIF        => array(
  85.                                                 'start'  => array(
  86.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  87.                                                              T_COLON              => T_COLON,
  88.                                                             ),
  89.                                                 'end'    => array(
  90.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  91.                                                              T_ENDIF               => T_ENDIF,
  92.                                                              T_ELSE                => T_ELSE,
  93.                                                              T_ELSEIF              => T_ELSEIF,
  94.                                                             ),
  95.                                                 'strict' => false,
  96.                                                 'shared' => false,
  97.                                                 'with'   => array(
  98.                                                              T_IF   => T_IF,
  99.                                                              T_ELSE => T_ELSE,
  100.                                                             ),
  101.                                                ),
  102.                             T_FOR           => array(
  103.                                                 'start'  => array(
  104.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  105.                                                              T_COLON              => T_COLON,
  106.                                                             ),
  107.                                                 'end'    => array(
  108.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  109.                                                              T_ENDFOR              => T_ENDFOR,
  110.                                                             ),
  111.                                                 'strict' => false,
  112.                                                 'shared' => false,
  113.                                                 'with'   => array(),
  114.                                                ),
  115.                             T_FOREACH       => array(
  116.                                                 'start'  => array(
  117.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  118.                                                              T_COLON              => T_COLON,
  119.                                                             ),
  120.                                                 'end'    => array(
  121.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  122.                                                              T_ENDFOREACH          => T_ENDFOREACH,
  123.                                                             ),
  124.                                                 'strict' => false,
  125.                                                 'shared' => false,
  126.                                                 'with'   => array(),
  127.                                                ),
  128.                             T_INTERFACE     => array(
  129.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  130.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  131.                                                 'strict' => true,
  132.                                                 'shared' => false,
  133.                                                 'with'   => array(),
  134.                                                ),
  135.                             T_FUNCTION      => array(
  136.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  137.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  138.                                                 'strict' => true,
  139.                                                 'shared' => false,
  140.                                                 'with'   => array(),
  141.                                                ),
  142.                             T_CLASS         => array(
  143.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  144.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  145.                                                 'strict' => true,
  146.                                                 'shared' => false,
  147.                                                 'with'   => array(),
  148.                                                ),
  149.                             T_TRAIT         => array(
  150.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  151.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  152.                                                 'strict' => true,
  153.                                                 'shared' => false,
  154.                                                 'with'   => array(),
  155.                                                ),
  156.                             T_USE           => array(
  157.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  158.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  159.                                                 'strict' => false,
  160.                                                 'shared' => false,
  161.                                                 'with'   => array(),
  162.                                                ),
  163.                             T_DECLARE       => array(
  164.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  165.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  166.                                                 'strict' => false,
  167.                                                 'shared' => false,
  168.                                                 'with'   => array(),
  169.                                                ),
  170.                             T_NAMESPACE     => array(
  171.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  172.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  173.                                                 'strict' => false,
  174.                                                 'shared' => false,
  175.                                                 'with'   => array(),
  176.                                                ),
  177.                             T_WHILE         => array(
  178.                                                 'start'  => array(
  179.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  180.                                                              T_COLON              => T_COLON,
  181.                                                             ),
  182.                                                 'end'    => array(
  183.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  184.                                                              T_ENDWHILE            => T_ENDWHILE,
  185.                                                             ),
  186.                                                 'strict' => false,
  187.                                                 'shared' => false,
  188.                                                 'with'   => array(),
  189.                                                ),
  190.                             T_DO            => array(
  191.                                                 'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  192.                                                 'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  193.                                                 'strict' => true,
  194.                                                 'shared' => false,
  195.                                                 'with'   => array(),
  196.                                                ),
  197.                             T_SWITCH        => array(
  198.                                                 'start'  => array(
  199.                                                              T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET,
  200.                                                              T_COLON              => T_COLON,
  201.                                                             ),
  202.                                                 'end'    => array(
  203.                                                              T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  204.                                                              T_ENDSWITCH           => T_ENDSWITCH,
  205.                                                             ),
  206.                                                 'strict' => true,
  207.                                                 'shared' => false,
  208.                                                 'with'   => array(),
  209.                                                ),
  210.                             T_CASE          => array(
  211.                                                 'start'  => array(
  212.                                                              T_COLON     => T_COLON,
  213.                                                              T_SEMICOLON => T_SEMICOLON,
  214.                                                             ),
  215.                                                 'end'    => array(
  216.                                                              T_BREAK    => T_BREAK,
  217.                                                              T_RETURN   => T_RETURN,
  218.                                                              T_CONTINUE => T_CONTINUE,
  219.                                                              T_THROW    => T_THROW,
  220.                                                              T_EXIT     => T_EXIT,
  221.                                                             ),
  222.                                                 'strict' => true,
  223.                                                 'shared' => true,
  224.                                                 'with'   => array(
  225.                                                              T_DEFAULT => T_DEFAULT,
  226.                                                              T_CASE    => T_CASE,
  227.                                                              T_SWITCH  => T_SWITCH,
  228.                                                             ),
  229.                                                ),
  230.                             T_DEFAULT       => array(
  231.                                                 'start'  => array(
  232.                                                              T_COLON     => T_COLON,
  233.                                                              T_SEMICOLON => T_SEMICOLON,
  234.                                                             ),
  235.                                                 'end'    => array(
  236.                                                              T_BREAK    => T_BREAK,
  237.                                                              T_RETURN   => T_RETURN,
  238.                                                              T_CONTINUE => T_CONTINUE,
  239.                                                              T_THROW    => T_THROW,
  240.                                                              T_EXIT     => T_EXIT,
  241.                                                             ),
  242.                                                 'strict' => true,
  243.                                                 'shared' => true,
  244.                                                 'with'   => array(
  245.                                                              T_CASE   => T_CASE,
  246.                                                              T_SWITCH => T_SWITCH,
  247.                                                             ),
  248.                                                ),
  249.                             T_START_HEREDOC => array(
  250.                                                 'start'  => array(T_START_HEREDOC => T_START_HEREDOC),
  251.                                                 'end'    => array(T_END_HEREDOC => T_END_HEREDOC),
  252.                                                 'strict' => true,
  253.                                                 'shared' => false,
  254.                                                 'with'   => array(),
  255.                                                ),
  256.                            );
  257.  
  258.     /**
  259.      * A list of tokens that end the scope.
  260.      *
  261.      * This array is just a unique collection of the end tokens
  262.      * from the _scopeOpeners array. The data is duplicated here to
  263.      * save time during parsing of the file.
  264.      *
  265.      * @var array 
  266.      */
  267.     public $endScopeTokens = array(
  268.                               T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  269.                               T_ENDIF               => T_ENDIF,
  270.                               T_ENDFOR              => T_ENDFOR,
  271.                               T_ENDFOREACH          => T_ENDFOREACH,
  272.                               T_ENDWHILE            => T_ENDWHILE,
  273.                               T_ENDSWITCH           => T_ENDSWITCH,
  274.                               T_BREAK               => T_BREAK,
  275.                               T_END_HEREDOC         => T_END_HEREDOC,
  276.                              );
  277.  
  278.     /**
  279.      * Known lengths of tokens.
  280.      *
  281.      * @var array<int, int>
  282.      */
  283.     public $knownLengths = array(
  284.                             T_ABSTRACT                 => 8,
  285.                             T_AND_EQUAL                => 2,
  286.                             T_ARRAY                    => 5,
  287.                             T_AS                       => 2,
  288.                             T_BOOLEAN_AND              => 2,
  289.                             T_BOOLEAN_OR               => 2,
  290.                             T_BREAK                    => 5,
  291.                             T_CALLABLE                 => 8,
  292.                             T_CASE                     => 4,
  293.                             T_CATCH                    => 5,
  294.                             T_CLASS                    => 5,
  295.                             T_CLASS_C                  => 9,
  296.                             T_CLONE                    => 5,
  297.                             T_CONCAT_EQUAL             => 2,
  298.                             T_CONST                    => 5,
  299.                             T_CONTINUE                 => 8,
  300.                             T_CURLY_OPEN               => 2,
  301.                             T_DEC                      => 2,
  302.                             T_DECLARE                  => 7,
  303.                             T_DEFAULT                  => 7,
  304.                             T_DIR                      => 7,
  305.                             T_DIV_EQUAL                => 2,
  306.                             T_DO                       => 2,
  307.                             T_DOLLAR_OPEN_CURLY_BRACES => 2,
  308.                             T_DOUBLE_ARROW             => 2,
  309.                             T_DOUBLE_COLON             => 2,
  310.                             T_ECHO                     => 4,
  311.                             T_ELSE                     => 4,
  312.                             T_ELSEIF                   => 6,
  313.                             T_EMPTY                    => 5,
  314.                             T_ENDDECLARE               => 10,
  315.                             T_ENDFOR                   => 6,
  316.                             T_ENDFOREACH               => 10,
  317.                             T_ENDIF                    => 5,
  318.                             T_ENDSWITCH                => 9,
  319.                             T_ENDWHILE                 => 8,
  320.                             T_EVAL                     => 4,
  321.                             T_EXTENDS                  => 7,
  322.                             T_FILE                     => 8,
  323.                             T_FINAL                    => 5,
  324.                             T_FINALLY                  => 7,
  325.                             T_FOR                      => 3,
  326.                             T_FOREACH                  => 7,
  327.                             T_FUNCTION                 => 8,
  328.                             T_FUNC_C                   => 12,
  329.                             T_GLOBAL                   => 6,
  330.                             T_GOTO                     => 4,
  331.                             T_HALT_COMPILER            => 15,
  332.                             T_IF                       => 2,
  333.                             T_IMPLEMENTS               => 10,
  334.                             T_INC                      => 2,
  335.                             T_INCLUDE                  => 7,
  336.                             T_INCLUDE_ONCE             => 12,
  337.                             T_INSTANCEOF               => 10,
  338.                             T_INSTEADOF                => 9,
  339.                             T_INTERFACE                => 9,
  340.                             T_ISSET                    => 5,
  341.                             T_IS_EQUAL                 => 2,
  342.                             T_IS_GREATER_OR_EQUAL      => 2,
  343.                             T_IS_IDENTICAL             => 3,
  344.                             T_IS_NOT_EQUAL             => 2,
  345.                             T_IS_NOT_IDENTICAL         => 3,
  346.                             T_IS_SMALLER_OR_EQUAL      => 2,
  347.                             T_LINE                     => 8,
  348.                             T_LIST                     => 4,
  349.                             T_LOGICAL_AND              => 3,
  350.                             T_LOGICAL_OR               => 2,
  351.                             T_LOGICAL_XOR              => 3,
  352.                             T_METHOD_C                 => 10,
  353.                             T_MINUS_EQUAL              => 2,
  354.                             T_POW_EQUAL                => 3,
  355.                             T_MOD_EQUAL                => 2,
  356.                             T_MUL_EQUAL                => 2,
  357.                             T_NAMESPACE                => 9,
  358.                             T_NS_C                     => 13,
  359.                             T_NS_SEPARATOR             => 1,
  360.                             T_NEW                      => 3,
  361.                             T_OBJECT_OPERATOR          => 2,
  362.                             T_OPEN_TAG_WITH_ECHO       => 3,
  363.                             T_OR_EQUAL                 => 2,
  364.                             T_PLUS_EQUAL               => 2,
  365.                             T_PRINT                    => 5,
  366.                             T_PRIVATE                  => 7,
  367.                             T_PUBLIC                   => 6,
  368.                             T_PROTECTED                => 9,
  369.                             T_REQUIRE                  => 7,
  370.                             T_REQUIRE_ONCE             => 12,
  371.                             T_RETURN                   => 6,
  372.                             T_STATIC                   => 6,
  373.                             T_SWITCH                   => 6,
  374.                             T_THROW                    => 5,
  375.                             T_TRAIT                    => 5,
  376.                             T_TRAIT_C                  => 9,
  377.                             T_TRY                      => 3,
  378.                             T_UNSET                    => 5,
  379.                             T_USE                      => 3,
  380.                             T_VAR                      => 3,
  381.                             T_WHILE                    => 5,
  382.                             T_XOR_EQUAL                => 2,
  383.                             T_YIELD                    => 5,
  384.                             T_OPEN_CURLY_BRACKET       => 1,
  385.                             T_CLOSE_CURLY_BRACKET      => 1,
  386.                             T_OPEN_SQUARE_BRACKET      => 1,
  387.                             T_CLOSE_SQUARE_BRACKET     => 1,
  388.                             T_OPEN_PARENTHESIS         => 1,
  389.                             T_CLOSE_PARENTHESIS        => 1,
  390.                             T_COLON                    => 1,
  391.                             T_STRING_CONCAT            => 1,
  392.                             T_INLINE_THEN              => 1,
  393.                             T_INLINE_ELSE              => 1,
  394.                             T_NULL                     => 4,
  395.                             T_FALSE                    => 5,
  396.                             T_TRUE                     => 4,
  397.                             T_SEMICOLON                => 1,
  398.                             T_EQUAL                    => 1,
  399.                             T_MULTIPLY                 => 1,
  400.                             T_DIVIDE                   => 1,
  401.                             T_PLUS                     => 1,
  402.                             T_MINUS                    => 1,
  403.                             T_MODULUS                  => 1,
  404.                             T_POW                      => 2,
  405.                             T_SPACESHIP                => 3,
  406.                             T_COALESCE                 => 2,
  407.                             T_BITWISE_AND              => 1,
  408.                             T_BITWISE_OR               => 1,
  409.                             T_BITWISE_XOR              => 1,
  410.                             T_SL                       => 2,
  411.                             T_SR                       => 2,
  412.                             T_SL_EQUAL                 => 3,
  413.                             T_SR_EQUAL                 => 3,
  414.                             T_ARRAY_HINT               => 5,
  415.                             T_GREATER_THAN             => 1,
  416.                             T_LESS_THAN                => 1,
  417.                             T_BOOLEAN_NOT              => 1,
  418.                             T_SELF                     => 4,
  419.                             T_PARENT                   => 6,
  420.                             T_COMMA                    => 1,
  421.                             T_THIS                     => 4,
  422.                             T_CLOSURE                  => 8,
  423.                             T_BACKTICK                 => 1,
  424.                             T_OPEN_SHORT_ARRAY         => 1,
  425.                             T_CLOSE_SHORT_ARRAY        => 1,
  426.                            );
  427.  
  428.  
  429.     /**
  430.      * A cache of different token types, resolved into arrays.
  431.      *
  432.      * @var array 
  433.      * @see standardiseToken()
  434.      */
  435.     private static $resolveTokenCache = array();
  436.  
  437.  
  438.     /**
  439.      * Creates an array of tokens when given some PHP code.
  440.      *
  441.      * Starts by using token_get_all() but does a lot of extra processing
  442.      * to insert information about the context of the token.
  443.      *
  444.      * @param string $string The string to tokenize.
  445.      *
  446.      * @return array 
  447.      */
  448.     protected function tokenize($string)
  449.     {
  450.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  451.             echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
  452.             $isWin = false;
  453.             if (strtoupper(substr(PHP_OS03)) === 'WIN'{
  454.                 $isWin = true;
  455.             }
  456.         }
  457.  
  458.         $tokens      @token_get_all($string);
  459.         $finalTokens = array();
  460.  
  461.         $newStackPtr       = 0;
  462.         $numTokens         count($tokens);
  463.         $lastNotEmptyToken = 0;
  464.  
  465.         $insideInlineIf = array();
  466.         $insideUseGroup = false;
  467.  
  468.         $commentTokenizer = new Comment();
  469.  
  470.         for ($stackPtr = 0; $stackPtr $numTokens$stackPtr++{
  471.             $token        = (array) $tokens[$stackPtr];
  472.             $tokenIsArray = isset($token[1]);
  473.  
  474.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  475.                 if ($tokenIsArray === true{
  476.                     $type    token_name($token[0]);
  477.                     $content = Util\Common::prepareForOutput($token[1]);
  478.                 else {
  479.                     $newToken = self::resolveSimpleToken($token[0]);
  480.                     $type     $newToken['type'];
  481.                     $content  = Util\Common::prepareForOutput($token[0]);
  482.                 }
  483.  
  484.                 echo "\tProcess token ";
  485.                 if ($tokenIsArray === true{
  486.                     echo "[$stackPtr]";
  487.                 else {
  488.                     echo " $stackPtr ";
  489.                 }
  490.  
  491.                 echo "$type => $content";
  492.             }//end if
  493.  
  494.             if ($newStackPtr > 0 && $finalTokens[($newStackPtr - 1)]['code'!== T_WHITESPACE{
  495.                 $lastNotEmptyToken ($newStackPtr - 1);
  496.             }
  497.  
  498.             /*
  499.                 If we are using \r\n newline characters, the \r and \n are sometimes
  500.                 split over two tokens. This normally occurs after comments. We need
  501.                 to merge these two characters together so that our line endings are
  502.                 consistent for all lines.
  503.             */
  504.  
  505.             if ($tokenIsArray === true && substr($token[1]-1=== "\r"{
  506.                 if (isset($tokens[($stackPtr + 1)]=== true
  507.                     && is_array($tokens[($stackPtr + 1)]=== true
  508.                     && $tokens[($stackPtr + 1)][1][0=== "\n"
  509.                 {
  510.                     $token[1.= "\n";
  511.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  512.                         if ($isWin === true{
  513.                             echo '\n';
  514.                         else {
  515.                             echo "\033[30;1m\\n\033[0m";
  516.                         }
  517.                     }
  518.  
  519.                     if ($tokens[($stackPtr + 1)][1=== "\n"{
  520.                         // This token's content has been merged into the previous,
  521.                         // so we can skip it.
  522.                         $tokens[($stackPtr + 1)'';
  523.                     else {
  524.                         $tokens[($stackPtr + 1)][1substr($tokens[($stackPtr + 1)][1]1);
  525.                     }
  526.                 }
  527.             }//end if
  528.  
  529.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  530.                 echo PHP_EOL;
  531.             }
  532.  
  533.             /*
  534.                 Parse doc blocks into something that can be easily iterated over.
  535.             */
  536.  
  537.             if ($tokenIsArray === true && $token[0=== T_DOC_COMMENT{
  538.                 $commentTokens $commentTokenizer->tokenizeString($token[1]$this->eolChar$newStackPtr);
  539.                 foreach ($commentTokens as $commentToken{
  540.                     $finalTokens[$newStackPtr$commentToken;
  541.                     $newStackPtr++;
  542.                 }
  543.  
  544.                 continue;
  545.             }
  546.  
  547.             /*
  548.                 If this is a double quoted string, PHP will tokenize the whole
  549.                 thing which causes problems with the scope map when braces are
  550.                 within the string. So we need to merge the tokens together to
  551.                 provide a single string.
  552.             */
  553.  
  554.             if ($tokenIsArray === false && ($token[0=== '"' || $token[0=== 'b"')) {
  555.                 // Binary casts need a special token.
  556.                 if ($token[0=== 'b"'{
  557.                     $finalTokens[$newStackPtr= array(
  558.                                                   'code'    => T_BINARY_CAST,
  559.                                                   'type'    => 'T_BINARY_CAST',
  560.                                                   'content' => 'b',
  561.                                                  );
  562.                     $newStackPtr++;
  563.                 }
  564.  
  565.                 $tokenContent '"';
  566.                 $nestedVars   = array();
  567.                 for ($i ($stackPtr + 1)$i $numTokens$i++{
  568.                     $subToken        = (array) $tokens[$i];
  569.                     $subTokenIsArray = isset($subToken[1]);
  570.  
  571.                     if ($subTokenIsArray === true{
  572.                         $tokenContent .= $subToken[1];
  573.                         if ($subToken[1=== '{'
  574.                             && $subToken[0!== T_ENCAPSED_AND_WHITESPACE
  575.                         {
  576.                             $nestedVars[$i;
  577.                         }
  578.                     else {
  579.                         $tokenContent .= $subToken[0];
  580.                         if ($subToken[0=== '}'{
  581.                             array_pop($nestedVars);
  582.                         }
  583.                     }
  584.  
  585.                     if ($subTokenIsArray === false
  586.                         && $subToken[0=== '"'
  587.                         && empty($nestedVars=== true
  588.                     {
  589.                         // We found the other end of the double quoted string.
  590.                         break;
  591.                     }
  592.                 }//end for
  593.  
  594.                 $stackPtr $i;
  595.  
  596.                 // Convert each line within the double quoted string to a
  597.                 // new token, so it conforms with other multiple line tokens.
  598.                 $tokenLines explode($this->eolChar$tokenContent);
  599.                 $numLines   count($tokenLines);
  600.                 $newToken   = array();
  601.  
  602.                 for ($j = 0; $j $numLines$j++{
  603.                     $newToken['content'$tokenLines[$j];
  604.                     if ($j === ($numLines - 1)) {
  605.                         if ($tokenLines[$j=== ''{
  606.                             break;
  607.                         }
  608.                     else {
  609.                         $newToken['content'.= $this->eolChar;
  610.                     }
  611.  
  612.                     $newToken['code']          T_DOUBLE_QUOTED_STRING;
  613.                     $newToken['type']          'T_DOUBLE_QUOTED_STRING';
  614.                     $finalTokens[$newStackPtr$newToken;
  615.                     $newStackPtr++;
  616.                 }
  617.  
  618.                 // Continue, as we're done with this token.
  619.                 continue;
  620.             }//end if
  621.  
  622.             /*
  623.                 If this is a heredoc, PHP will tokenize the whole
  624.                 thing which causes problems when heredocs don't
  625.                 contain real PHP code, which is almost never.
  626.                 We want to leave the start and end heredoc tokens
  627.                 alone though.
  628.             */
  629.  
  630.             if ($tokenIsArray === true && $token[0=== T_START_HEREDOC{
  631.                 // Add the start heredoc token to the final array.
  632.                 $finalTokens[$newStackPtr= self::standardiseToken($token);
  633.  
  634.                 // Check if this is actually a nowdoc and use a different token
  635.                 // to help the sniffs.
  636.                 $nowdoc = false;
  637.                 if ($token[1][3=== "'"{
  638.                     $finalTokens[$newStackPtr]['code'T_START_NOWDOC;
  639.                     $finalTokens[$newStackPtr]['type''T_START_NOWDOC';
  640.                     $nowdoc = true;
  641.                 }
  642.  
  643.                 $tokenContent '';
  644.                 for ($i ($stackPtr + 1)$i $numTokens$i++{
  645.                     $subTokenIsArray is_array($tokens[$i]);
  646.                     if ($subTokenIsArray === true
  647.                         && $tokens[$i][0=== T_END_HEREDOC
  648.                     {
  649.                         // We found the other end of the heredoc.
  650.                         break;
  651.                     }
  652.  
  653.                     if ($subTokenIsArray === true{
  654.                         $tokenContent .= $tokens[$i][1];
  655.                     else {
  656.                         $tokenContent .= $tokens[$i];
  657.                     }
  658.                 }
  659.  
  660.                 if ($i === $numTokens{
  661.                     // We got to the end of the file and never
  662.                     // found the closing token, so this probably wasn't
  663.                     // a heredoc.
  664.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  665.                         $type $finalTokens[$newStackPtr]['type'];
  666.                         echo "\t\t* failed to find the end of the here/nowdoc".PHP_EOL;
  667.                         echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL;
  668.                     }
  669.  
  670.                     $finalTokens[$newStackPtr]['code'= T_STRING;
  671.                     $finalTokens[$newStackPtr]['type''T_STRING';
  672.                     $newStackPtr++;
  673.                     continue;
  674.                 }
  675.  
  676.                 $stackPtr $i;
  677.                 $newStackPtr++;
  678.  
  679.                 // Convert each line within the heredoc to a
  680.                 // new token, so it conforms with other multiple line tokens.
  681.                 $tokenLines explode($this->eolChar$tokenContent);
  682.                 $numLines   count($tokenLines);
  683.                 $newToken   = array();
  684.  
  685.                 for ($j = 0; $j $numLines$j++{
  686.                     $newToken['content'$tokenLines[$j];
  687.                     if ($j === ($numLines - 1)) {
  688.                         if ($tokenLines[$j=== ''{
  689.                             break;
  690.                         }
  691.                     else {
  692.                         $newToken['content'.= $this->eolChar;
  693.                     }
  694.  
  695.                     if ($nowdoc === true{
  696.                         $newToken['code'T_NOWDOC;
  697.                         $newToken['type''T_NOWDOC';
  698.                     else {
  699.                         $newToken['code'T_HEREDOC;
  700.                         $newToken['type''T_HEREDOC';
  701.                     }
  702.  
  703.                     $finalTokens[$newStackPtr$newToken;
  704.                     $newStackPtr++;
  705.                 }//end for
  706.  
  707.                 // Add the end heredoc token to the final array.
  708.                 $finalTokens[$newStackPtr= self::standardiseToken($tokens[$stackPtr]);
  709.  
  710.                 if ($nowdoc === true{
  711.                     $finalTokens[$newStackPtr]['code'T_END_NOWDOC;
  712.                     $finalTokens[$newStackPtr]['type''T_END_NOWDOC';
  713.                     $nowdoc = true;
  714.                 }
  715.  
  716.                 $newStackPtr++;
  717.  
  718.                 // Continue, as we're done with this token.
  719.                 continue;
  720.             }//end if
  721.  
  722.             /*
  723.                 Before PHP 5.6, the ... operator was tokenized as three
  724.                 T_STRING_CONCAT tokens in a row. So look for and combine
  725.                 these tokens in earlier versions.
  726.             */
  727.  
  728.             if ($tokenIsArray === false
  729.                 && $token[0=== '.'
  730.                 && isset($tokens[($stackPtr + 1)]=== true
  731.                 && isset($tokens[($stackPtr + 2)]=== true
  732.                 && $tokens[($stackPtr + 1)=== '.'
  733.                 && $tokens[($stackPtr + 2)=== '.'
  734.             {
  735.                 $newToken            = array();
  736.                 $newToken['code']    T_ELLIPSIS;
  737.                 $newToken['type']    'T_ELLIPSIS';
  738.                 $newToken['content''...';
  739.                 $finalTokens[$newStackPtr$newToken;
  740.  
  741.                 $newStackPtr++;
  742.                 $stackPtr += 2;
  743.                 continue;
  744.             }
  745.  
  746.             /*
  747.                 Before PHP 5.6, the ** operator was tokenized as two
  748.                 T_MULTIPLY tokens in a row. So look for and combine
  749.                 these tokens in earlier versions.
  750.             */
  751.  
  752.             if ($tokenIsArray === false
  753.                 && $token[0=== '*'
  754.                 && isset($tokens[($stackPtr + 1)]=== true
  755.                 && $tokens[($stackPtr + 1)=== '*'
  756.             {
  757.                 $newToken            = array();
  758.                 $newToken['code']    T_POW;
  759.                 $newToken['type']    'T_POW';
  760.                 $newToken['content''**';
  761.                 $finalTokens[$newStackPtr$newToken;
  762.  
  763.                 $newStackPtr++;
  764.                 $stackPtr++;
  765.                 continue;
  766.             }
  767.  
  768.             /*
  769.                 Before PHP 5.6, the **= operator was tokenized as
  770.                 T_MULTIPLY followed by T_MUL_EQUAL. So look for and combine
  771.                 these tokens in earlier versions.
  772.             */
  773.  
  774.             if ($tokenIsArray === false
  775.                 && $token[0=== '*'
  776.                 && isset($tokens[($stackPtr + 1)]=== true
  777.                 && is_array($tokens[($stackPtr + 1)]=== true
  778.                 && $tokens[($stackPtr + 1)][1=== '*='
  779.             {
  780.                 $newToken            = array();
  781.                 $newToken['code']    T_POW_EQUAL;
  782.                 $newToken['type']    'T_POW_EQUAL';
  783.                 $newToken['content''**=';
  784.                 $finalTokens[$newStackPtr$newToken;
  785.  
  786.                 $newStackPtr++;
  787.                 $stackPtr++;
  788.                 continue;
  789.             }
  790.  
  791.             /*
  792.                 Before PHP 7, the ?? operator was tokenized as
  793.                 T_INLINE_THEN followed by T_INLINE_THEN.
  794.                 So look for and combine these tokens in earlier versions.
  795.             */
  796.  
  797.             if ($tokenIsArray === false
  798.                 && $token[0=== '?'
  799.                 && isset($tokens[($stackPtr + 1)]=== true
  800.                 && $tokens[($stackPtr + 1)][0=== '?'
  801.             {
  802.                 $newToken            = array();
  803.                 $newToken['code']    T_COALESCE;
  804.                 $newToken['type']    'T_COALESCE';
  805.                 $newToken['content''??';
  806.                 $finalTokens[$newStackPtr$newToken;
  807.  
  808.                 $newStackPtr++;
  809.                 $stackPtr++;
  810.                 continue;
  811.             }
  812.  
  813.             /*
  814.                 Tokens after a double colon may be look like scope openers,
  815.                 such as when writing code like Foo::NAMESAPCE, but they are
  816.                 only ever variables or strings.
  817.             */
  818.  
  819.             if ($stackPtr > 1
  820.                 && $tokens[($stackPtr - 1)][0=== T_PAAMAYIM_NEKUDOTAYIM
  821.                 && $tokenIsArray === true
  822.                 && $token[0!== T_STRING
  823.                 && $token[0!== T_VARIABLE
  824.                 && $token[0!== T_DOLLAR
  825.                 && isset(Util\Tokens::$emptyTokens[$token[0]]=== false
  826.             {
  827.                 $newToken            = array();
  828.                 $newToken['code']    = T_STRING;
  829.                 $newToken['type']    'T_STRING';
  830.                 $newToken['content'$token[1];
  831.                 $finalTokens[$newStackPtr$newToken;
  832.  
  833.                 $newStackPtr++;
  834.                 continue;
  835.             }
  836.  
  837.             /*
  838.                 Before PHP 7, the <=> operator was tokenized as
  839.                 T_IS_SMALLER_OR_EQUAL followed by T_GREATER_THAN.
  840.                 So look for and combine these tokens in earlier versions.
  841.             */
  842.  
  843.             if ($tokenIsArray === true
  844.                 && $token[0=== T_IS_SMALLER_OR_EQUAL
  845.                 && isset($tokens[($stackPtr + 1)]=== true
  846.                 && $tokens[($stackPtr + 1)][0=== '>'
  847.             {
  848.                 $newToken            = array();
  849.                 $newToken['code']    T_SPACESHIP;
  850.                 $newToken['type']    'T_SPACESHIP';
  851.                 $newToken['content''<=>';
  852.                 $finalTokens[$newStackPtr$newToken;
  853.  
  854.                 $newStackPtr++;
  855.                 $stackPtr++;
  856.                 continue;
  857.             }
  858.  
  859.             /*
  860.                 PHP doesn't assign a token to goto labels, so we have to.
  861.                 These are just string tokens with a single colon after them. Double
  862.                 colons are already tokenized and so don't interfere with this check.
  863.                 But we do have to account for CASE statements, that look just like
  864.                 goto labels.
  865.             */
  866.  
  867.             if ($tokenIsArray === true
  868.                 && $token[0=== T_STRING
  869.                 && isset($tokens[($stackPtr + 1)]=== true
  870.                 && $tokens[($stackPtr + 1)=== ':'
  871.                 && $tokens[($stackPtr - 1)][0!== T_PAAMAYIM_NEKUDOTAYIM
  872.             {
  873.                 $stopTokens = array(
  874.                                T_CASE               => true,
  875.                                T_SEMICOLON          => true,
  876.                                T_OPEN_CURLY_BRACKET => true,
  877.                                T_INLINE_THEN        => true,
  878.                               );
  879.  
  880.                 for ($x ($newStackPtr - 1)$x > 0; $x--{
  881.                     if (isset($stopTokens[$finalTokens[$x]['code']]=== true{
  882.                         break;
  883.                     }
  884.                 }
  885.  
  886.                 if ($finalTokens[$x]['code'!== T_CASE
  887.                     && $finalTokens[$x]['code'!== T_INLINE_THEN
  888.                 {
  889.                     $finalTokens[$newStackPtr= array(
  890.                                                   'content' => $token[1].':',
  891.                                                   'code'    => T_GOTO_LABEL,
  892.                                                   'type'    => 'T_GOTO_LABEL',
  893.                                                  );
  894.  
  895.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  896.                         echo "\t\t* token $stackPtr changed from T_STRING to T_GOTO_LABEL".PHP_EOL;
  897.                         echo "\t\t* skipping T_COLON token ".($stackPtr + 1).PHP_EOL;
  898.                     }
  899.  
  900.                     $newStackPtr++;
  901.                     $stackPtr++;
  902.                     continue;
  903.                 }
  904.             }//end if
  905.  
  906.             /*
  907.                 HHVM 3.5 tokenizes "else[\s]+if" as a T_ELSEIF token while PHP
  908.                 proper only tokenizes "elseif" as a T_ELSEIF token. So split
  909.                 up the HHVM token to make it looks like proper PHP.
  910.             */
  911.  
  912.             if ($tokenIsArray === true
  913.                 && $token[0=== T_ELSEIF
  914.                 && strtolower($token[1]!== 'elseif'
  915.             {
  916.                 $finalTokens[$newStackPtr= array(
  917.                                               'content' => substr($token[1]04),
  918.                                               'code'    => T_ELSE,
  919.                                               'type'    => 'T_ELSE',
  920.                                              );
  921.  
  922.                 $newStackPtr++;
  923.                 $finalTokens[$newStackPtr= array(
  924.                                               'content' => substr($token[1]4-2),
  925.                                               'code'    => T_WHITESPACE,
  926.                                               'type'    => 'T_WHITESPACE',
  927.                                              );
  928.  
  929.                 $newStackPtr++;
  930.                 $finalTokens[$newStackPtr= array(
  931.                                               'content' => substr($token[1]-2),
  932.                                               'code'    => T_IF,
  933.                                               'type'    => 'T_IF',
  934.                                              );
  935.  
  936.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  937.                     echo "\t\t* token $stackPtr changed from T_ELSEIF to T_ELSE/T_WHITESPACE/T_IF".PHP_EOL;
  938.                 }
  939.  
  940.                 $newStackPtr++;
  941.                 continue;
  942.             }//end if
  943.  
  944.             /*
  945.                 HHVM 3.5 and 3.6 tokenizes a hashbang line such as #!/usr/bin/php
  946.                 as T_HASHBANG while PHP proper uses T_INLINE_HTML.
  947.             */
  948.  
  949.             if ($tokenIsArray === true && token_name($token[0]=== 'T_HASHBANG'{
  950.                 $finalTokens[$newStackPtr= array(
  951.                                               'content' => $token[1],
  952.                                               'code'    => T_INLINE_HTML,
  953.                                               'type'    => 'T_INLINE_HTML',
  954.                                              );
  955.  
  956.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  957.                     echo "\t\t* token $stackPtr changed from T_HASHBANG to T_INLINE_HTML".PHP_EOL;
  958.                 }
  959.  
  960.                 $newStackPtr++;
  961.                 continue;
  962.             }//end if
  963.  
  964.             /*
  965.                 If this token has newlines in its content, split each line up
  966.                 and create a new token for each line. We do this so it's easier
  967.                 to ascertain where errors occur on a line.
  968.                 Note that $token[1] is the token's content.
  969.             */
  970.  
  971.             if ($tokenIsArray === true && strpos($token[1]$this->eolChar!== false{
  972.                 $tokenLines explode($this->eolChar$token[1]);
  973.                 $numLines   count($tokenLines);
  974.                 $newToken   = array(
  975.                                'type'    => token_name($token[0]),
  976.                                'code'    => $token[0],
  977.                                'content' => '',
  978.                               );
  979.  
  980.                 for ($i = 0; $i $numLines$i++{
  981.                     $newToken['content'$tokenLines[$i];
  982.                     if ($i === ($numLines - 1)) {
  983.                         if ($tokenLines[$i=== ''{
  984.                             break;
  985.                         }
  986.                     else {
  987.                         $newToken['content'.= $this->eolChar;
  988.                     }
  989.  
  990.                     $finalTokens[$newStackPtr$newToken;
  991.                     $newStackPtr++;
  992.                 }
  993.             else {
  994.                 if ($tokenIsArray === true && $token[0=== T_STRING{
  995.                     // Some T_STRING tokens should remain that way
  996.                     // due to their context.
  997.                     $context = array(
  998.                                 T_OBJECT_OPERATOR      => true,
  999.                                 T_FUNCTION             => true,
  1000.                                 T_CLASS                => true,
  1001.                                 T_EXTENDS              => true,
  1002.                                 T_IMPLEMENTS           => true,
  1003.                                 T_NEW                  => true,
  1004.                                 T_CONST                => true,
  1005.                                 T_NS_SEPARATOR         => true,
  1006.                                 T_USE                  => true,
  1007.                                 T_NAMESPACE            => true,
  1008.                                 T_PAAMAYIM_NEKUDOTAYIM => true,
  1009.                                );
  1010.                     if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]=== true{
  1011.                         $finalTokens[$newStackPtr= array(
  1012.                                                       'content' => $token[1],
  1013.                                                       'code'    => T_STRING,
  1014.                                                       'type'    => 'T_STRING',
  1015.                                                      );
  1016.                         $newStackPtr++;
  1017.                         continue;
  1018.                     }
  1019.                 }//end if
  1020.  
  1021.                 $newToken = null;
  1022.                 if ($tokenIsArray === false{
  1023.                     if (isset(self::$resolveTokenCache[$token[0]]=== true{
  1024.                         $newToken = self::$resolveTokenCache[$token[0]];
  1025.                     }
  1026.                 else {
  1027.                     $cacheKey = null;
  1028.                     if ($token[0=== T_STRING{
  1029.                         $cacheKey strtolower($token[1]);
  1030.                     else if ($token[0!== T_CURLY_OPEN{
  1031.                         $cacheKey $token[0];
  1032.                     }
  1033.  
  1034.                     if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]=== true{
  1035.                         $newToken            = self::$resolveTokenCache[$cacheKey];
  1036.                         $newToken['content'$token[1];
  1037.                     }
  1038.                 }
  1039.  
  1040.                 if ($newToken === null{
  1041.                     $newToken = self::standardiseToken($token);
  1042.                 }
  1043.  
  1044.                 // Convert colons that are actually the ELSE component of an
  1045.                 // inline IF statement.
  1046.                 if ($newToken['code'=== T_INLINE_THEN{
  1047.                     $insideInlineIf[$stackPtr;
  1048.                 else if (empty($insideInlineIf=== false && $newToken['code'=== T_COLON{
  1049.                     array_pop($insideInlineIf);
  1050.                     $newToken['code'T_INLINE_ELSE;
  1051.                     $newToken['type''T_INLINE_ELSE';
  1052.                 }
  1053.  
  1054.                 // This is a special condition for T_ARRAY tokens used for
  1055.                 // type hinting function arguments as being arrays. We want to keep
  1056.                 // the parenthesis map clean, so let's tag these tokens as
  1057.                 // T_ARRAY_HINT.
  1058.                 if ($newToken['code'=== T_ARRAY{
  1059.                     for ($i $stackPtr$i $numTokens$i++{
  1060.                         if ($tokens[$i=== '('{
  1061.                             break;
  1062.                         else if ($tokens[$i][0=== T_VARIABLE{
  1063.                             $newToken['code'T_ARRAY_HINT;
  1064.                             $newToken['type''T_ARRAY_HINT';
  1065.                             break;
  1066.                         }
  1067.                     }
  1068.                 }
  1069.  
  1070.                 // This is a special case when checking PHP 5.5+ code in PHP < 5.5
  1071.                 // where "finally" should be T_FINALLY instead of T_STRING.
  1072.                 if ($newToken['code'=== T_STRING
  1073.                     && strtolower($newToken['content']=== 'finally'
  1074.                 {
  1075.                     $newToken['code'T_FINALLY;
  1076.                     $newToken['type''T_FINALLY';
  1077.                 }
  1078.  
  1079.                 // This is a special case for the PHP 5.5 classname::class syntax
  1080.                 // where "class" should be T_STRING instead of T_CLASS.
  1081.                 if (($newToken['code'=== T_CLASS
  1082.                     || $newToken['code'=== T_FUNCTION)
  1083.                     && $finalTokens[($newStackPtr - 1)]['code'=== T_DOUBLE_COLON
  1084.                 {
  1085.                     $newToken['code'= T_STRING;
  1086.                     $newToken['type''T_STRING';
  1087.                 }
  1088.  
  1089.                 // This is a special case for PHP 5.6 use function and use const
  1090.                 // where "function" and "const" should be T_STRING instead of T_FUNCTION
  1091.                 // and T_CONST.
  1092.                 if (($newToken['code'=== T_FUNCTION
  1093.                     || $newToken['code'=== T_CONST)
  1094.                     && $finalTokens[$lastNotEmptyToken]['code'=== T_USE
  1095.                 {
  1096.                     $newToken['code'= T_STRING;
  1097.                     $newToken['type''T_STRING';
  1098.                 }
  1099.  
  1100.                 // This is a special case for use groups in PHP 7+ where leaving
  1101.                 // the curly braces as their normal tokens would confuse
  1102.                 // the scope map and sniffs.
  1103.                 if ($newToken['code'=== T_OPEN_CURLY_BRACKET
  1104.                     && $finalTokens[$lastNotEmptyToken]['code'=== T_NS_SEPARATOR
  1105.                 {
  1106.                     $newToken['code'T_OPEN_USE_GROUP;
  1107.                     $newToken['type''T_OPEN_USE_GROUP';
  1108.                     $insideUseGroup   = true;
  1109.                 }
  1110.  
  1111.                 if ($insideUseGroup === true && $newToken['code'=== T_CLOSE_CURLY_BRACKET{
  1112.                     $newToken['code'T_CLOSE_USE_GROUP;
  1113.                     $newToken['type''T_CLOSE_USE_GROUP';
  1114.                     $insideUseGroup   = false;
  1115.                 }
  1116.  
  1117.                 $finalTokens[$newStackPtr$newToken;
  1118.                 $newStackPtr++;
  1119.             }//end if
  1120.         }//end for
  1121.  
  1122.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1123.             echo "\t*** END PHP TOKENIZING ***".PHP_EOL;
  1124.         }
  1125.  
  1126.         return $finalTokens;
  1127.  
  1128.     }//end tokenize()
  1129.  
  1130.  
  1131.     /**
  1132.      * Performs additional processing after main tokenizing.
  1133.      *
  1134.      * This additional processing checks for CASE statements that are using curly
  1135.      * braces for scope openers and closers. It also turns some T_FUNCTION tokens
  1136.      * into T_CLOSURE when they are not standard function definitions. It also
  1137.      * detects short array syntax and converts those square brackets into new tokens.
  1138.      * It also corrects some usage of the static and class keywords. It also
  1139.      * assigns tokens to function return types.
  1140.      *
  1141.      * @return void 
  1142.      */
  1143.     protected function processAdditional()
  1144.     {
  1145.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1146.             echo "\t*** START ADDITIONAL PHP PROCESSING ***".PHP_EOL;
  1147.         }
  1148.  
  1149.         $numTokens count($this->tokens);
  1150.         for ($i ($numTokens - 1)$i >= 0; $i--{
  1151.             // Check for any unset scope conditions due to alternate IF/ENDIF syntax.
  1152.             if (isset($this->tokens[$i]['scope_opener']=== true
  1153.                 && isset($this->tokens[$i]['scope_condition']=== false
  1154.             {
  1155.                 $this->tokens[$i]['scope_condition'$this->tokens[$this->tokens[$i]['scope_opener']]['scope_condition'];
  1156.             }
  1157.  
  1158.             if ($this->tokens[$i]['code'=== T_FUNCTION{
  1159.                 // Context sensitive keywords support.
  1160.                 for ($x ($i + 1)$x $numTokens$x++{
  1161.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1162.                         // Non-whitespace content.
  1163.                         break;
  1164.                     }
  1165.                 }
  1166.  
  1167.                 if ($x === $numTokens{
  1168.                     // We got to the end without finding any more
  1169.                     // non-whitespace content.
  1170.                     continue;
  1171.                 }
  1172.  
  1173.                 if (in_array($this->tokens[$x]['code']array(T_STRINGT_OPEN_PARENTHESIST_BITWISE_AND)true=== false{
  1174.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1175.                         $line $this->tokens[$x]['line'];
  1176.                         $type $this->tokens[$x]['type'];
  1177.                         echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
  1178.                     }
  1179.  
  1180.                     $this->tokens[$x]['code'= T_STRING;
  1181.                     $this->tokens[$x]['type''T_STRING';
  1182.                 }
  1183.  
  1184.                 /*
  1185.                     Detect functions that are actually closures and
  1186.                     assign them a different token.
  1187.                 */
  1188.  
  1189.                 if (isset($this->tokens[$i]['scope_opener']=== true{
  1190.                     for ($x ($i + 1)$x $numTokens$x++{
  1191.                         if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false
  1192.                             && $this->tokens[$x]['code'!== T_BITWISE_AND
  1193.                         {
  1194.                             break;
  1195.                         }
  1196.                     }
  1197.  
  1198.                     if ($this->tokens[$x]['code'=== T_OPEN_PARENTHESIS{
  1199.                         $this->tokens[$i]['code'T_CLOSURE;
  1200.                         $this->tokens[$i]['type''T_CLOSURE';
  1201.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1202.                             $line $this->tokens[$i]['line'];
  1203.                             echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
  1204.                         }
  1205.  
  1206.                         for ($x ($this->tokens[$i]['scope_opener'+ 1)$x $this->tokens[$i]['scope_closer']$x++{
  1207.                             if (isset($this->tokens[$x]['conditions'][$i]=== false{
  1208.                                 continue;
  1209.                             }
  1210.  
  1211.                             $this->tokens[$x]['conditions'][$iT_CLOSURE;
  1212.                             if (PHP_CODESNIFFER_VERBOSITY > 1{
  1213.                                 $type $this->tokens[$x]['type'];
  1214.                                 echo "\t\t* cleaned $x ($type) *".PHP_EOL;
  1215.                             }
  1216.                         }
  1217.                     }
  1218.  
  1219.                     $tokenAfterReturnTypeHint $this->tokens[$i]['scope_opener'];
  1220.                 else if (isset($this->tokens[$i]['parenthesis_closer']=== true{
  1221.                     $tokenAfterReturnTypeHint = null;
  1222.                     for ($x ($this->tokens[$i]['parenthesis_closer'+ 1)$x $numTokens$x++{
  1223.                         if ($this->tokens[$x]['code'=== T_SEMICOLON{
  1224.                             $tokenAfterReturnTypeHint $x;
  1225.                             break;
  1226.                         }
  1227.                     }
  1228.  
  1229.                     if ($tokenAfterReturnTypeHint === null{
  1230.                         // Probably a syntax error.
  1231.                         continue;
  1232.                     }
  1233.                 else {
  1234.                     // Probably a syntax error.
  1235.                     continue;
  1236.                 }//end if
  1237.  
  1238.                 /*
  1239.                     Detect function return values and assign them
  1240.                     a special token, because PHP doesn't.
  1241.                 */
  1242.  
  1243.                 for ($x ($tokenAfterReturnTypeHint - 1)$x $i$x--{
  1244.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1245.                         if (in_array($this->tokens[$x]['code']array(T_STRINGT_ARRAYT_CALLABLET_SELFT_PARENT)true=== true{
  1246.                             if (PHP_CODESNIFFER_VERBOSITY > 1{
  1247.                                 $line $this->tokens[$x]['line'];
  1248.                                 $type $this->tokens[$x]['type'];
  1249.                                 echo "\t* token $x on line $line changed from $type to T_RETURN_TYPE".PHP_EOL;
  1250.                             }
  1251.  
  1252.                             $this->tokens[$x]['code'T_RETURN_TYPE;
  1253.                             $this->tokens[$x]['type''T_RETURN_TYPE';
  1254.                         }
  1255.  
  1256.                         break;
  1257.                     }
  1258.                 }
  1259.  
  1260.                 continue;
  1261.             else if ($this->tokens[$i]['code'=== T_CLASS && isset($this->tokens[$i]['scope_opener']=== true{
  1262.                 /*
  1263.                     Detect anonymous classes and assign them a different token.
  1264.                 */
  1265.  
  1266.                 for ($x ($i + 1)$x $numTokens$x++{
  1267.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1268.                         break;
  1269.                     }
  1270.                 }
  1271.  
  1272.                 if ($this->tokens[$x]['code'=== T_OPEN_PARENTHESIS
  1273.                     || $this->tokens[$x]['code'=== T_OPEN_CURLY_BRACKET
  1274.                     || $this->tokens[$x]['code'=== T_EXTENDS
  1275.                     || $this->tokens[$x]['code'=== T_IMPLEMENTS
  1276.                 {
  1277.                     $this->tokens[$i]['code'T_ANON_CLASS;
  1278.                     $this->tokens[$i]['type''T_ANON_CLASS';
  1279.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1280.                         $line $this->tokens[$i]['line'];
  1281.                         echo "\t* token $i on line $line changed from T_CLASS to T_ANON_CLASS".PHP_EOL;
  1282.                     }
  1283.  
  1284.                     for ($x ($this->tokens[$i]['scope_opener'+ 1)$x $this->tokens[$i]['scope_closer']$x++{
  1285.                         if (isset($this->tokens[$x]['conditions'][$i]=== false{
  1286.                             continue;
  1287.                         }
  1288.  
  1289.                         $this->tokens[$x]['conditions'][$iT_ANON_CLASS;
  1290.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1291.                             $type $this->tokens[$x]['type'];
  1292.                             echo "\t\t* cleaned $x ($type) *".PHP_EOL;
  1293.                         }
  1294.                     }
  1295.                 }
  1296.  
  1297.                 continue;
  1298.             else if ($this->tokens[$i]['code'=== T_OPEN_SQUARE_BRACKET{
  1299.                 // Unless there is a variable or a bracket before this token,
  1300.                 // it is the start of an array being defined using the short syntax.
  1301.                 for ($x ($i - 1)$x > 0; $x--{
  1302.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1303.                         break;
  1304.                     }
  1305.                 }
  1306.  
  1307.                 $allowed = array(
  1308.                             T_CLOSE_CURLY_BRACKET  => T_CLOSE_CURLY_BRACKET,
  1309.                             T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET,
  1310.                             T_CLOSE_PARENTHESIS    => T_CLOSE_PARENTHESIS,
  1311.                             T_VARIABLE             => T_VARIABLE,
  1312.                             T_STRING               => T_STRING,
  1313.                            );
  1314.  
  1315.                 if (isset($allowed[$this->tokens[$x]['code']]=== false
  1316.                     && isset($this->tokens[$i]['bracket_closer']=== true
  1317.                 {
  1318.                     $this->tokens[$i]['code'T_OPEN_SHORT_ARRAY;
  1319.                     $this->tokens[$i]['type''T_OPEN_SHORT_ARRAY';
  1320.  
  1321.                     $closer $this->tokens[$i]['bracket_closer'];
  1322.                     $this->tokens[$closer]['code'T_CLOSE_SHORT_ARRAY;
  1323.                     $this->tokens[$closer]['type''T_CLOSE_SHORT_ARRAY';
  1324.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1325.                         $line $this->tokens[$i]['line'];
  1326.                         echo "\t* token $i on line $line changed from T_OPEN_SQUARE_BRACKET to T_OPEN_SHORT_ARRAY".PHP_EOL;
  1327.                         $line $this->tokens[$closer]['line'];
  1328.                         echo "\t* token $closer on line $line changed from T_CLOSE_SQUARE_BRACKET to T_CLOSE_SHORT_ARRAY".PHP_EOL;
  1329.                     }
  1330.                 }
  1331.  
  1332.                 continue;
  1333.             else if ($this->tokens[$i]['code'=== T_STATIC{
  1334.                 for ($x ($i - 1)$x > 0; $x--{
  1335.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1336.                         break;
  1337.                     }
  1338.                 }
  1339.  
  1340.                 if ($this->tokens[$x]['code'=== T_INSTANCEOF{
  1341.                     $this->tokens[$i]['code'= T_STRING;
  1342.                     $this->tokens[$i]['type''T_STRING';
  1343.  
  1344.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1345.                         $line $this->tokens[$i]['line'];
  1346.                         echo "\t* token $i on line $line changed from T_STATIC to T_STRING".PHP_EOL;
  1347.                     }
  1348.                 }
  1349.  
  1350.                 continue;
  1351.             else if ($this->tokens[$i]['code'=== T_ECHO && $this->tokens[$i]['content'=== '<?='{
  1352.                 // HHVM tokenizes <?= as T_ECHO but it should be T_OPEN_TAG_WITH_ECHO.
  1353.                 $this->tokens[$i]['code'= T_OPEN_TAG_WITH_ECHO;
  1354.                 $this->tokens[$i]['type''T_OPEN_TAG_WITH_ECHO';
  1355.  
  1356.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  1357.                     $line $this->tokens[$i]['line'];
  1358.                     echo "\t* token $i on line $line changed from T_ECHO to T_OPEN_TAG_WITH_ECHO".PHP_EOL;
  1359.                 }
  1360.             else if ($this->tokens[$i]['code'=== T_TRUE
  1361.                 || $this->tokens[$i]['code'=== T_FALSE
  1362.                 || $this->tokens[$i]['code'=== T_NULL
  1363.             {
  1364.                 for ($x ($i + 1)$i $numTokens$x++{
  1365.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1366.                         // Non-whitespace content.
  1367.                         break;
  1368.                     }
  1369.                 }
  1370.  
  1371.                 $context = array(
  1372.                             T_OBJECT_OPERATOR      => true,
  1373.                             T_NS_SEPARATOR         => true,
  1374.                             T_PAAMAYIM_NEKUDOTAYIM => true,
  1375.                            );
  1376.                 if (isset($context[$this->tokens[$x]['code']]=== true{
  1377.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1378.                         $line $this->tokens[$i]['line'];
  1379.                         $type $this->tokens[$i]['type'];
  1380.                         echo "\t* token $i on line $line changed from $type to T_STRING".PHP_EOL;
  1381.                     }
  1382.  
  1383.                     $this->tokens[$i]['code'= T_STRING;
  1384.                     $this->tokens[$i]['type''T_STRING';
  1385.                 }
  1386.             else if ($this->tokens[$i]['code'=== T_CONST{
  1387.                 // Context sensitive keywords support.
  1388.                 for ($x ($i + 1)$i $numTokens$x++{
  1389.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1390.                         // Non-whitespace content.
  1391.                         break;
  1392.                     }
  1393.                 }
  1394.  
  1395.                 if ($this->tokens[$x]['code'!== T_STRING{
  1396.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1397.                         $line $this->tokens[$x]['line'];
  1398.                         $type $this->tokens[$x]['type'];
  1399.                         echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
  1400.                     }
  1401.  
  1402.                     $this->tokens[$x]['code'= T_STRING;
  1403.                     $this->tokens[$x]['type''T_STRING';
  1404.                 }
  1405.             }//end if
  1406.  
  1407.             if (($this->tokens[$i]['code'!== T_CASE
  1408.                 && $this->tokens[$i]['code'!== T_DEFAULT)
  1409.                 || isset($this->tokens[$i]['scope_opener']=== false
  1410.             {
  1411.                 // Only interested in CASE and DEFAULT statements from here on in.
  1412.                 continue;
  1413.             }
  1414.  
  1415.             $scopeOpener $this->tokens[$i]['scope_opener'];
  1416.             $scopeCloser $this->tokens[$i]['scope_closer'];
  1417.  
  1418.             // If the first char after the opener is a curly brace
  1419.             // and that brace has been ignored, it is actually
  1420.             // opening this case statement and the opener and closer are
  1421.             // probably set incorrectly.
  1422.             for ($x ($scopeOpener + 1)$x $numTokens$x++{
  1423.                 if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1424.                     // Non-whitespace content.
  1425.                     break;
  1426.                 }
  1427.             }
  1428.  
  1429.             if ($this->tokens[$x]['code'=== T_CASE || $this->tokens[$x]['code'=== T_DEFAULT{
  1430.                 // Special case for multiple CASE statements that share the same
  1431.                 // closer. Because we are going backwards through the file, this next
  1432.                 // CASE statement is already fixed, so just use its closer and don't
  1433.                 // worry about fixing anything.
  1434.                 $newCloser $this->tokens[$x]['scope_closer'];
  1435.                 $this->tokens[$i]['scope_closer'$newCloser;
  1436.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  1437.                     $oldType $this->tokens[$scopeCloser]['type'];
  1438.                     $newType $this->tokens[$newCloser]['type'];
  1439.                     $line    $this->tokens[$i]['line'];
  1440.                     echo "\t* token $i (T_CASE) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
  1441.                 }
  1442.  
  1443.                 continue;
  1444.             }
  1445.  
  1446.             if ($this->tokens[$x]['code'!== T_OPEN_CURLY_BRACKET
  1447.                 || isset($this->tokens[$x]['scope_condition']=== true
  1448.             {
  1449.                 // Not a CASE/DEFAULT with a curly brace opener.
  1450.                 continue;
  1451.             }
  1452.  
  1453.             // The closer for this CASE/DEFAULT should be the closing curly brace and
  1454.             // not whatever it already is. The opener needs to be the opening curly
  1455.             // brace so everything matches up.
  1456.             $newCloser $this->tokens[$x]['bracket_closer'];
  1457.             foreach (array($i$x$newCloseras $index{
  1458.                 $this->tokens[$index]['scope_condition'$i;
  1459.                 $this->tokens[$index]['scope_opener']    $x;
  1460.                 $this->tokens[$index]['scope_closer']    $newCloser;
  1461.             }
  1462.  
  1463.             unset($this->tokens[$scopeOpener]['scope_condition']);
  1464.             unset($this->tokens[$scopeOpener]['scope_opener']);
  1465.             unset($this->tokens[$scopeOpener]['scope_closer']);
  1466.             unset($this->tokens[$scopeCloser]['scope_condition']);
  1467.             unset($this->tokens[$scopeCloser]['scope_opener']);
  1468.             unset($this->tokens[$scopeCloser]['scope_closer']);
  1469.             unset($this->tokens[$x]['bracket_opener']);
  1470.             unset($this->tokens[$x]['bracket_closer']);
  1471.             unset($this->tokens[$newCloser]['bracket_opener']);
  1472.             unset($this->tokens[$newCloser]['bracket_closer']);
  1473.             $this->tokens[$scopeCloser]['conditions'][$i;
  1474.  
  1475.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  1476.                 $line      $this->tokens[$i]['line'];
  1477.                 $tokenType $this->tokens[$i]['type'];
  1478.  
  1479.                 $oldType $this->tokens[$scopeOpener]['type'];
  1480.                 $newType $this->tokens[$x]['type'];
  1481.                 echo "\t* token $i ($tokenType) on line $line opener changed from $scopeOpener ($oldType) to $x ($newType)".PHP_EOL;
  1482.  
  1483.                 $oldType $this->tokens[$scopeCloser]['type'];
  1484.                 $newType $this->tokens[$newCloser]['type'];
  1485.                 echo "\t* token $i ($tokenType) on line $line closer changed from $scopeCloser ($oldType) to $newCloser ($newType)".PHP_EOL;
  1486.             }
  1487.  
  1488.             // Now fix up all the tokens that think they are
  1489.             // inside the CASE/DEFAULT statement when they are really outside.
  1490.             for ($x $newCloser$x $scopeCloser$x++{
  1491.                 foreach ($this->tokens[$x]['conditions'as $num => $oldCond{
  1492.                     if ($oldCond === $this->tokens[$i]['code']{
  1493.                         $oldConditions $this->tokens[$x]['conditions'];
  1494.                         unset($this->tokens[$x]['conditions'][$num]);
  1495.  
  1496.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1497.                             $type     $this->tokens[$x]['type'];
  1498.                             $oldConds '';
  1499.                             foreach ($oldConditions as $condition{
  1500.                                 $oldConds .= token_name($condition).',';
  1501.                             }
  1502.  
  1503.                             $oldConds rtrim($oldConds',');
  1504.  
  1505.                             $newConds '';
  1506.                             foreach ($this->tokens[$x]['conditions'as $condition{
  1507.                                 $newConds .= token_name($condition).',';
  1508.                             }
  1509.  
  1510.                             $newConds rtrim($newConds',');
  1511.  
  1512.                             echo "\t\t* cleaned $x ($type) *".PHP_EOL;
  1513.                             echo "\t\t\t=> conditions changed from $oldConds to $newConds".PHP_EOL;
  1514.                         }
  1515.  
  1516.                         break;
  1517.                     }//end if
  1518.                 }//end foreach
  1519.             }//end for
  1520.         }//end for
  1521.  
  1522.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1523.             echo "\t*** END ADDITIONAL PHP PROCESSING ***".PHP_EOL;
  1524.         }
  1525.  
  1526.     }//end processAdditional()
  1527.  
  1528.  
  1529.     /**
  1530.      * Takes a token produced from <code>token_get_all()</code> and produces a
  1531.      * more uniform token.
  1532.      *
  1533.      * @param string|array$token The token to convert.
  1534.      *
  1535.      * @return array The new token.
  1536.      */
  1537.     public static function standardiseToken($token)
  1538.     {
  1539.         if (isset($token[1]=== false{
  1540.             if (isset(self::$resolveTokenCache[$token[0]]=== true{
  1541.                 return self::$resolveTokenCache[$token[0]];
  1542.             }
  1543.         else {
  1544.             $cacheKey = null;
  1545.             if ($token[0=== T_STRING{
  1546.                 $cacheKey strtolower($token[1]);
  1547.             else if ($token[0!== T_CURLY_OPEN{
  1548.                 $cacheKey $token[0];
  1549.             }
  1550.  
  1551.             if ($cacheKey !== null && isset(self::$resolveTokenCache[$cacheKey]=== true{
  1552.                 $newToken            = self::$resolveTokenCache[$cacheKey];
  1553.                 $newToken['content'$token[1];
  1554.                 return $newToken;
  1555.             }
  1556.         }
  1557.  
  1558.         if (isset($token[1]=== false{
  1559.             return self::resolveSimpleToken($token[0]);
  1560.         }
  1561.  
  1562.         if ($token[0=== T_STRING{
  1563.             switch ($cacheKey{
  1564.             case 'false':
  1565.                 $newToken['type''T_FALSE';
  1566.                 break;
  1567.             case 'true':
  1568.                 $newToken['type''T_TRUE';
  1569.                 break;
  1570.             case 'null':
  1571.                 $newToken['type''T_NULL';
  1572.                 break;
  1573.             case 'self':
  1574.                 $newToken['type''T_SELF';
  1575.                 break;
  1576.             case 'parent':
  1577.                 $newToken['type''T_PARENT';
  1578.                 break;
  1579.             default:
  1580.                 $newToken['type''T_STRING';
  1581.                 break;
  1582.             }
  1583.  
  1584.             $newToken['code'constant($newToken['type']);
  1585.  
  1586.             self::$resolveTokenCache[$cacheKey$newToken;
  1587.         else if ($token[0=== T_CURLY_OPEN{
  1588.             $newToken = array(
  1589.                          'code' => T_OPEN_CURLY_BRACKET,
  1590.                          'type' => 'T_OPEN_CURLY_BRACKET',
  1591.                         );
  1592.         else {
  1593.             $newToken = array(
  1594.                          'code' => $token[0],
  1595.                          'type' => token_name($token[0]),
  1596.                         );
  1597.  
  1598.             self::$resolveTokenCache[$token[0]] $newToken;
  1599.         }//end if
  1600.  
  1601.         $newToken['content'$token[1];
  1602.         return $newToken;
  1603.  
  1604.     }//end standardiseToken()
  1605.  
  1606.  
  1607.     /**
  1608.      * Converts simple tokens into a format that conforms to complex tokens
  1609.      * produced by token_get_all().
  1610.      *
  1611.      * Simple tokens are tokens that are not in array form when produced from
  1612.      * token_get_all().
  1613.      *
  1614.      * @param string $token The simple token to convert.
  1615.      *
  1616.      * @return array The new token in array format.
  1617.      */
  1618.     public static function resolveSimpleToken($token)
  1619.     {
  1620.         $newToken = array();
  1621.  
  1622.         switch ($token{
  1623.         case '{':
  1624.             $newToken['type''T_OPEN_CURLY_BRACKET';
  1625.             break;
  1626.         case '}':
  1627.             $newToken['type''T_CLOSE_CURLY_BRACKET';
  1628.             break;
  1629.         case '[':
  1630.             $newToken['type''T_OPEN_SQUARE_BRACKET';
  1631.             break;
  1632.         case ']':
  1633.             $newToken['type''T_CLOSE_SQUARE_BRACKET';
  1634.             break;
  1635.         case '(':
  1636.             $newToken['type''T_OPEN_PARENTHESIS';
  1637.             break;
  1638.         case ')':
  1639.             $newToken['type''T_CLOSE_PARENTHESIS';
  1640.             break;
  1641.         case ':':
  1642.             $newToken['type''T_COLON';
  1643.             break;
  1644.         case '.':
  1645.             $newToken['type''T_STRING_CONCAT';
  1646.             break;
  1647.         case '?':
  1648.             $newToken['type''T_INLINE_THEN';
  1649.             break;
  1650.         case ';':
  1651.             $newToken['type''T_SEMICOLON';
  1652.             break;
  1653.         case '=':
  1654.             $newToken['type''T_EQUAL';
  1655.             break;
  1656.         case '*':
  1657.             $newToken['type''T_MULTIPLY';
  1658.             break;
  1659.         case '/':
  1660.             $newToken['type''T_DIVIDE';
  1661.             break;
  1662.         case '+':
  1663.             $newToken['type''T_PLUS';
  1664.             break;
  1665.         case '-':
  1666.             $newToken['type''T_MINUS';
  1667.             break;
  1668.         case '%':
  1669.             $newToken['type''T_MODULUS';
  1670.             break;
  1671.         case '^':
  1672.             $newToken['type''T_BITWISE_XOR';
  1673.             break;
  1674.         case '&':
  1675.             $newToken['type''T_BITWISE_AND';
  1676.             break;
  1677.         case '|':
  1678.             $newToken['type''T_BITWISE_OR';
  1679.             break;
  1680.         case '<':
  1681.             $newToken['type''T_LESS_THAN';
  1682.             break;
  1683.         case '>':
  1684.             $newToken['type''T_GREATER_THAN';
  1685.             break;
  1686.         case '!':
  1687.             $newToken['type''T_BOOLEAN_NOT';
  1688.             break;
  1689.         case ',':
  1690.             $newToken['type''T_COMMA';
  1691.             break;
  1692.         case '@':
  1693.             $newToken['type''T_ASPERAND';
  1694.             break;
  1695.         case '$':
  1696.             $newToken['type''T_DOLLAR';
  1697.             break;
  1698.         case '`':
  1699.             $newToken['type''T_BACKTICK';
  1700.             break;
  1701.         default:
  1702.             $newToken['type''T_NONE';
  1703.             break;
  1704.         }//end switch
  1705.  
  1706.         $newToken['code']    = constant($newToken['type']);
  1707.         $newToken['content'$token;
  1708.  
  1709.         self::$resolveTokenCache[$token$newToken;
  1710.         return $newToken;
  1711.  
  1712.     }//end resolveSimpleToken()
  1713.  
  1714.  
  1715. }//end class

Documentation generated on Mon, 11 Mar 2019 14:49:54 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.