Пример #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;
 }
Пример #2
0
 /**
 ----------------------------------------------------------------------+
 * Return the previous meaningfull token
 * @param	int	current position
 * @return	Int
 ----------------------------------------------------------------------+
 */
 protected function prev($pos)
 {
     $i = $pos;
     $o = $this->node->tokens;
     $c = $this->node->start;
     while (--$i > $c) {
         if (\phplinter\Tokenizer::meaningfull($o[$i][0])) {
             return $i;
         }
     }
     return false;
 }