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


PHP Node::getParams方法代码示例

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


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

示例1: recordFunctionParameterTypesUsage

 private function recordFunctionParameterTypesUsage(Node $node)
 {
     if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
         foreach ($node->getParams() as $param) {
             if ($param->type instanceof Node\Name) {
                 $this->recordUsageOf($param->type);
             }
             if (is_string($param->type)) {
                 $this->recordUsageOfByString($param->type);
             }
         }
     }
 }
开发者ID:pamil,项目名称:ComposerRequireChecker,代码行数:13,代码来源:UsedSymbolCollector.php

示例2: enterNode

 /**
  * {@inheritdoc}
  */
 public function enterNode(Node $node)
 {
     if (!$node instanceof Node\FunctionLike) {
         return;
     }
     $parametersNames = array();
     foreach ($node->getParams() as $parameter) {
         $currentParameterName = $parameter->name;
         if (!isset($parametersNames[$currentParameterName])) {
             $parametersNames[$currentParameterName] = false;
         } elseif (!$parametersNames[$currentParameterName]) {
             $this->addContextMessage(sprintf('Duplicate function parameter name "%s"', $currentParameterName), $node);
             $parametersNames[$currentParameterName] = true;
         }
     }
 }
开发者ID:lzpfmh,项目名称:php7cc,代码行数:19,代码来源:DuplicateFunctionParameterVisitor.php

示例3: leaveNode

 /**
  * {@inheritdoc}
  */
 public function leaveNode(Node $node)
 {
     if ($node instanceof Node\FunctionLike) {
         $params = $node->getParams();
         $paramNames = array();
         $hasParameterWithSameName = false;
         array_walk($params, function (Node\Param $param) use(&$paramNames, &$hasParameterWithSameName) {
             if (array_key_exists($param->name, $paramNames)) {
                 $hasParameterWithSameName = true;
             }
             $paramNames[$param->name] = true;
         });
         if ($hasParameterWithSameName) {
             $this->errorCollection->add(new Error($this->parserContext->getFilename(), $node->getLine(), 'Functions can no longer have more than one parameter with the same name.'));
         }
     }
 }
开发者ID:jolicode,项目名称:php7-checker,代码行数:20,代码来源:FunctionParametersSameNameChecker.php

示例4: enterNode

 /**
  * @inheritdoc
  * @param \PhpParser\Node $node
  * @return null|\PhpParser\Node|void
  */
 public function enterNode(Node $node)
 {
     // direct class calls
     if ($node instanceof Node\Expr\New_ || $node instanceof Node\Expr\StaticCall || $node instanceof Node\Expr\ClassConstFetch || $node instanceof Node\Expr\StaticPropertyFetch) {
         if ($node->class instanceof Node\Name) {
             $this->handleClassName($node->class);
         }
         if ($node instanceof Node\Expr\ClassConstFetch) {
             $this->handleConstantName($node->name, $node->getLine());
         }
     } elseif ($node instanceof Node\FunctionLike) {
         if (!empty($node->getParams())) {
             foreach ($node->getParams() as $param) {
                 if (isset($param->type) && !is_string($param->type)) {
                     $this->handleClassName($param->type);
                 }
             }
         }
     } elseif ($node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Interface_) {
         $names = [];
         if (!empty($node->implements)) {
             $names += $node->implements;
         }
         if (!empty($node->extends)) {
             if ($node->extends instanceof Name) {
                 $names[] = $node->extends;
             } else {
                 $names += $node->extends;
             }
         }
         foreach ($names as $name) {
             $this->handleClassName($name);
         }
     } elseif ($node instanceof Node\Expr\FuncCall && !$node->name instanceof Node\Expr) {
         $this->handleFunctionName($node->name);
     } elseif ($node instanceof Node\Expr\ConstFetch) {
         $this->handleConstantName($node->name);
     }
 }
开发者ID:suralc,项目名称:pvra,代码行数:44,代码来源:LibraryChanges.php

示例5: enterNode

 /**
  * {@inheritdoc}
  */
 public function enterNode(Node $node)
 {
     if ($node instanceof Node\Stmt\Namespace_) {
         $this->aliases = [];
         return;
     }
     if ($node instanceof Node\Stmt\Use_) {
         foreach ($node->uses as $use) {
             $this->aliases[$use->alias] = (string) $use->name;
         }
         return;
     }
     if ($node instanceof Node\Stmt\ClassMethod) {
         $params = $node->getParams();
         if (!count($params)) {
             return;
         }
         $param1 = $params[0];
         $paramClass = $this->resolveAlias((string) $param1->type);
         if (is_subclass_of($paramClass, '\\Symfony\\Component\\Validator\\Context\\ExecutionContextInterface')) {
             $this->contextVariable = $param1->name;
         }
         return;
     }
     if ($node instanceof Node\Expr\MethodCall) {
         $this->parseMethodCall($node);
     }
 }
开发者ID:php-community,项目名称:JMSTranslationBundle,代码行数:31,代码来源:ValidationContextExtractor.php


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