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


PHP FullyQualifiedFunctionName::fromClosureInContext方法代码示例

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


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

示例1: visitClosure

 /**
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitClosure(Node $node) : Context
 {
     $this->analyzeNoOp($node, "no-op closure");
     return $this->context->withClosureFQSEN(FullyQualifiedFunctionName::fromClosureInContext($this->context));
 }
开发者ID:jazzdan,项目名称:phan,代码行数:13,代码来源:BreadthFirstVisitor.php

示例2: visitClosure

 /**
  * Visit a node with kind `\ast\AST_CLOSURE`
  *
  * @param Node $node
  * A node of the type indicated by the method name that we'd
  * like to figure out the type that it produces.
  *
  * @return UnionType
  * The set of types that are possibly produced by the
  * given node
  */
 public function visitClosure(Decl $node) : UnionType
 {
     // The type of a closure is the fqsen pointing
     // at its definition
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     $type = CallableType::instanceWithClosureFQSEN($closure_fqsen)->asUnionType();
     return $type;
 }
开发者ID:gitter-badger,项目名称:phan,代码行数:19,代码来源:UnionTypeVisitor.php

示例3: getClosure

 /**
  * @return Method
  */
 public function getClosure() : Func
 {
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     if (!$this->code_base->hasFunctionWithFQSEN($closure_fqsen)) {
         throw new CodeBaseException($closure_fqsen, "Could not find closure {$closure_fqsen}");
     }
     return $this->code_base->getFunctionByFQSEN($closure_fqsen);
 }
开发者ID:ablyler,项目名称:phan,代码行数:11,代码来源:ContextNode.php

示例4: visitClosure

 /**
  * Visit a node with kind `\ast\AST_CLOSURE`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitClosure(Node $node) : Context
 {
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context);
     $method = Method::fromNode($this->context, $this->code_base, $node);
     // Override the FQSEN with the found alternate ID
     $method->setFQSEN($closure_fqsen);
     // Make the closure reachable by FQSEN from anywhere
     $this->code_base->addMethod($method);
     // If we have a 'this' variable in our current scope,
     // pass it down into the closure
     $context = $this->context->withScope(new Scope());
     if ($context->getScope()->hasVariableWithName('this')) {
         $context = $context->addScopeVariable($this->context->getScope()->getVariableWithName('this'));
     }
     if (!empty($node->children['uses']) && $node->children['uses']->kind == \ast\AST_CLOSURE_USES) {
         $uses = $node->children['uses'];
         foreach ($uses->children as $use) {
             if ($use->kind != \ast\AST_CLOSURE_VAR) {
                 Log::err(Log::EVAR, "You can only have variables in a closure use() clause", $this->context->getFile(), $node->lineno);
                 continue;
             }
             $variable_name = AST::variableName($use->children['name']);
             if (empty($variable_name)) {
                 continue;
             }
             $variable = null;
             // Check to see if the variable exists in this scope
             if (!$this->context->getScope()->hasVariableWithName($variable_name)) {
                 // If this is not pass-by-reference variable we
                 // have a problem
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     Log::err(Log::EVAR, "Variable \${$variable_name} is not defined", $this->context->getFile(), $node->lineno);
                     continue;
                 } else {
                     // If the variable doesn't exist, but its
                     // a pass-by-reference variable, we can
                     // just create it
                     $variable = Variable::fromNodeInContext($use, $this->context, $this->code_base, false);
                 }
             } else {
                 $variable = $this->context->getScope()->getVariableWithName($variable_name);
                 // If this isn't a pass-by-reference variable, we
                 // clone the variable so state within this scope
                 // doesn't update the outer scope
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     $variable = clone $variable;
                 }
             }
             // Pass the variable into a new scope
             $context = $context->withScopeVariable($variable);
         }
     }
     // Add all parameters to the scope
     if (!empty($node->children['params']) && $node->children['params']->kind == \ast\AST_PARAM_LIST) {
         $params = $node->children['params'];
         foreach ($params->children as $param) {
             // Read the parameter
             $parameter = Parameter::fromNode($this->context, $this->code_base, $param);
             // Add it to the scope
             $context = $context->withScopeVariable($parameter);
         }
     }
     return $context->withClosureFQSEN($closure_fqsen);
 }
开发者ID:hslatman,项目名称:phan,代码行数:74,代码来源:DepthFirstVisitor.php

示例5: visitClosure

 /**
  * Visit a node with kind `\ast\AST_CLOSURE`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitClosure(Decl $node) : Context
 {
     $closure_fqsen = FullyQualifiedFunctionName::fromClosureInContext($this->context->withLineNumberStart($node->lineno ?? 0));
     $func = Func::fromNode($this->context, $this->code_base, $node, $closure_fqsen);
     // If we have a 'this' variable in our current scope,
     // pass it down into the closure
     if ($this->context->getScope()->hasVariableWithName('this')) {
         $func->getInternalScope()->addVariable($this->context->getScope()->getVariableByName('this'));
     }
     // Make the closure reachable by FQSEN from anywhere
     $this->code_base->addFunction($func);
     if (!empty($node->children['uses']) && $node->children['uses']->kind == \ast\AST_CLOSURE_USES) {
         $uses = $node->children['uses'];
         foreach ($uses->children as $use) {
             if ($use->kind != \ast\AST_CLOSURE_VAR) {
                 $this->emitIssue(Issue::VariableUseClause, $node->lineno ?? 0);
                 continue;
             }
             $variable_name = (new ContextNode($this->code_base, $this->context, $use->children['name']))->getVariableName();
             if (empty($variable_name)) {
                 continue;
             }
             $variable = null;
             // Check to see if the variable exists in this scope
             if (!$this->context->getScope()->hasVariableWithName($variable_name)) {
                 // If this is not pass-by-reference variable we
                 // have a problem
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     $this->emitIssue(Issue::UndeclaredVariable, $node->lineno ?? 0, $variable_name);
                     continue;
                 } else {
                     // If the variable doesn't exist, but its
                     // a pass-by-reference variable, we can
                     // just create it
                     $variable = Variable::fromNodeInContext($use, $this->context, $this->code_base, false);
                 }
             } else {
                 $variable = $this->context->getScope()->getVariableByName($variable_name);
                 // If this isn't a pass-by-reference variable, we
                 // clone the variable so state within this scope
                 // doesn't update the outer scope
                 if (!($use->flags & \ast\flags\PARAM_REF)) {
                     $variable = clone $variable;
                 }
             }
             // Pass the variable into a new scope
             $func->getInternalScope()->addVariable($variable);
         }
     }
     // Add all parameters to the scope
     if (!empty($node->children['params']) && $node->children['params']->kind == \ast\AST_PARAM_LIST) {
         $params = $node->children['params'];
         foreach ($params->children as $param) {
             // Read the parameter
             $parameter = Parameter::fromNode($this->context, $this->code_base, $param);
             // Add it to the scope
             $func->getInternalScope()->addVariable($parameter);
         }
     }
     if ($this->analyzeFunctionLikeIsGenerator($node)) {
         $this->setReturnTypeOfGenerator($func, $node);
     }
     return $this->context->withScope($func->getInternalScope());
 }
开发者ID:etsy,项目名称:phan,代码行数:74,代码来源:PreOrderAnalysisVisitor.php


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