token_name() public static method

----------------------------------------------------------------------+
public static token_name ( $token ) : String
$token int
return String ----------------------------------------------------------------------+
Example #1
0
 /**
 ----------------------------------------------------------------------+
 * @desc 	Harvest from node
 * @param	Mixed
 * @return   Array
 ----------------------------------------------------------------------+
 */
 protected function _extract($node)
 {
     if (!$node) {
         return null;
     }
     if (is_array($node)) {
         $out = array();
         foreach ($node as $_) {
             $out[] = $this->_extract($_);
         }
         return $out;
     }
     if ($node->type === T_FILE) {
         $this->namespace = null;
     }
     $out = array('name' => $node->name, 'type' => \phplinter\Tokenizer::token_name($node->type), 'comment' => $node->comments, 'static' => $node->static, 'abstract' => $node->abstract, 'visibility' => $node->visibility, 'namespace' => $this->namespace, 'extends' => $node->extends, 'implements' => $node->implements, 'arguments' => $node->arguments, 'constants' => $node->constants, 'start_line' => $node->start_line, 'end_line' => $node->end_line, 'score' => SCORE_FULL + $this->penaltys[$node->file], 'nodes' => $this->_extract($node->nodes), 'file' => $node->file);
     if ($node->namespace) {
         $this->namespace = $node->namespace;
         $out['namespace'] = $this->namespace;
     }
     return $out;
 }
Example #2
0
 /**
 ----------------------------------------------------------------------+
 * Tokens common to all scopes.
 * @param	int	current position
 ----------------------------------------------------------------------+
 */
 public function common_tokens($pos)
 {
     $token = $this->node->tokens[$pos];
     if ($this->final_return === 1 && $token[0] !== T_CLOSE_SCOPE && \phplinter\Tokenizer::meaningfull($token[0])) {
         $this->final_return = 2;
         $this->report('WAR_UNREACHABLE_CODE', null, $token[2]);
     }
     $t = $token[0];
     if ($this->config->match_rule('DEP_DEPRECATED_TOKEN', $t)) {
         $this->report('DEP_DEPRECATED_TOKEN', \phplinter\Tokenizer::token_name($t));
     }
     switch ($t) {
         case T_INLINE_HTML:
             $this->report('REF_HTML_MIXIN', null, $token[2]);
             break;
         case T_REQUIRE:
         case T_REQUIRE_ONCE:
         case T_INCLUDE:
         case T_INCLUDE_ONCE:
             $this->sec_includes($pos);
             break;
         case T_IS_EQUAL:
         case T_IS_NOT_EQUAL:
             $this->report('INF_COMPARE', null, $token[2]);
             break;
         case T_BACKTICK:
             $this->sec_backtick($pos);
             break;
         case T_STRING:
             $this->parse_string($pos);
             break;
         case T_RETURN:
         case T_EXIT:
             $prev = $this->node->tokens[$this->prev($pos)];
             if (!in_array($prev[0], array(T_LOGICAL_OR, T_BOOLEAN_OR)) && $this->scope === 0 && $this->final_return === false) {
                 $this->final_return = true;
             }
             break;
         case T_OPEN_SCOPE:
             $this->branches++;
             if ($token[1] === 'switch') {
                 if ($this->switch !== false) {
                     $this->report('REF_NESTED_SWITCH', null, $token[2]);
                 }
                 $this->switch = $this->scope;
             }
             $this->scope++;
             if ($this->config->match_rule('REF_DEEP_NESTING', $this->scope)) {
                 $this->report('REF_DEEP_NESTING', $this->scope, $token[2]);
             }
             break;
         case T_CLOSE_SCOPE:
             $this->scope--;
             if ($this->switch === $this->scope) {
                 $this->switch = false;
             }
             break;
         case T_SEMICOLON:
             if ($this->final_return === true) {
                 $this->final_return = 1;
             }
             break;
     }
 }