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

Source for file JS.php

Documentation is available at JS.php

  1. <?php
  2. /**
  3.  * Tokenizes JS 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. use PHP_CodeSniffer\Exceptions\TokenizerException;
  14. use PHP_CodeSniffer\Config;
  15.  
  16. class JS extends Tokenizer
  17. {
  18.  
  19.  
  20.     /**
  21.      * A list of tokens that are allowed to open a scope.
  22.      *
  23.      * This array also contains information about what kind of token the scope
  24.      * opener uses to open and close the scope, if the token strictly requires
  25.      * an opener, if the token can share a scope closer, and who it can be shared
  26.      * with. An example of a token that shares a scope closer is a CASE scope.
  27.      *
  28.      * @var array 
  29.      */
  30.     public $scopeOpeners = array(
  31.                             T_IF       => array(
  32.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  33.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  34.                                            'strict' => false,
  35.                                            'shared' => false,
  36.                                            'with'   => array(),
  37.                                           ),
  38.                             T_TRY      => array(
  39.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  40.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  41.                                            'strict' => true,
  42.                                            'shared' => false,
  43.                                            'with'   => array(),
  44.                                           ),
  45.                             T_CATCH    => array(
  46.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  47.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  48.                                            'strict' => true,
  49.                                            'shared' => false,
  50.                                            'with'   => array(),
  51.                                           ),
  52.                             T_ELSE     => array(
  53.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  54.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  55.                                            'strict' => false,
  56.                                            'shared' => false,
  57.                                            'with'   => array(),
  58.                                           ),
  59.                             T_FOR      => array(
  60.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  61.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  62.                                            'strict' => false,
  63.                                            'shared' => false,
  64.                                            'with'   => array(),
  65.                                           ),
  66.                             T_FUNCTION => array(
  67.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  68.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  69.                                            'strict' => false,
  70.                                            'shared' => false,
  71.                                            'with'   => array(),
  72.                                           ),
  73.                             T_WHILE    => array(
  74.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  75.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  76.                                            'strict' => false,
  77.                                            'shared' => false,
  78.                                            'with'   => array(),
  79.                                           ),
  80.                             T_DO       => array(
  81.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  82.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  83.                                            'strict' => true,
  84.                                            'shared' => false,
  85.                                            'with'   => array(),
  86.                                           ),
  87.                             T_SWITCH   => array(
  88.                                            'start'  => array(T_OPEN_CURLY_BRACKET => T_OPEN_CURLY_BRACKET),
  89.                                            'end'    => array(T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET),
  90.                                            'strict' => true,
  91.                                            'shared' => false,
  92.                                            'with'   => array(),
  93.                                           ),
  94.                             T_CASE     => array(
  95.                                            'start'  => array(T_COLON => T_COLON),
  96.                                            'end'    => array(
  97.                                                         T_BREAK    => T_BREAK,
  98.                                                         T_RETURN   => T_RETURN,
  99.                                                         T_CONTINUE => T_CONTINUE,
  100.                                                         T_THROW    => T_THROW,
  101.                                                        ),
  102.                                            'strict' => true,
  103.                                            'shared' => true,
  104.                                            'with'   => array(
  105.                                                         T_DEFAULT => T_DEFAULT,
  106.                                                         T_CASE    => T_CASE,
  107.                                                         T_SWITCH  => T_SWITCH,
  108.                                                        ),
  109.                                           ),
  110.                             T_DEFAULT  => array(
  111.                                            'start'  => array(T_COLON => T_COLON),
  112.                                            'end'    => array(
  113.                                                         T_BREAK    => T_BREAK,
  114.                                                         T_RETURN   => T_RETURN,
  115.                                                         T_CONTINUE => T_CONTINUE,
  116.                                                         T_THROW    => T_THROW,
  117.                                                        ),
  118.                                            'strict' => true,
  119.                                            'shared' => true,
  120.                                            'with'   => array(
  121.                                                         T_CASE   => T_CASE,
  122.                                                         T_SWITCH => T_SWITCH,
  123.                                                        ),
  124.                                           ),
  125.                            );
  126.  
  127.     /**
  128.      * A list of tokens that end the scope.
  129.      *
  130.      * This array is just a unique collection of the end tokens
  131.      * from the _scopeOpeners array. The data is duplicated here to
  132.      * save time during parsing of the file.
  133.      *
  134.      * @var array 
  135.      */
  136.     public $endScopeTokens = array(
  137.                               T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
  138.                               T_BREAK               => T_BREAK,
  139.                              );
  140.  
  141.     /**
  142.      * A list of special JS tokens and their types.
  143.      *
  144.      * @var array 
  145.      */
  146.     protected $tokenValues = array(
  147.                               'function'  => 'T_FUNCTION',
  148.                               'prototype' => 'T_PROTOTYPE',
  149.                               'try'       => 'T_TRY',
  150.                               'catch'     => 'T_CATCH',
  151.                               'return'    => 'T_RETURN',
  152.                               'throw'     => 'T_THROW',
  153.                               'break'     => 'T_BREAK',
  154.                               'switch'    => 'T_SWITCH',
  155.                               'continue'  => 'T_CONTINUE',
  156.                               'if'        => 'T_IF',
  157.                               'else'      => 'T_ELSE',
  158.                               'do'        => 'T_DO',
  159.                               'while'     => 'T_WHILE',
  160.                               'for'       => 'T_FOR',
  161.                               'var'       => 'T_VAR',
  162.                               'case'      => 'T_CASE',
  163.                               'default'   => 'T_DEFAULT',
  164.                               'true'      => 'T_TRUE',
  165.                               'false'     => 'T_FALSE',
  166.                               'null'      => 'T_NULL',
  167.                               'this'      => 'T_THIS',
  168.                               'typeof'    => 'T_TYPEOF',
  169.                               '('         => 'T_OPEN_PARENTHESIS',
  170.                               ')'         => 'T_CLOSE_PARENTHESIS',
  171.                               '{'         => 'T_OPEN_CURLY_BRACKET',
  172.                               '}'         => 'T_CLOSE_CURLY_BRACKET',
  173.                               '['         => 'T_OPEN_SQUARE_BRACKET',
  174.                               ']'         => 'T_CLOSE_SQUARE_BRACKET',
  175.                               '?'         => 'T_INLINE_THEN',
  176.                               '.'         => 'T_OBJECT_OPERATOR',
  177.                               '+'         => 'T_PLUS',
  178.                               '-'         => 'T_MINUS',
  179.                               '*'         => 'T_MULTIPLY',
  180.                               '%'         => 'T_MODULUS',
  181.                               '/'         => 'T_DIVIDE',
  182.                               '^'         => 'T_LOGICAL_XOR',
  183.                               ','         => 'T_COMMA',
  184.                               ';'         => 'T_SEMICOLON',
  185.                               ':'         => 'T_COLON',
  186.                               '<'         => 'T_LESS_THAN',
  187.                               '>'         => 'T_GREATER_THAN',
  188.                               '<='        => 'T_IS_SMALLER_OR_EQUAL',
  189.                               '>='        => 'T_IS_GREATER_OR_EQUAL',
  190.                               '!'         => 'T_BOOLEAN_NOT',
  191.                               '||'        => 'T_BOOLEAN_OR',
  192.                               '&&'        => 'T_BOOLEAN_AND',
  193.                               '|'         => 'T_BITWISE_OR',
  194.                               '&'         => 'T_BITWISE_AND',
  195.                               '!='        => 'T_IS_NOT_EQUAL',
  196.                               '!=='       => 'T_IS_NOT_IDENTICAL',
  197.                               '='         => 'T_EQUAL',
  198.                               '=='        => 'T_IS_EQUAL',
  199.                               '==='       => 'T_IS_IDENTICAL',
  200.                               '-='        => 'T_MINUS_EQUAL',
  201.                               '+='        => 'T_PLUS_EQUAL',
  202.                               '*='        => 'T_MUL_EQUAL',
  203.                               '/='        => 'T_DIV_EQUAL',
  204.                               '%='        => 'T_MOD_EQUAL',
  205.                               '++'        => 'T_INC',
  206.                               '--'        => 'T_DEC',
  207.                               '//'        => 'T_COMMENT',
  208.                               '/*'        => 'T_COMMENT',
  209.                               '/**'       => 'T_DOC_COMMENT',
  210.                               '*/'        => 'T_COMMENT',
  211.                              );
  212.  
  213.     /**
  214.      * A list string delimiters.
  215.      *
  216.      * @var array 
  217.      */
  218.     protected $stringTokens = array(
  219.                                '\'' => '\'',
  220.                                '"'  => '"',
  221.                               );
  222.  
  223.     /**
  224.      * A list tokens that start and end comments.
  225.      *
  226.      * @var array 
  227.      */
  228.     protected $commentTokens = array(
  229.                                 '//'  => null,
  230.                                 '/*'  => '*/',
  231.                                 '/**' => '*/',
  232.                                );
  233.  
  234.  
  235.     /**
  236.      * Initialise the tokenizer.
  237.      *
  238.      * Pre-checks the content to see if it looks minified.
  239.      *
  240.      * @param string                  $content The content to tokenize,
  241.      * @param \PHP_CodeSniffer\Config $config  The config data for the run.
  242.      * @param string                  $eolChar The EOL char used in the content.
  243.      *
  244.      * @return void 
  245.      * @throws TokenizerException If the file appears to be minified.
  246.      */
  247.     public function __construct($contentConfig $config$eolChar='\n')
  248.     {
  249.         if ($this->isMinifiedContent($content$eolChar=== true{
  250.             throw new TokenizerException('File appears to be minified and cannot be processed');
  251.         }
  252.  
  253.         return parent::__construct($content$config$eolChar);
  254.  
  255.     }//end __construct()
  256.  
  257.  
  258.     /**
  259.      * Creates an array of tokens when given some JS code.
  260.      *
  261.      * @param string $string The string to tokenize.
  262.      *
  263.      * @return array 
  264.      */
  265.     public function tokenize($string)
  266.     {
  267.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  268.             echo "\t*** START JS TOKENIZING ***".PHP_EOL;
  269.         }
  270.  
  271.         $maxTokenLength = 0;
  272.         foreach ($this->tokenValues as $token => $values{
  273.             if (strlen($token$maxTokenLength{
  274.                 $maxTokenLength strlen($token);
  275.             }
  276.         }
  277.  
  278.         $tokens          = array();
  279.         $inString        '';
  280.         $stringChar      = null;
  281.         $inComment       '';
  282.         $buffer          '';
  283.         $preStringBuffer '';
  284.         $cleanBuffer     = false;
  285.  
  286.         $commentTokenizer = new Comment();
  287.  
  288.         $tokens[= array(
  289.                      'code'    => T_OPEN_TAG,
  290.                      'type'    => 'T_OPEN_TAG',
  291.                      'content' => '',
  292.                     );
  293.  
  294.         // Convert newlines to single characters for ease of
  295.         // processing. We will change them back later.
  296.         $string str_replace($this->eolChar"\n"$string);
  297.  
  298.         $chars    str_split($string);
  299.         $numChars count($chars);
  300.         for ($i = 0; $i $numChars$i++{
  301.             $char $chars[$i];
  302.  
  303.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  304.                 $content       = Util\Common::prepareForOutput($char);
  305.                 $bufferContent = Util\Common::prepareForOutput($buffer);
  306.  
  307.                 if ($inString !== ''{
  308.                     echo "\t";
  309.                 }
  310.  
  311.                 if ($inComment !== ''{
  312.                     echo "\t";
  313.                 }
  314.  
  315.                 echo "\tProcess char $i => $content (buffer: $bufferContent)".PHP_EOL;
  316.             }//end if
  317.  
  318.             if ($inString === '' && $inComment === '' && $buffer !== ''{
  319.                 // If the buffer only has whitespace and we are about to
  320.                 // add a character, store the whitespace first.
  321.                 if (trim($char!== '' && trim($buffer=== ''{
  322.                     $tokens[= array(
  323.                                  'code'    => T_WHITESPACE,
  324.                                  'type'    => 'T_WHITESPACE',
  325.                                  'content' => str_replace("\n"$this->eolChar$buffer),
  326.                                 );
  327.  
  328.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  329.                         $content = Util\Common::prepareForOutput($buffer);
  330.                         echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL;
  331.                     }
  332.  
  333.                     $buffer '';
  334.                 }
  335.  
  336.                 // If the buffer is not whitespace and we are about to
  337.                 // add a whitespace character, store the content first.
  338.                 if ($inString === ''
  339.                     && $inComment === ''
  340.                     && trim($char=== ''
  341.                     && trim($buffer!== ''
  342.                 {
  343.                     $tokens[= array(
  344.                                  'code'    => T_STRING,
  345.                                  'type'    => 'T_STRING',
  346.                                  'content' => str_replace("\n"$this->eolChar$buffer),
  347.                                 );
  348.  
  349.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  350.                         $content = Util\Common::prepareForOutput($buffer);
  351.                         echo "\t=> Added token T_STRING ($content)".PHP_EOL;
  352.                     }
  353.  
  354.                     $buffer '';
  355.                 }
  356.             }//end if
  357.  
  358.             // Process strings.
  359.             if ($inComment === '' && isset($this->stringTokens[$char]=== true{
  360.                 if ($inString === $char{
  361.                     // This could be the end of the string, but make sure it
  362.                     // is not escaped first.
  363.                     $escapes = 0;
  364.                     for ($x ($i - 1)$x >= 0; $x--{
  365.                         if ($chars[$x!== '\\'{
  366.                             break;
  367.                         }
  368.  
  369.                         $escapes++;
  370.                     }
  371.  
  372.                     if ($escapes === 0 || ($escapes % 2=== 0{
  373.                         // There is an even number escape chars,
  374.                         // so this is not escaped, it is the end of the string.
  375.                         $tokens[= array(
  376.                                      'code'    => T_CONSTANT_ENCAPSED_STRING,
  377.                                      'type'    => 'T_CONSTANT_ENCAPSED_STRING',
  378.                                      'content' => str_replace("\n"$this->eolChar$buffer).$char,
  379.                                     );
  380.  
  381.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  382.                             echo "\t\t* found end of string *".PHP_EOL;
  383.                             $content = Util\Common::prepareForOutput($buffer.$char);
  384.                             echo "\t=> Added token T_CONSTANT_ENCAPSED_STRING ($content)".PHP_EOL;
  385.                         }
  386.  
  387.                         $buffer          '';
  388.                         $preStringBuffer '';
  389.                         $inString        '';
  390.                         $stringChar      = null;
  391.                         continue;
  392.                     }//end if
  393.                 else if ($inString === ''{
  394.                     $inString        $char;
  395.                     $stringChar      $i;
  396.                     $preStringBuffer $buffer;
  397.  
  398.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  399.                         echo "\t\t* looking for string closer *".PHP_EOL;
  400.                     }
  401.                 }//end if
  402.             }//end if
  403.  
  404.             if ($inString !== '' && $char === "\n"{
  405.                 // Unless this newline character is escaped, the string did not
  406.                 // end before the end of the line, which means it probably
  407.                 // wasn't a string at all (maybe a regex).
  408.                 if ($chars[($i - 1)!== '\\'{
  409.                     $i      $stringChar;
  410.                     $buffer $preStringBuffer;
  411.                     $preStringBuffer '';
  412.                     $inString        '';
  413.                     $stringChar      = null;
  414.                     $char            $chars[$i];
  415.  
  416.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  417.                         echo "\t\t* found newline before end of string, bailing *".PHP_EOL;
  418.                     }
  419.                 }
  420.             }
  421.  
  422.             $buffer .= $char;
  423.  
  424.             // We don't look for special tokens inside strings,
  425.             // so if we are in a string, we can continue here now
  426.             // that the current char is in the buffer.
  427.             if ($inString !== ''{
  428.                 continue;
  429.             }
  430.  
  431.             // Special case for T_DIVIDE which can actually be
  432.             // the start of a regular expression.
  433.             if ($buffer === $char && $char === '/' && $chars[($i + 1)!== '*'{
  434.                 $regex $this->getRegexToken(
  435.                     $i,
  436.                     $string,
  437.                     $chars,
  438.                     $tokens,
  439.                     $this->eolChar
  440.                 );
  441.  
  442.                 if ($regex !== null{
  443.                     $tokens[= array(
  444.                                  'code'    => T_REGULAR_EXPRESSION,
  445.                                  'type'    => 'T_REGULAR_EXPRESSION',
  446.                                  'content' => $regex['content'],
  447.                                 );
  448.  
  449.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  450.                         $content = Util\Common::prepareForOutput($regex['content']);
  451.                         echo "\t=> Added token T_REGULAR_EXPRESSION ($content)".PHP_EOL;
  452.                     }
  453.  
  454.                     $i           $regex['end'];
  455.                     $buffer      '';
  456.                     $cleanBuffer = false;
  457.                     continue;
  458.                 }//end if
  459.             }//end if
  460.  
  461.             // Check for known tokens, but ignore tokens found that are not at
  462.             // the end of a string, like FOR and this.FORmat.
  463.             if (isset($this->tokenValues[strtolower($buffer)]=== true
  464.                 && (preg_match('|[a-zA-z0-9_]|'$char=== 0
  465.                 || isset($chars[($i + 1)]=== false
  466.                 || preg_match('|[a-zA-z0-9_]|'$chars[($i + 1)]=== 0)
  467.             {
  468.                 $matchedToken    = false;
  469.                 $lookAheadLength ($maxTokenLength strlen($buffer));
  470.  
  471.                 if ($lookAheadLength > 0{
  472.                     // The buffer contains a token type, but we need
  473.                     // to look ahead at the next chars to see if this is
  474.                     // actually part of a larger token. For example,
  475.                     // FOR and FOREACH.
  476.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  477.                         echo "\t\t* buffer possibly contains token, looking ahead $lookAheadLength chars *".PHP_EOL;
  478.                     }
  479.  
  480.                     $charBuffer $buffer;
  481.                     for ($x = 1; $x <= $lookAheadLength$x++{
  482.                         if (isset($chars[($i $x)]=== false{
  483.                             break;
  484.                         }
  485.  
  486.                         $charBuffer .= $chars[($i $x)];
  487.  
  488.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  489.                             $content = Util\Common::prepareForOutput($charBuffer);
  490.                             echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL;
  491.                         }
  492.  
  493.                         if (isset($this->tokenValues[strtolower($charBuffer)]=== true{
  494.                             // We've found something larger that matches
  495.                             // so we can ignore this char. Except for 1 very specific
  496.                             // case where a comment like /**/ needs to tokenize as
  497.                             // T_COMMENT and not T_DOC_COMMENT.
  498.                             $oldType $this->tokenValues[strtolower($buffer)];
  499.                             $newType $this->tokenValues[strtolower($charBuffer)];
  500.                             if ($oldType === 'T_COMMENT'
  501.                                 && $newType === 'T_DOC_COMMENT'
  502.                                 && $chars[($i $x + 1)=== '/'
  503.                             {
  504.                                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  505.                                     echo "\t\t* look ahead ignored T_DOC_COMMENT, continuing *".PHP_EOL;
  506.                                 }
  507.                             else {
  508.                                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  509.                                     echo "\t\t* look ahead found more specific token ($newType), ignoring $i *".PHP_EOL;
  510.                                 }
  511.  
  512.                                 $matchedToken = true;
  513.                                 break;
  514.                             }
  515.                         }//end if
  516.                     }//end for
  517.                 }//end if
  518.  
  519.                 if ($matchedToken === false{
  520.                     if (PHP_CODESNIFFER_VERBOSITY > 1 && $lookAheadLength > 0{
  521.                         echo "\t\t* look ahead found nothing *".PHP_EOL;
  522.                     }
  523.  
  524.                     $value $this->tokenValues[strtolower($buffer)];
  525.  
  526.                     if ($value === 'T_FUNCTION' && $buffer !== 'function'{
  527.                         // The function keyword needs to be all lowercase or else
  528.                         // it is just a function called "Function".
  529.                         $value 'T_STRING';
  530.                     }
  531.  
  532.                     $tokens[= array(
  533.                                  'code'    => constant($value),
  534.                                  'type'    => $value,
  535.                                  'content' => $buffer,
  536.                                 );
  537.  
  538.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  539.                         $content = Util\Common::prepareForOutput($buffer);
  540.                         echo "\t=> Added token $value ($content)".PHP_EOL;
  541.                     }
  542.  
  543.                     $cleanBuffer = true;
  544.                 }//end if
  545.             else if (isset($this->tokenValues[strtolower($char)]=== true{
  546.                 // No matter what token we end up using, we don't
  547.                 // need the content in the buffer any more because we have
  548.                 // found a valid token.
  549.                 $newContent substr(str_replace("\n"$this->eolChar$buffer)0-1);
  550.                 if ($newContent !== ''{
  551.                     $tokens[= array(
  552.                                  'code'    => T_STRING,
  553.                                  'type'    => 'T_STRING',
  554.                                  'content' => $newContent,
  555.                                 );
  556.  
  557.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  558.                         $content = Util\Common::prepareForOutput(substr($buffer0-1));
  559.                         echo "\t=> Added token T_STRING ($content)".PHP_EOL;
  560.                     }
  561.                 }
  562.  
  563.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  564.                     echo "\t\t* char is token, looking ahead ".($maxTokenLength - 1).' chars *'.PHP_EOL;
  565.                 }
  566.  
  567.                 // The char is a token type, but we need to look ahead at the
  568.                 // next chars to see if this is actually part of a larger token.
  569.                 // For example, = and ===.
  570.                 $charBuffer   $char;
  571.                 $matchedToken = false;
  572.                 for ($x = 1; $x <= $maxTokenLength$x++{
  573.                     if (isset($chars[($i $x)]=== false{
  574.                         break;
  575.                     }
  576.  
  577.                     $charBuffer .= $chars[($i $x)];
  578.  
  579.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  580.                         $content = Util\Common::prepareForOutput($charBuffer);
  581.                         echo "\t\t=> Looking ahead $x chars => $content".PHP_EOL;
  582.                     }
  583.  
  584.                     if (isset($this->tokenValues[strtolower($charBuffer)]=== true{
  585.                         // We've found something larger that matches
  586.                         // so we can ignore this char.
  587.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  588.                             $type $this->tokenValues[strtolower($charBuffer)];
  589.                             echo "\t\t* look ahead found more specific token ($type), ignoring $i *".PHP_EOL;
  590.                         }
  591.  
  592.                         $matchedToken = true;
  593.                         break;
  594.                     }
  595.                 }//end for
  596.  
  597.                 if ($matchedToken === false{
  598.                     $value    $this->tokenValues[strtolower($char)];
  599.                     $tokens[= array(
  600.                                  'code'    => constant($value),
  601.                                  'type'    => $value,
  602.                                  'content' => $char,
  603.                                 );
  604.  
  605.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  606.                         echo "\t\t* look ahead found nothing *".PHP_EOL;
  607.                         $content = Util\Common::prepareForOutput($char);
  608.                         echo "\t=> Added token $value ($content)".PHP_EOL;
  609.                     }
  610.  
  611.                     $cleanBuffer = true;
  612.                 else {
  613.                     $buffer $char;
  614.                 }//end if
  615.             }//end if
  616.  
  617.             // Keep track of content inside comments.
  618.             if ($inComment === ''
  619.                 && array_key_exists($buffer$this->commentTokens=== true
  620.             {
  621.                 // This is not really a comment if the content
  622.                 // looks like \// (i.e., it is escaped).
  623.                 if (isset($chars[($i - 2)]=== true && $chars[($i - 2)=== '\\'{
  624.                     $lastToken   array_pop($tokens);
  625.                     $lastContent $lastToken['content'];
  626.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  627.                         $value   $this->tokenValues[strtolower($lastContent)];
  628.                         $content = Util\Common::prepareForOutput($lastContent);
  629.                         echo "\t=> Removed token $value ($content)".PHP_EOL;
  630.                     }
  631.  
  632.                     $lastChars    str_split($lastContent);
  633.                     $lastNumChars count($lastChars);
  634.                     for ($x = 0; $x $lastNumChars$x++{
  635.                         $lastChar $lastChars[$x];
  636.                         $value    $this->tokenValues[strtolower($lastChar)];
  637.                         $tokens[= array(
  638.                                      'code'    => constant($value),
  639.                                      'type'    => $value,
  640.                                      'content' => $lastChar,
  641.                                     );
  642.  
  643.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  644.                             $content = Util\Common::prepareForOutput($lastChar);
  645.                             echo "\t=> Added token $value ($content)".PHP_EOL;
  646.                         }
  647.                     }
  648.                 else {
  649.                     // We have started a comment.
  650.                     $inComment $buffer;
  651.  
  652.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  653.                         echo "\t\t* looking for end of comment *".PHP_EOL;
  654.                     }
  655.                 }//end if
  656.             else if ($inComment !== ''{
  657.                 if ($this->commentTokens[$inComment=== null{
  658.                     // Comment ends at the next newline.
  659.                     if (strpos($buffer"\n"!== false{
  660.                         $inComment '';
  661.                     }
  662.                 else {
  663.                     if ($this->commentTokens[$inComment=== $buffer{
  664.                         $inComment '';
  665.                     }
  666.                 }
  667.  
  668.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  669.                     if ($inComment === ''{
  670.                         echo "\t\t* found end of comment *".PHP_EOL;
  671.                     }
  672.                 }
  673.  
  674.                 if ($inComment === '' && $cleanBuffer === false{
  675.                     $tokens[= array(
  676.                                  'code'    => T_STRING,
  677.                                  'type'    => 'T_STRING',
  678.                                  'content' => str_replace("\n"$this->eolChar$buffer),
  679.                                 );
  680.  
  681.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  682.                         $content = Util\Common::prepareForOutput($buffer);
  683.                         echo "\t=> Added token T_STRING ($content)".PHP_EOL;
  684.                     }
  685.  
  686.                     $buffer '';
  687.                 }
  688.             }//end if
  689.  
  690.             if ($cleanBuffer === true{
  691.                 $buffer      '';
  692.                 $cleanBuffer = false;
  693.             }
  694.         }//end for
  695.  
  696.         if (empty($buffer=== false{
  697.             // Buffer contains whitespace from the end of the file.
  698.             $tokens[= array(
  699.                          'code'    => T_WHITESPACE,
  700.                          'type'    => 'T_WHITESPACE',
  701.                          'content' => str_replace("\n"$this->eolChar$buffer),
  702.                         );
  703.  
  704.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  705.                 $content = Util\Common::prepareForOutput($buffer);
  706.                 echo "\t=> Added token T_WHITESPACE ($content)".PHP_EOL;
  707.             }
  708.         }
  709.  
  710.         $tokens[= array(
  711.                      'code'    => T_CLOSE_TAG,
  712.                      'type'    => 'T_CLOSE_TAG',
  713.                      'content' => '',
  714.                     );
  715.  
  716.         /*
  717.             Now that we have done some basic tokenizing, we need to
  718.             modify the tokens to join some together and split some apart
  719.             so they match what the PHP tokenizer does.
  720.         */
  721.  
  722.         $finalTokens = array();
  723.         $newStackPtr = 0;
  724.         $numTokens   count($tokens);
  725.         for ($stackPtr = 0; $stackPtr $numTokens$stackPtr++{
  726.             $token $tokens[$stackPtr];
  727.  
  728.             /*
  729.                 Look for comments and join the tokens together.
  730.             */
  731.  
  732.             if ($token['code'=== T_COMMENT || $token['code'=== T_DOC_COMMENT{
  733.                 $newContent   '';
  734.                 $tokenContent $token['content'];
  735.                 $endContent   $this->commentTokens[$tokenContent];
  736.                 while ($tokenContent !== $endContent{
  737.                     if ($endContent === null
  738.                         && strpos($tokenContent$this->eolChar!== false
  739.                     {
  740.                         // A null end token means the comment ends at the end of
  741.                         // the line so we look for newlines and split the token.
  742.                         $tokens[$stackPtr]['content'substr(
  743.                             $tokenContent,
  744.                             (strpos($tokenContent$this->eolCharstrlen($this->eolChar))
  745.                         );
  746.  
  747.                         $tokenContent substr(
  748.                             $tokenContent,
  749.                             0,
  750.                             (strpos($tokenContent$this->eolCharstrlen($this->eolChar))
  751.                         );
  752.  
  753.                         // If the substr failed, skip the token as the content
  754.                         // will now be blank.
  755.                         if ($tokens[$stackPtr]['content'!== false
  756.                             && $tokens[$stackPtr]['content'!== ''
  757.                         {
  758.                             $stackPtr--;
  759.                         }
  760.  
  761.                         break;
  762.                     }//end if
  763.  
  764.                     $stackPtr++;
  765.                     $newContent .= $tokenContent;
  766.                     if (isset($tokens[$stackPtr]=== false{
  767.                         break;
  768.                     }
  769.  
  770.                     $tokenContent $tokens[$stackPtr]['content'];
  771.                 }//end while
  772.  
  773.                 if ($token['code'=== T_DOC_COMMENT{
  774.                     $commentTokens $commentTokenizer->tokenizeString($newContent.$tokenContent$this->eolChar$newStackPtr);
  775.                     foreach ($commentTokens as $commentToken{
  776.                         $finalTokens[$newStackPtr$commentToken;
  777.                         $newStackPtr++;
  778.                     }
  779.  
  780.                     continue;
  781.                 else {
  782.                     // Save the new content in the current token so
  783.                     // the code below can chop it up on newlines.
  784.                     $token['content'$newContent.$tokenContent;
  785.                 }
  786.             }//end if
  787.  
  788.             /*
  789.                 If this token has newlines in its content, split each line up
  790.                 and create a new token for each line. We do this so it's easier
  791.                 to ascertain where errors occur on a line.
  792.                 Note that $token[1] is the token's content.
  793.             */
  794.  
  795.             if (strpos($token['content']$this->eolChar!== false{
  796.                 $tokenLines explode($this->eolChar$token['content']);
  797.                 $numLines   count($tokenLines);
  798.  
  799.                 for ($i = 0; $i $numLines$i++{
  800.                     $newToken['content'$tokenLines[$i];
  801.                     if ($i === ($numLines - 1)) {
  802.                         if ($tokenLines[$i=== ''{
  803.                             break;
  804.                         }
  805.                     else {
  806.                         $newToken['content'.= $this->eolChar;
  807.                     }
  808.  
  809.                     $newToken['type']          $token['type'];
  810.                     $newToken['code']          $token['code'];
  811.                     $finalTokens[$newStackPtr$newToken;
  812.                     $newStackPtr++;
  813.                 }
  814.             else {
  815.                 $finalTokens[$newStackPtr$token;
  816.                 $newStackPtr++;
  817.             }//end if
  818.  
  819.             // Convert numbers, including decimals.
  820.             if ($token['code'=== T_STRING
  821.                 || $token['code'=== T_OBJECT_OPERATOR
  822.             {
  823.                 $newContent  '';
  824.                 $oldStackPtr $stackPtr;
  825.                 while (preg_match('|^[0-9\.]+$|'$tokens[$stackPtr]['content']!== 0{
  826.                     $newContent .= $tokens[$stackPtr]['content'];
  827.                     $stackPtr++;
  828.                 }
  829.  
  830.                 if ($newContent !== '' && $newContent !== '.'{
  831.                     $finalTokens[($newStackPtr - 1)]['content'$newContent;
  832.                     if (ctype_digit($newContent=== true{
  833.                         $finalTokens[($newStackPtr - 1)]['code'constant('T_LNUMBER');
  834.                         $finalTokens[($newStackPtr - 1)]['type''T_LNUMBER';
  835.                     else {
  836.                         $finalTokens[($newStackPtr - 1)]['code'constant('T_DNUMBER');
  837.                         $finalTokens[($newStackPtr - 1)]['type''T_DNUMBER';
  838.                     }
  839.  
  840.                     $stackPtr--;
  841.                     continue;
  842.                 else {
  843.                     $stackPtr $oldStackPtr;
  844.                 }
  845.             }//end if
  846.  
  847.             // Convert the token after an object operator into a string, in most cases.
  848.             if ($token['code'=== T_OBJECT_OPERATOR{
  849.                 for ($i ($stackPtr + 1)$i $numTokens$i++{
  850.                     if (isset(Util\Tokens::$emptyTokens[$tokens[$i]['code']]=== true{
  851.                         continue;
  852.                     }
  853.  
  854.                     if ($tokens[$i]['code'!== T_PROTOTYPE
  855.                         && $tokens[$i]['code'!== T_LNUMBER
  856.                         && $tokens[$i]['code'!== T_DNUMBER
  857.                     {
  858.                         $tokens[$i]['code'= T_STRING;
  859.                         $tokens[$i]['type''T_STRING';
  860.                     }
  861.  
  862.                     break;
  863.                 }
  864.             }
  865.         }//end for
  866.  
  867.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  868.             echo "\t*** END TOKENIZING ***".PHP_EOL;
  869.         }
  870.  
  871.         return $finalTokens;
  872.  
  873.     }//end tokenize()
  874.  
  875.  
  876.     /**
  877.      * Tokenizes a regular expression if one is found.
  878.      *
  879.      * If a regular expression is not found, NULL is returned.
  880.      *
  881.      * @param string $char   The index of the possible regex start character.
  882.      * @param string $string The complete content of the string being tokenized.
  883.      * @param string $chars  An array of characters being tokenized.
  884.      * @param string $tokens The current array of tokens found in the string.
  885.      *
  886.      * @return void 
  887.      */
  888.     public function getRegexToken($char$string$chars$tokens)
  889.     {
  890.         $beforeTokens = array(
  891.                          T_EQUAL               => true,
  892.                          T_IS_NOT_EQUAL        => true,
  893.                          T_IS_IDENTICAL        => true,
  894.                          T_IS_NOT_IDENTICAL    => true,
  895.                          T_OPEN_PARENTHESIS    => true,
  896.                          T_OPEN_SQUARE_BRACKET => true,
  897.                          T_RETURN              => true,
  898.                          T_BOOLEAN_OR          => true,
  899.                          T_BOOLEAN_AND         => true,
  900.                          T_BITWISE_OR          => true,
  901.                          T_BITWISE_AND         => true,
  902.                          T_COMMA               => true,
  903.                          T_COLON               => true,
  904.                          T_TYPEOF              => true,
  905.                          T_INLINE_THEN         => true,
  906.                          T_INLINE_ELSE         => true,
  907.                         );
  908.  
  909.         $afterTokens = array(
  910.                         ','            => true,
  911.                         ')'            => true,
  912.                         ']'            => true,
  913.                         ';'            => true,
  914.                         ' '            => true,
  915.                         '.'            => true,
  916.                         ':'            => true,
  917.                         $this->eolChar => true,
  918.                        );
  919.  
  920.         // Find the last non-whitespace token that was added
  921.         // to the tokens array.
  922.         $numTokens count($tokens);
  923.         for ($prev ($numTokens - 1)$prev >= 0; $prev--{
  924.             if (isset(Util\Tokens::$emptyTokens[$tokens[$prev]['code']]=== false{
  925.                 break;
  926.             }
  927.         }
  928.  
  929.         if (isset($beforeTokens[$tokens[$prev]['code']]=== false{
  930.             return null;
  931.         }
  932.  
  933.         // This is probably a regular expression, so look for the end of it.
  934.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  935.             echo "\t* token possibly starts a regular expression *".PHP_EOL;
  936.         }
  937.  
  938.         $numChars count($chars);
  939.         for ($next ($char + 1)$next $numChars$next++{
  940.             if ($chars[$next=== '/'{
  941.                 // Just make sure this is not escaped first.
  942.                 if ($chars[($next - 1)!== '\\'{
  943.                     // In the simple form: /.../ so we found the end.
  944.                     break;
  945.                 else if ($chars[($next - 2)=== '\\'{
  946.                     // In the form: /...\\/ so we found the end.
  947.                     break;
  948.                 }
  949.             else {
  950.                 $possibleEolChar substr($string$nextstrlen($this->eolChar));
  951.                 if ($possibleEolChar === $this->eolChar{
  952.                     // This is the last token on the line and regular
  953.                     // expressions need to be defined on a single line,
  954.                     // so this is not a regular expression.
  955.                     break;
  956.                 }
  957.             }
  958.         }
  959.  
  960.         if ($chars[$next!== '/'{
  961.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  962.                 echo "\t* could not find end of regular expression *".PHP_EOL;
  963.             }
  964.  
  965.             return null;
  966.         }
  967.  
  968.         while (preg_match('|[a-zA-Z]|'$chars[($next + 1)]!== 0{
  969.             // The token directly after the end of the regex can
  970.             // be modifiers like global and case insensitive
  971.             // (.e.g, /pattern/gi).
  972.             $next++;
  973.         }
  974.  
  975.         $regexEnd $next;
  976.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  977.             echo "\t* found end of regular expression at token $regexEnd *".PHP_EOL;
  978.         }
  979.  
  980.         for ($next ($next + 1)$next $numChars$next++{
  981.             if ($chars[$next!== ' '{
  982.                 break;
  983.             else {
  984.                 $possibleEolChar substr($string$nextstrlen($this->eolChar));
  985.                 if ($possibleEolChar === $this->eolChar{
  986.                     // This is the last token on the line.
  987.                     break;
  988.                 }
  989.             }
  990.         }
  991.  
  992.         if (isset($afterTokens[$chars[$next]]=== false{
  993.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  994.                 echo "\t* tokens after regular expression do not look correct *".PHP_EOL;
  995.             }
  996.  
  997.             return null;
  998.         }
  999.  
  1000.         // This is a regular expression, so join all the tokens together.
  1001.         $content '';
  1002.         for ($x $char$x <= $regexEnd$x++{
  1003.             $content .= $chars[$x];
  1004.         }
  1005.  
  1006.         $token = array(
  1007.                   'start'   => $char,
  1008.                   'end'     => $regexEnd,
  1009.                   'content' => $content,
  1010.                  );
  1011.  
  1012.         return $token;
  1013.  
  1014.     }//end getRegexToken()
  1015.  
  1016.  
  1017.     /**
  1018.      * Performs additional processing after main tokenizing.
  1019.      *
  1020.      * This additional processing looks for properties, closures, labels and objects.
  1021.      *
  1022.      * @return void 
  1023.      */
  1024.     public function processAdditional()
  1025.     {
  1026.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1027.             echo "\t*** START ADDITIONAL JS PROCESSING ***".PHP_EOL;
  1028.         }
  1029.  
  1030.         $numTokens  count($this->tokens);
  1031.         $classStack = array();
  1032.  
  1033.         for ($i = 0; $i $numTokens$i++{
  1034.             if (PHP_CODESNIFFER_VERBOSITY > 1{
  1035.                 $type    $this->tokens[$i]['type'];
  1036.                 $content = Util\Common::prepareForOutput($this->tokens[$i]['content']);
  1037.  
  1038.                 echo str_repeat("\t"count($classStack));
  1039.                 echo "\tProcess token $i$type => $content".PHP_EOL;
  1040.             }
  1041.  
  1042.             // Looking for functions that are actually closures.
  1043.             if ($this->tokens[$i]['code'=== T_FUNCTION && isset($this->tokens[$i]['scope_opener']=== true{
  1044.                 for ($x ($i + 1)$x $numTokens$x++{
  1045.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]=== false{
  1046.                         break;
  1047.                     }
  1048.                 }
  1049.  
  1050.                 if ($this->tokens[$x]['code'=== T_OPEN_PARENTHESIS{
  1051.                     $this->tokens[$i]['code'T_CLOSURE;
  1052.                     $this->tokens[$i]['type''T_CLOSURE';
  1053.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1054.                         $line $this->tokens[$i]['line'];
  1055.                         echo str_repeat("\t"count($classStack));
  1056.                         echo "\t* token $i on line $line changed from T_FUNCTION to T_CLOSURE".PHP_EOL;
  1057.                     }
  1058.  
  1059.                     for ($x ($this->tokens[$i]['scope_opener'+ 1)$x $this->tokens[$i]['scope_closer']$x++{
  1060.                         if (isset($this->tokens[$x]['conditions'][$i]=== false{
  1061.                             continue;
  1062.                         }
  1063.  
  1064.                         $this->tokens[$x]['conditions'][$iT_CLOSURE;
  1065.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1066.                             $type $this->tokens[$x]['type'];
  1067.                             echo str_repeat("\t"count($classStack));
  1068.                             echo "\t\t* cleaned $x ($type) *".PHP_EOL;
  1069.                         }
  1070.                     }
  1071.                 }//end if
  1072.  
  1073.                 continue;
  1074.             else if ($this->tokens[$i]['code'=== T_OPEN_CURLY_BRACKET
  1075.                 && isset($this->tokens[$i]['scope_condition']=== false
  1076.             {
  1077.                 $classStack[$i;
  1078.  
  1079.                 $closer $this->tokens[$i]['bracket_closer'];
  1080.                 $this->tokens[$i]['code']      T_OBJECT;
  1081.                 $this->tokens[$i]['type']      'T_OBJECT';
  1082.                 $this->tokens[$closer]['code'T_CLOSE_OBJECT;
  1083.                 $this->tokens[$closer]['type''T_CLOSE_OBJECT';
  1084.  
  1085.                 if (PHP_CODESNIFFER_VERBOSITY > 1{
  1086.                     echo str_repeat("\t"count($classStack));
  1087.                     echo "\t* token $i converted from T_OPEN_CURLY_BRACKET to T_OBJECT *".PHP_EOL;
  1088.                     echo str_repeat("\t"count($classStack));
  1089.                     echo "\t* token $closer converted from T_CLOSE_CURLY_BRACKET to T_CLOSE_OBJECT *".PHP_EOL;
  1090.                 }
  1091.  
  1092.                 for ($x ($i + 1)$x $closer$x++{
  1093.                     $this->tokens[$x]['conditions'][$iT_OBJECT;
  1094.                     ksort($this->tokens[$x]['conditions']SORT_NUMERIC);
  1095.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1096.                         $type $this->tokens[$x]['type'];
  1097.                         echo str_repeat("\t"count($classStack));
  1098.                         echo "\t\t* added T_OBJECT condition to $x ($type) *".PHP_EOL;
  1099.                     }
  1100.                 }
  1101.             else if ($this->tokens[$i]['code'=== T_CLOSE_OBJECT{
  1102.                 $opener array_pop($classStack);
  1103.             else if ($this->tokens[$i]['code'=== T_COLON{
  1104.                 // If it is a scope opener, it belongs to a
  1105.                 // DEFAULT or CASE statement.
  1106.                 if (isset($this->tokens[$i]['scope_condition']=== true{
  1107.                     continue;
  1108.                 }
  1109.  
  1110.                 // Make sure this is not part of an inline IF statement.
  1111.                 for ($x ($i - 1)$x >= 0; $x--{
  1112.                     if ($this->tokens[$x]['code'=== T_INLINE_THEN{
  1113.                         $this->tokens[$i]['code'T_INLINE_ELSE;
  1114.                         $this->tokens[$i]['type''T_INLINE_ELSE';
  1115.  
  1116.                         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1117.                             echo str_repeat("\t"count($classStack));
  1118.                             echo "\t* token $i converted from T_COLON to T_INLINE_THEN *".PHP_EOL;
  1119.                         }
  1120.  
  1121.                         continue(2);
  1122.                     else if ($this->tokens[$x]['line'$this->tokens[$i]['line']{
  1123.                         break;
  1124.                     }
  1125.                 }
  1126.  
  1127.                 // The string to the left of the colon is either a property or label.
  1128.                 for ($label ($i - 1)$label >= 0; $label--{
  1129.                     if (isset(Util\Tokens::$emptyTokens[$this->tokens[$label]['code']]=== false{
  1130.                         break;
  1131.                     }
  1132.                 }
  1133.  
  1134.                 if ($this->tokens[$label]['code'!== T_STRING
  1135.                     && $this->tokens[$label]['code'!== T_CONSTANT_ENCAPSED_STRING
  1136.                 {
  1137.                     continue;
  1138.                 }
  1139.  
  1140.                 if (empty($classStack=== false{
  1141.                     $this->tokens[$label]['code'T_PROPERTY;
  1142.                     $this->tokens[$label]['type''T_PROPERTY';
  1143.  
  1144.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1145.                         echo str_repeat("\t"count($classStack));
  1146.                         echo "\t* token $label converted from T_STRING to T_PROPERTY *".PHP_EOL;
  1147.                     }
  1148.                 else {
  1149.                     $this->tokens[$label]['code'T_LABEL;
  1150.                     $this->tokens[$label]['type''T_LABEL';
  1151.  
  1152.                     if (PHP_CODESNIFFER_VERBOSITY > 1{
  1153.                         echo str_repeat("\t"count($classStack));
  1154.                         echo "\t* token $label converted from T_STRING to T_LABEL *".PHP_EOL;
  1155.                     }
  1156.                 }//end if
  1157.             }//end if
  1158.         }//end for
  1159.  
  1160.         if (PHP_CODESNIFFER_VERBOSITY > 1{
  1161.             echo "\t*** END ADDITIONAL JS PROCESSING ***".PHP_EOL;
  1162.         }
  1163.  
  1164.     }//end processAdditional()
  1165.  
  1166.  
  1167. }//end class

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