當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Node::hasAttribute方法代碼示例

本文整理匯總了PHP中PhpParser\Node::hasAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Node::hasAttribute方法的具體用法?PHP Node::hasAttribute怎麽用?PHP Node::hasAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhpParser\Node的用法示例。


在下文中一共展示了Node::hasAttribute方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: enterNode

 /**
  * Check all nodes
  *
  * @param  Node $node
  * @return void
  **/
 public function enterNode(Node $node)
 {
     // Skip nodes without comments.
     if (!$node->hasAttribute("comments")) {
         return;
     }
     // Check if annotations should be preserved. Only nodes with actual
     // doc comment blocks are processed.
     $comments = [];
     if ($this->preserveAnnotations) {
         $docComment = $node->getDocComment();
         if ($docComment) {
             $text = $docComment->getText();
             // Check if it is a doc comment.
             if (strpos($text, "/**") !== false) {
                 $text = $this->stripComment($text);
                 if ($text) {
                     $comments = [new Comment($text)];
                 }
             }
         }
     }
     // Remove (or set) comments.
     $node->setAttribute("comments", $comments);
     return $node;
 }
開發者ID:basilfx,項目名稱:php-obfuscator,代碼行數:32,代碼來源:RemoveComments.php

示例2: enterNode

 /**
  * Called when entering a node.
  *
  * Return value semantics:
  *  * null:      $node stays as-is
  *  * otherwise: $node is set to the return value
  *
  * @param Node $node Node
  *
  * @return null|Node Node
  */
 public function enterNode(Node $node)
 {
     if (isset($node->returnType)) {
         var_dump($node->returnType);
         die;
     } elseif ($node instanceof Node\Param) {
         if ($node->hasAttribute("generic_name")) {
             $type = $node->getAttribute("generic_name");
             if (isset($this->genericTypes[$type])) {
                 $node->type = new Node\Name\FullyQualified($this->genericTypes[$type]);
             } else {
                 throw new \LogicException("Bad generic found");
             }
         } elseif ($node->type instanceof Node\Name && $node->type->hasAttribute("generics") && $node->type->getAttribute("generics")) {
             $type = $node->getAttribute("original_type")->parts;
             foreach ($node->type->getAttribute("generics") as $generic) {
                 if (isset($this->genericTypes[$generic])) {
                     $value = str_replace("\\", Engine::NS_TOKEN, $this->genericTypes[$generic]);
                     $type[] = Engine::CLASS_TOKEN . $value . Engine::CLASS_TOKEN;
                 } else {
                     throw new \LogicException("Bad generic found");
                 }
             }
             $node->type = new Node\Name\FullyQualified($type);
         } elseif ((string) $node->name == "item") {
             var_dump($node);
             die;
         }
     }
 }
開發者ID:killer100,項目名稱:PhpGenerics,代碼行數:41,代碼來源:Generator.php

示例3: leaveNode

 public function leaveNode(Node $node)
 {
     if ($node->hasAttribute(NameResolver::TAG_NAMES_ATTRIBUTE)) {
         $tags = $node->getAttribute(NameResolver::TAG_NAMES_ATTRIBUTE);
         foreach ($tags as $tagName) {
             $name = new Node\Name($tagName);
             $name->setAttribute('isComment', true);
             $this->collect($name, $node);
         }
     }
 }
開發者ID:EvKoh,項目名稱:PhpDependencyAnalysis,代碼行數:11,代碼來源:TagCollector.php

示例4: leaveNode

 public function leaveNode(Node $node)
 {
     if (!$node->hasAttribute('oldEnabledRules')) {
         return;
     }
     // Restore rules as they were before this node
     $this->enabledRules = $node->getAttribute('oldEnabledRules');
 }
開發者ID:t-ichihara,項目名稱:parse,代碼行數:8,代碼來源:CallbackVisitor.php

示例5: detectNowDoc

 /**
  * @param \PhpParser\Node $node
  */
 private function detectNowDoc(Node $node)
 {
     if ($node->hasAttribute('isNowDoc') && $node instanceof Node\Scalar\String_) {
         $this->getResult()->addRequirement(Reason::NOWDOC_LITERAL, $node->getLine());
     }
 }
開發者ID:suralc,項目名稱:pvra,代碼行數:9,代碼來源:Php53Features.php

示例6: dumpPosition

 protected function dumpPosition(Node $node)
 {
     if (!$node->hasAttribute('startLine') || !$node->hasAttribute('endLine')) {
         return null;
     }
     $start = $node->getAttribute('startLine');
     $end = $node->getAttribute('endLine');
     if ($node->hasAttribute('startFilePos') && $node->hasAttribute('endFilePos') && null !== $this->code) {
         $start .= ':' . $this->toColumn($this->code, $node->getAttribute('startFilePos'));
         $end .= ':' . $this->toColumn($this->code, $node->getAttribute('endFilePos'));
     }
     return "[{$start} - {$end}]";
 }
開發者ID:nikic,項目名稱:php-parser,代碼行數:13,代碼來源:NodeDumper.php

示例7: detectShortEchoSyntax

 private function detectShortEchoSyntax(Node $node)
 {
     if ($node instanceof Node\Stmt\Echo_ && $node->hasAttribute('isShortEchoTag')) {
         $this->getResult()->addRequirement(Reason::SHORT_ECHO_TAG, $node->getLine());
     }
 }
開發者ID:suralc,項目名稱:pvra,代碼行數:6,代碼來源:Php54Features.php

示例8: removeGenerics

 protected function removeGenerics(Node $node)
 {
     if (!$node->hasAttribute('generics') || !$node->getAttribute('generics')) {
         return;
     }
     foreach ($node->getAttribute('generics') as $type) {
         unset($this->currentGenerics[$type]);
     }
 }
開發者ID:killer100,項目名稱:PhpGenerics,代碼行數:9,代碼來源:Compiler.php


注:本文中的PhpParser\Node::hasAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。