当前位置: 首页>>代码示例>>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;未经允许,请勿转载。