当前位置: 首页>>代码示例>>PHP>>正文


PHP Node::getType方法代码示例

本文整理汇总了PHP中PhpParser\Node::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getType方法的具体用法?PHP Node::getType怎么用?PHP Node::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpParser\Node的用法示例。


在下文中一共展示了Node::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pushState

 public function pushState($stateKey, Node $node)
 {
     if ($this->debug) {
         printf("Stacking %s %s %s %d\n", $stateKey, $node->getType(), $node->name, count($this->stateStack));
     }
     $state = $this->getState($stateKey);
     array_unshift($this->stateStack, ['node' => $node, 'state' => $state, 'key' => $state->getName(), 'nodeType' => $node->getType()]);
 }
开发者ID:trismegiste,项目名称:mondrian,代码行数:8,代码来源:VisitorGateway.php

示例2: enterNode

 /**
  * {@inheritdoc}
  */
 public function enterNode(Node $node)
 {
     if (isset($this->mapping[$node->getType()])) {
         // We have a mapping, so resolve the assign operation to
         // Separate assign and operation nodes
         $class = $this->mapping[$node->getType()];
         return new Node\Expr\Assign($node->var, new $class($node->var, $node->expr));
     }
 }
开发者ID:bwoebi,项目名称:recki-ct,代码行数:12,代码来源:AssignOpResolver.php

示例3: getListPart

 /**
  * @param Node $stmts
  * @return Node\Expr\List_
  * @throws \Exception
  */
 private function getListPart(Node $stmts)
 {
     if ($stmts->getType() === 'Expr_Assign' && $stmts->var->getType() === 'Expr_List') {
         return $stmts->var;
     } elseif ($stmts->getType() === 'Expr_List') {
         return $stmts;
     } else {
         throw new \Exception("Unknown statement: " . $stmts->getType());
     }
 }
开发者ID:angrybender,项目名称:phpPM,代码行数:15,代码来源:ParserList.php

示例4: getUnexpectedThing

 private function getUnexpectedThing(Node $node)
 {
     switch ($node->getType()) {
         case 'Scalar_String':
         case 'Scalar_LNumber':
         case 'Scalar_DNumber':
             return json_encode($node->value);
         case 'Expr_ConstFetch':
             return (string) $node->name;
         default:
             return $node->getType();
     }
 }
开发者ID:a53ali,项目名称:CakePhP,代码行数:13,代码来源:LegacyEmptyPass.php

示例5: enterNode

 public function enterNode(Node $node)
 {
     if ($node->getType() == 'Stmt_Use') {
         foreach ($node->uses as $use) {
             $this->uses[] = $use;
         }
     }
     // echo $node->getType() . "\n";
     if (isset($node->class) && $node->class) {
         if ($node->class->getType() != 'Name_FullyQualified') {
             $this->names[] = $node->class;
         }
     }
     if (isset($node->extends) && $node->extends) {
         if ($node->extends->getType() != 'Name_FullyQualified') {
             $this->names[] = $node->extends;
         }
     }
     if (isset($node->implements) && $node->implements) {
         foreach ($node->implements as $implements) {
             if ($implements->getType() != 'Name_FullyQualified') {
                 $this->names[] = $implements;
             }
         }
     }
     if (isset($node->params)) {
         foreach ($node->params as $param) {
             if ($param->type && !is_string($param->type)) {
                 if ($param->type->getType() != 'Name_FullyQualified') {
                     $this->names[] = $param->type;
                 }
             }
         }
     }
 }
开发者ID:knuthelland,项目名称:phpimports,代码行数:35,代码来源:ScopeAnalyzer.php

示例6: leaveNode

 public function leaveNode(Node $node)
 {
     $type = $node->getType();
     if ($type == "Expr_BinaryOp_Concat") {
         if ($node->right) {
             //转为symbol
             $right_symbol = SymbolUtils::getSymbolByNode($node->right);
             $right_symbol != null && array_push($this->items, $right_symbol);
         }
         if ($node->left->getType() != "Expr_BinaryOp_Concat") {
             $left_symbol = SymbolUtils::getSymbolByNode($node->left);
             $left_symbol != null && array_push($this->items, $left_symbol);
         }
     } else {
         if ($type == "Scalar_Encapsed") {
             foreach ($node->parts as $item) {
                 if (!is_object($item)) {
                     $valueSymbol = new ValueSymbol();
                     $valueSymbol->setValue($item);
                     $valueSymbol != null && array_push($this->items, $valueSymbol);
                 } else {
                     $setItem = SymbolUtils::getSymbolByNode($item);
                     $setItem != null && array_push($this->items, $setItem);
                 }
             }
         }
     }
 }
开发者ID:getcode2git,项目名称:phpvulhunter,代码行数:28,代码来源:ConcatSymbol.class.php

示例7: leaveNode

 public function leaveNode(Node $node)
 {
     if (!$node instanceof ConstFetch) {
         $callback = [$this, 'rewrite' . ucfirst($node->getType())];
         if (is_callable($callback)) {
             call_user_func_array($callback, [$node]);
         }
         return;
     }
     if ($this->disable_const_rewrite_level > 0) {
         return;
     }
     if (!$node->name instanceof Name) {
         return;
     }
     if (!$node->name->isUnqualified()) {
         return;
     }
     if (!ConstantPatcher::isBlacklisted((string) $node->name)) {
         $replacement = new FullyQualified(array());
         $replacement->set('\\__ConstProxy__::get(\'' . (string) $node->name . '\')');
         $pos = $node->getAttribute('startTokenPos');
         ConstantPatcher::$replacement[$pos] = '\\__ConstProxy__::get(\'' . (string) $node->name . '\')';
         $node->name = $replacement;
     }
 }
开发者ID:sibenye,项目名称:naijaskillhub,代码行数:26,代码来源:NodeVisitor.php

示例8: enter

 public final function enter(Node $node)
 {
     switch ($node->getType()) {
         case 'Stmt_Namespace':
             $this->namespace = $node->name;
             $this->aliases = array();
             // @todo : with multiple namespaces in one file : does this bug ?
             // leave() shouldn't reset these values ?
             break;
         case 'Stmt_UseUse':
             if (isset($this->aliases[$node->alias])) {
                 throw new \PhpParser\Error(sprintf('Cannot use "%s" as "%s" because the name is already in use', $node->name, $node->alias), $node->getLine());
             }
             $this->aliases[$node->alias] = $node->name;
             break;
         case 'Stmt_Class':
             $this->context->pushState('class', $node);
             $this->enterClassNode($node);
             break;
         case 'Stmt_Trait':
             $this->context->pushState('trait', $node);
             $this->enterTraitNode($node);
             break;
         case 'Stmt_Interface':
             $this->context->pushState('interface', $node);
             $this->enterInterfaceNode($node);
             break;
     }
 }
开发者ID:trismegiste,项目名称:mondrian,代码行数:29,代码来源:FileLevelTemplate.php

示例9: enter

 public function enter(\PhpParser\Node $node)
 {
     if ($node->getType() == 'Stmt_ClassMethod') {
         // NS
         $methodName = $node->name;
         $currentFqcn = $this->getCurrentFqcn();
         $declaringFqcn = $this->getReflectionContext()->getDeclaringClass($currentFqcn, $methodName);
         // Vertices
         $signatureIndex = $declaringFqcn . '::' . $methodName;
         $classVertex = $this->findVertex('interface', $currentFqcn);
         $signatureVertex = $this->findVertex('method', $signatureIndex);
         // if current class == declaring class, we add the edge
         if ($declaringFqcn == $currentFqcn) {
             $this->getGraph()->addEdge($classVertex, $signatureVertex);
             // I -> M
             // and we link the signature to the params
             foreach ($node->params as $idx => $param) {
                 // adding edge from signature to param :
                 $paramVertex = $this->findVertex('param', $signatureIndex . '/' . $idx);
                 // it is possible to not find the param because the signature
                 // is external to the source code :
                 if (!is_null($paramVertex)) {
                     $this->getGraph()->addEdge($signatureVertex, $paramVertex);
                     // M -> P
                     // now the type of the param :
                     $this->typeHintParam($param, $paramVertex);
                 }
             }
         }
     }
 }
开发者ID:trismegiste,项目名称:mondrian,代码行数:31,代码来源:InterfaceLevel.php

示例10: create

 /**
  * @param Node $node
  * @param $context
  * @return AbstractTranspiler
  * @throws NotImplementedException
  */
 public static function create(Node $node, $context)
 {
     if ($context === null) {
         throw new ContextNotProvidedException('You have to provide the context');
     }
     $type = $node->getType();
     if (!array_key_exists($type, self::$transpilersMap)) {
         print_R($type);
         die;
         throw new NotImplementedException("'" . $node->getType() . "' not implemented.");
     }
     $className = "\\Php2js\\Transpilers\\" . self::$transpilersMap[$type] . 'Transpiler';
     $transpiler = new $className($node);
     $transpiler->setContext($context);
     return $transpiler;
 }
开发者ID:blocka,项目名称:php2js,代码行数:22,代码来源:TranspilerFactory.php

示例11: isEqual

 public static function isEqual(\PhpParser\Node $nodeA, \PhpParser\Node $nodeB)
 {
     if ($nodeA->getType() !== $nodeB->getType()) {
         return false;
     }
     $subNodesA = $nodeA->getSubNodeNames();
     $subNodesB = $nodeB->getSubNodeNames();
     if ($subNodesA !== $subNodesB) {
         return false;
     }
     foreach ($subNodesA as $key) {
         $valueA = $nodeA->{$key};
         $valueB = $nodeB->{$key};
         $result = true;
         if ($valueA instanceof \PhpParser\Node && $valueB instanceof \PhpParser\Node) {
             $result = self::isEqual($valueA, $valueB);
         } else {
             $result = $valueA === $valueB;
         }
         if (!$result) {
             return false;
         }
     }
     return true;
 }
开发者ID:tomzx,项目名称:php-semver-checker,代码行数:25,代码来源:Node.php

示例12: enter

 public final function enter(Node $node)
 {
     if ($node->getType() == 'Stmt_ClassMethod' && $node->isPublic()) {
         $fqcn = $this->getCurrentFqcn();
         $this->enterPublicMethod($fqcn, $node);
     }
 }
开发者ID:trismegiste,项目名称:mondrian,代码行数:7,代码来源:ObjectLevelHelper.php

示例13: enterMethodCode

 protected function enterMethodCode(Node $node)
 {
     switch ($node->getType()) {
         case 'Expr_New':
             $this->pushViolation($node, 'static factory (OCP violation)');
             break;
     }
 }
开发者ID:trismegiste,项目名称:phpunit-assert-solid,代码行数:8,代码来源:StaticFactory.php

示例14: enter

 /**
  * @inheritdoc
  */
 public function enter(Node $node)
 {
     switch ($node->getType()) {
         case 'PhpFile':
             $this->context->pushState('file', $node);
             break;
     }
 }
开发者ID:trismegiste,项目名称:mondrian,代码行数:11,代码来源:PackageLevel.php

示例15: leaveNode

 /**
  * @inheritdoc
  */
 public function leaveNode(Node $node)
 {
     switch ($node->getType()) {
         case 'Stmt_Class':
             $this->currentClass = null;
             break;
         case 'Stmt_ClassMethod':
             $this->currentMethod = null;
             break;
     }
 }
开发者ID:trismegiste,项目名称:phpunit-assert-solid,代码行数:14,代码来源:MethodContentTracking.php


注:本文中的PhpParser\Node::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。