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


PHP FQSEN\FullyQualifiedFunctionName类代码示例

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


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

示例1: functionListFromSignature

 /**
  * @return Func[]
  * One or more (alternate) methods begotten from
  * reflection info and internal method data
  */
 public static function functionListFromSignature(CodeBase $code_base, FullyQualifiedFunctionName $fqsen, array $signature) : array
 {
     $context = new Context();
     $return_type = UnionType::fromStringInContext(array_shift($signature), $context);
     $func = new Func($context, $fqsen->getName(), $return_type, 0, $fqsen);
     return self::functionListFromFunction($func, $code_base);
 }
开发者ID:tpunt,项目名称:phan,代码行数:12,代码来源:FunctionFactory.php

示例2: testFullyQualifiedFunctionName

 public function testFullyQualifiedFunctionName()
 {
     $this->assertFQSENEqual(FullyQualifiedFunctionName::make('\\Name\\Space', 'g'), '\\Name\\Space\\g');
     $this->assertFQSENEqual(FullyQualifiedFunctionName::make('', 'g'), '\\g');
     $this->assertFQSENEqual(FullyQualifiedGlobalConstantName::make('', 'g'), '\\g');
     $this->assertFQSENEqual(FullyQualifiedFunctionName::fromFullyQualifiedString('\\g'), '\\g');
     $this->assertFQSENEqual(FullyQualifiedFunctionName::fromStringInContext('g', $this->context), '\\g');
 }
开发者ID:nagyistge,项目名称:phan,代码行数:8,代码来源:FQSENTest.php

示例3: createSchema

 public static function createSchema() : Schema
 {
     $schema = new Schema('File', [new Column('file_path', Column::TYPE_STRING, true), new Column('modification_time', Column::TYPE_INT)]);
     $schema->addAssociation(new ListAssociation('FileClassFQSEN', Column::TYPE_STRING, function (File $file, array $class_fqsen_string_list) {
         $file->getFile()->setClassFQSENList(array_map(function (string $fqsen_string) {
             return FullyQualifiedClassName::fromFullyQualifiedString($fqsen_string);
         }, $class_fqsen_string_list));
     }, function (File $file) {
         return array_map(function (FullyQualifiedClassName $fqsen) {
             return (string) $fqsen;
         }, $file->getFile()->getClassFQSENList());
     }));
     $schema->addAssociation(new ListAssociation('FileMethodFQSEN', Column::TYPE_STRING, function (File $file, array $method_fqsen_string_list) {
         $file->getFile()->setMethodFQSENList(array_map(function (string $fqsen_string) {
             if (false !== strpos($fqsen_string, '::')) {
                 return FullyQualifiedMethodName::fromFullyQualifiedString($fqsen_string);
             } else {
                 return FullyQualifiedFunctionName::fromFullyQualifiedString($fqsen_string);
             }
         }, $method_fqsen_string_list));
     }, function (File $file) {
         return array_map(function (FQSEN $fqsen) {
             return (string) $fqsen;
         }, $file->getFile()->getMethodFQSENList());
     }));
     $schema->addAssociation(new ListAssociation('FilePropertyFQSEN', Column::TYPE_STRING, function (File $file, array $fqsen_string_list) {
         $file->getFile()->setPropertyFQSENList(array_map(function (string $fqsen_string) {
             if (false !== strpos($fqsen_string, '::')) {
                 return FullyQualifiedPropertyName::fromFullyQualifiedString($fqsen_string);
             } else {
                 return FullyQualifiedFunctionName::fromFullyQualifiedString($fqsen_string);
             }
         }, $fqsen_string_list));
     }, function (File $file) {
         return array_map(function (FQSEN $fqsen) {
             return (string) $fqsen;
         }, $file->getFile()->getPropertyFQSENList());
     }));
     $schema->addAssociation(new ListAssociation('FileConstantFQSEN', Column::TYPE_STRING, function (File $file, array $fqsen_string_list) {
         $file->getFile()->setConstantFQSENList(array_map(function (string $fqsen_string) {
             if (false !== strpos($fqsen_string, '::')) {
                 return FullyQualifiedConstantName::fromFullyQualifiedString($fqsen_string);
             } else {
                 return FullyQualifiedFunctionName::fromFullyQualifiedString($fqsen_string);
             }
         }, $fqsen_string_list));
     }, function (File $file) {
         return array_map(function (FQSEN $fqsen) {
             return (string) $fqsen;
         }, $file->getFile()->getConstantFQSENList());
     }));
     return $schema;
 }
开发者ID:tmli3b3rm4n,项目名称:phan,代码行数:53,代码来源:File.php

示例4: addUndefinedFunctionSignatures

 /**
  * Add any functions from the FunctionSignatureMap that aren't
  * defined in this version of PHP to the code base
  *
  * @return void
  */
 private function addUndefinedFunctionSignatures()
 {
     $function_signature_map = UnionType::internalFunctionSignatureMap();
     foreach ($function_signature_map as $function_name => $signature) {
         $fqsen = FullyQualifiedFunctionName::make('\\', $function_name);
         // If we already loaded the function, skip it
         if ($this->hasMethod($fqsen)) {
             continue;
         }
         // Add each method returned for the signature
         foreach (Method::methodListFromSignature($this, $fqsen, $signature) as $method) {
             $this->addMethod($method);
         }
     }
 }
开发者ID:tmli3b3rm4n,项目名称:phan,代码行数:21,代码来源:CodeBase.php

示例5: hasInternalFunctionWithFQSEN

 /**
  * @param FullyQualifiedFunctionName
  * The FQSEN of a function we'd like to look up
  *
  * @return bool
  * If the FQSEN represents an internal function that
  * hasn't been loaded yet, true is returned.
  */
 private function hasInternalFunctionWithFQSEN(FullyQualifiedFunctionName $fqsen) : bool
 {
     // Only root namespaced functions will be found in
     // the internal function map.
     if ($fqsen->getNamespace() != '\\') {
         return false;
     }
     // For elements in the root namespace, check to see if
     // there's a static method signature for something that
     // hasn't been loaded into memory yet and create a
     // method out of it as its requested
     $function_signature_map = UnionType::internalFunctionSignatureMap();
     if (!empty($function_signature_map[$fqsen->getNameWithAlternateId()])) {
         $signature = $function_signature_map[$fqsen->getNameWithAlternateId()];
         // Add each method returned for the signature
         foreach (FunctionFactory::functionListFromSignature($this, $fqsen, $signature) as $i => $function) {
             $this->addFunction($function);
         }
         return true;
     }
     return false;
 }
开发者ID:etsy,项目名称:phan,代码行数:30,代码来源:CodeBase.php

示例6: getNamespaceMapFor

 /**
  * @return FullyQualifiedGlobalStructuralElement
  * The namespace mapped name for the given flags and name
  */
 public function getNamespaceMapFor(int $flags, string $name) : FullyQualifiedGlobalStructuralElement
 {
     $name = strtolower($name);
     // Look for the mapping on the part before a
     // slash
     $name_parts = explode('\\', $name, 2);
     $suffix = '';
     if (count($name_parts) > 1) {
         $name = $name_parts[0];
         $suffix = $name_parts[1];
     }
     assert(!empty($this->namespace_map[$flags][$name]), "No namespace defined for name");
     assert($this->namespace_map[$flags][$name] instanceof FQSEN, "Namespace map was not an FQSEN");
     $fqsen = $this->namespace_map[$flags][$name];
     if (!$suffix) {
         return $fqsen;
     }
     switch ($flags) {
         case \ast\flags\USE_NORMAL:
             return FullyQualifiedClassName::fromFullyQualifiedString((string) $fqsen . '\\' . $suffix);
         case \ast\flags\USE_FUNCTION:
             return FullyQualifiedFunctionName::fromFullyQualifiedString((string) $fqsen . '\\' . $suffix);
     }
     assert(false, "Unknown flag {$flags}");
     return $fqsen;
 }
开发者ID:etsy,项目名称:phan,代码行数:30,代码来源:Context.php

示例7: unserialize

 public function unserialize($serialized)
 {
     list($file_ref, $serialized) = explode('^', $serialized);
     parent::unserialize($file_ref);
     list($namespace, $is_conditional, $class_fqsen, $method_fqsen, $closure_fqsen) = explode('|', $serialized);
     $this->namespace = $namespace;
     $this->is_conditional = (bool) $is_conditional;
     $this->class_fqsen = $class_fqsen ? FullyQualifiedClassName::fromFullyQualifiedString($class_fqsen) : null;
     $this->method_fqsen = $method_fqsen ? FullyQualifiedMethodName::fromFullyQualifiedString($method_fqsen) : null;
     $this->closure_fqsen = $closure_fqsen ? FullyQualifiedFunctionName::fromFullyQualifiedString($closure_fqsen) : null;
 }
开发者ID:gitter-badger,项目名称:phan,代码行数:11,代码来源:Context.php

示例8: methodListFromReflectionFunction

 /**
  * @return Method[]
  * One or more (alternate) methods begotten from
  * reflection info and internal method data
  */
 public static function methodListFromReflectionFunction(CodeBase $code_base, \ReflectionFunction $reflection_function) : array
 {
     $number_of_required_parameters = $reflection_function->getNumberOfRequiredParameters();
     $number_of_optional_parameters = $reflection_function->getNumberOfParameters() - $number_of_required_parameters;
     $context = new Context();
     $parts = explode('\\', $reflection_function->getName());
     $method_name = array_pop($parts);
     $namespace = '\\' . implode('\\', $parts);
     $fqsen = FullyQualifiedFunctionName::make($namespace, $method_name);
     $method = new Method($context, $fqsen->getName(), new UnionType(), 0, $number_of_required_parameters, $number_of_optional_parameters);
     $method->setFQSEN($fqsen);
     return self::methodListFromMethod($method, $code_base);
 }
开发者ID:themarios,项目名称:phan,代码行数:18,代码来源:Method.php

示例9: 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

示例10: aliasTargetMapFromUseNode

 /**
  * @return array
  * A map from alias to target
  */
 private function aliasTargetMapFromUseNode(Node $node, string $prefix = '') : array
 {
     assert($node->kind == \ast\AST_USE, 'Method takes AST_USE nodes');
     $map = [];
     foreach ($node->children ?? [] as $child_node) {
         $target = $child_node->children['name'];
         if (empty($child_node->children['alias'])) {
             if (($pos = strrpos($target, '\\')) !== false) {
                 $alias = substr($target, $pos + 1);
             } else {
                 $alias = $target;
             }
         } else {
             $alias = $child_node->children['alias'];
         }
         // if AST_USE does not have any flags set, then its AST_USE_ELEM
         // children will (this will be for AST_GROUP_USE)
         if ($node->flags !== 0) {
             $target_node = $node;
         } else {
             $target_node = $child_node;
         }
         if ($target_node->flags == T_FUNCTION) {
             $parts = explode('\\', $target);
             $function_name = array_pop($parts);
             $target = FullyQualifiedFunctionName::make($prefix . '\\' . implode('\\', $parts), $function_name);
         } else {
             if ($target_node->flags == T_CONST) {
                 $parts = explode('\\', $target);
                 $name = array_pop($parts);
                 $target = FullyQualifiedGlobalConstantName::make($prefix . '\\' . implode('\\', $parts), $name);
             } else {
                 $target = FullyQualifiedClassName::fromFullyQualifiedString($prefix . '\\' . $target);
             }
         }
         $map[$alias] = [$target_node->flags, $target];
     }
     return $map;
 }
开发者ID:ablyler,项目名称:phan,代码行数:43,代码来源:ScopeVisitor.php

示例11: visitFuncDecl

 /**
  * Visit a node with kind `\ast\AST_FUNC_DECL`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitFuncDecl(Decl $node) : Context
 {
     $function_name = (string) $node->name;
     // Hunt for an un-taken alternate ID
     $alternate_id = 0;
     $function_fqsen = null;
     do {
         $function_fqsen = FullyQualifiedFunctionName::fromStringInContext($function_name, $this->context)->withNamespace($this->context->getNamespace())->withAlternateId($alternate_id++);
     } while ($this->code_base->hasFunctionWithFQSEN($function_fqsen));
     $func = Func::fromNode($this->context->withLineNumberStart($node->lineno ?? 0)->withLineNumberEnd($node->endLineno ?? 0), $this->code_base, $node, $function_fqsen);
     $this->code_base->addFunction($func);
     // Send the context into the function and reset the scope
     $context = $this->context->withScope($func->getInternalScope());
     return $context;
 }
开发者ID:tpunt,项目名称:phan,代码行数:25,代码来源:ParseVisitor.php

示例12: 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

示例13: visitCall

 /**
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitCall(Node $node) : Context
 {
     $expression = $node->children['expr'];
     (new ContextNode($this->code_base, $this->context, $node))->analyzeBackwardCompatibility();
     foreach ($node->children['args']->children ?? [] as $arg_node) {
         if ($arg_node instanceof Node) {
             (new ContextNode($this->code_base, $this->context, $arg_node))->analyzeBackwardCompatibility();
         }
     }
     if ($expression->kind == \ast\AST_VAR) {
         $variable_name = (new ContextNode($this->code_base, $this->context, $expression))->getVariableName();
         if (empty($variable_name)) {
             return $this->context;
         }
         // $var() - hopefully a closure, otherwise we don't know
         if ($this->context->getScope()->hasVariableWithName($variable_name)) {
             $variable = $this->context->getScope()->getVariableByName($variable_name);
             $union_type = $variable->getUnionType();
             if ($union_type->isEmpty()) {
                 return $this->context;
             }
             foreach ($union_type->getTypeSet() as $type) {
                 if (!$type instanceof CallableType) {
                     continue;
                 }
                 $closure_fqsen = FullyQualifiedFunctionName::fromFullyQualifiedString((string) $type->asFQSEN());
                 if ($this->code_base->hasFunctionWithFQSEN($closure_fqsen)) {
                     // Get the closure
                     $function = $this->code_base->getFunctionByFQSEN($closure_fqsen);
                     // Check the call for paraemter and argument types
                     $this->analyzeCallToMethod($this->code_base, $function, $node);
                 }
             }
         }
     } elseif ($expression->kind == \ast\AST_NAME) {
         try {
             $method = (new ContextNode($this->code_base, $this->context, $expression))->getFunction($expression->children['name'] ?? $expression->children['method']);
         } catch (IssueException $exception) {
             Issue::maybeEmitInstance($this->code_base, $this->context, $exception->getIssueInstance());
             return $this->context;
         }
         // Check the call for paraemter and argument types
         $this->analyzeCallToMethod($this->code_base, $method, $node);
     } elseif ($expression->kind == \ast\AST_CALL || $expression->kind == \ast\AST_STATIC_CALL || $expression->kind == \ast\AST_NEW || $expression->kind == \ast\AST_METHOD_CALL) {
         $class_list = (new ContextNode($this->code_base, $this->context, $expression))->getClassList();
         foreach ($class_list as $class) {
             if (!$class->hasMethodWithName($this->code_base, '__invoke')) {
                 continue;
             }
             $method = $class->getMethodByNameInContext($this->code_base, '__invoke', $this->context);
             // Check the call for paraemter and argument types
             $this->analyzeCallToMethod($this->code_base, $method, $node);
         }
     }
     return $this->context;
 }
开发者ID:etsy,项目名称:phan,代码行数:64,代码来源:PostOrderAnalysisVisitor.php

示例14: methodListFromSignature

 /**
  * @return Method[]
  * One or more (alternate) methods begotten from
  * reflection info and internal method data
  */
 public static function methodListFromSignature(CodeBase $code_base, FullyQualifiedFunctionName $fqsen, array $signature) : array
 {
     $context = new Context();
     $return_type = UnionType::fromStringInContext(array_shift($signature), $context);
     $method = new Method($context, $fqsen->getName(), $return_type, 0);
     $method->setFQSEN($fqsen);
     return self::methodListFromMethod($method, $code_base);
 }
开发者ID:mgonyan,项目名称:phan,代码行数:13,代码来源:Method.php

示例15: fromRow

 /**
  * @param array
  * A map from column name to value
  *
  * @return Model
  * An instance of the model derived from row data
  */
 public static function fromRow(array $row) : Method
 {
     list($scope, $name) = explode('|', $row['scope_name']);
     $method_element = new MethodElement(unserialize(base64_decode($row['context'])), $row['name'], UnionType::fromFullyQualifiedString($row['type']), (int) $row['flags']);
     $method_element->setNumberOfRequiredParameters($row['number_of_required_parameters']);
     $method_element->setNumberOfOptionalParameters($row['number_of_optional_parameters']);
     $method = new Method($method_element, $scope, $name);
     if (false !== strpos($row['fqsen'], '::')) {
         $fqsen = FullyQualifiedMethodName::fromFullyQualifiedString($row['fqsen']);
     } else {
         $fqsen = FullyQualifiedFunctionName::fromFullyQualifiedString($row['fqsen']);
     }
     $method->getMethod()->setFQSEN($fqsen);
     return $method;
 }
开发者ID:black-silence,项目名称:phan,代码行数:22,代码来源:Method.php


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