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


PHP Node::setAttribute方法代码示例

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


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

 public function enterNode(Node $node)
 {
     if (!empty($this->stack)) {
         $node->setAttribute('parent', $this->stack[count($this->stack) - 1]);
     }
     $this->stack[] = $node;
 }
开发者ID:sourcerer-mike,项目名称:phpsemver,代码行数:7,代码来源:ParentVisitor.php

示例3: leaveNode

 public function leaveNode(Node $node)
 {
     if ($node instanceof Node\Expr\Assign && $node->var instanceof Node\Expr\Variable && $this->var == $node->var->name) {
         $this->var = null;
     } elseif (!is_null($this->var) && ($node instanceof Node\Expr\FuncCall || $node instanceof Node\Expr\MethodCall || $node instanceof Node\Expr\StaticCall || $node instanceof Node\Expr\Closure)) {
         $node->setAttribute('in_var', $this->var);
         return $node;
     }
 }
开发者ID:Zackio,项目名称:vip-scanner,代码行数:9,代码来源:class-in-assignment-visitor.php

示例4: enterNode

 public function enterNode(Node $node)
 {
     $node->setAttribute('scope', implode(self::SCOPE_SEPARATOR, $this->scope));
     if ($node instanceof Node\Stmt\NameSpace_ || $node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\ClassMethod || $node instanceof Node\Stmt\Function_) {
         $this->scope[] = $node->name;
     } elseif ($node instanceof Node\Expr\Closure) {
         $this->scope[] = self::CLOSURE_NAME;
     }
     return $node;
 }
开发者ID:Zackio,项目名称:vip-scanner,代码行数:10,代码来源:class-scope-visitor.php

示例5: resolveVariableType

 /**
  * {@inheritdoc}
  */
 public function resolveVariableType(Node $node)
 {
     if ($node instanceof Node\Expr\PropertyFetch) {
         // $this->someProperty
         if ($node->var instanceof Node\Expr\Variable && $node->var->name === 'this') {
             $node->setAttribute('guessedType', $this->table->lookUpClassProperty($node->name)->type());
         }
         // $x->someProperty
     }
 }
开发者ID:Soullivaneuh,项目名称:deprecation-detector,代码行数:13,代码来源:ReattachStateToProperty.php

示例6: enterNode

 public function enterNode(Node $node)
 {
     $node->setAttribute("scope", end($this->scope));
     if ($node instanceof Stmt\Namespace_ and !empty($node->name)) {
         $this->namespace = new NamespaceName($node->name->parts);
         $this->scope[] = new Scope\NamespaceScope($this->namespace);
     } elseif ($node instanceof Stmt\Class_) {
         $this->scope[] = new Scope\ClassScope($this->namespace, $node->name);
     } elseif ($node instanceof Stmt\Function_) {
         $this->scope[] = new Scope\FunctionScope($this->namespace, $node->name);
     } elseif ($node instanceof Stmt\ClassMethod) {
         $this->scope[] = new Scope\ClassMethodScope(end($this->scope), $node->name);
     } elseif ($node instanceof Expr\Closure) {
         $identifier = $node->getAttribute("startFilePos", mt_rand());
         $node->setAttribute("identifier", $identifier);
         // The Closure node now has identifier for common use
         $this->scope[] = new Scope\ClosureScope(end($this->scope), $identifier);
     }
     $node->setAttribute("scopeInner", end($this->scope));
 }
开发者ID:sekjun9878,项目名称:elphp,代码行数:20,代码来源:ScopeResolver.php

示例7: enterNode

 public function enterNode(Node $node)
 {
     $node->setAttribute("scope", end($this->scope));
     if ($node instanceof Stmt\Namespace_ and !empty($node->name)) {
         $this->namespace = new NamespaceName($node->name->parts);
     } elseif ($node instanceof Stmt\Class_) {
         $this->scope[] = new Scope\ClassScope($this->namespace, $node->name);
     } elseif ($node instanceof Stmt\Function_) {
         $this->scope[] = new Scope\FunctionScope($this->namespace, $node->name);
     } elseif ($node instanceof Stmt\ClassMethod) {
         $this->scope[] = new Scope\ClassMethodScope(end($this->scope), $node->name);
     } elseif ($node instanceof Expr\Closure) {
         $this->scope[] = new Scope\ClosureScope(end($this->scope), $node->getAttribute("startFilePos", mt_rand()));
     }
 }
开发者ID:sekjun9878,项目名称:scope-resolver,代码行数:15,代码来源:ScopeResolver.php

示例8: resolveVariableType

 /**
  * {@inheritdoc}
  */
 public function resolveVariableType(Node $node)
 {
     if ($node instanceof Node\Expr\Variable) {
         $node->setAttribute('guessedType', $this->table->lookUp($node->name)->type());
     }
 }
开发者ID:Soullivaneuh,项目名称:deprecation-detector,代码行数:9,代码来源:ReattachStateToVariable.php

示例9: computeInternalVersions

 /**
  * Compute the version of an internal function.
  *
  * @param Node   $node
  * @param string $element
  * @param string $context
  *
  * @return void
  */
 private function computeInternalVersions(Node $node, $element, $context, $extra = null)
 {
     $versions = $node->getAttribute('compatinfo');
     if ($versions === null) {
         // find reference info
         $argc = isset($node->args) ? count($node->args) : 0;
         $versions = $this->references->find($context, $element, $argc, $extra);
         $versions['ext.all'] = $versions['php.all'] = '';
         if ($argc) {
             foreach ($node->args as $arg) {
                 if ($arg->value instanceof Node\Expr\BinaryOp\Pow) {
                     // Exponentiation
                     $this->updateVersion('5.6.0', $versions['php.min']);
                 }
             }
         }
         // cache to speed-up later uses
         $node->setAttribute('compatinfo', $versions);
     }
     $node->setAttribute('fileName', $this->file);
     if ('methods' == $context) {
         $element = sprintf('%s::%s', $extra, $element);
     }
     // update versions of $element
     $this->updateElementVersion($context, $element, $versions);
     ++$this->metrics[$context][$element]['matches'];
     // update local context
     $this->updateLocalVersions($versions, isset($this->metrics[$context][$element]['optional']));
 }
开发者ID:bjork,项目名称:php-compat-info,代码行数:38,代码来源:CompatibilityAnalyser.php

示例10: transform

 protected function transform(Node $node)
 {
     $node->type = null;
     $node->setAttribute('changed', true);
     return $node;
 }
开发者ID:Ronmi,项目名称:php7backport,代码行数:6,代码来源:ScalarTypehint.php

示例11: leaveNode

 /**
  * Perform action
  *
  * @param  Node      $node
  * @return void|bool Void if node should remain, false if not
  */
 public function leaveNode(Node $node)
 {
     $node->setAttribute('comments', []);
 }
开发者ID:bonroyage,项目名称:classtools,代码行数:10,代码来源:CommentStripper.php

示例12: transform

 protected function transform(Node $node)
 {
     $node->name = '__construct';
     $node->setAttribute('changed', true);
     return $node;
 }
开发者ID:vrana,项目名称:php7backport,代码行数:6,代码来源:Constructor.php


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