當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。