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


PHP FQSEN\FullyQualifiedClassName类代码示例

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


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

示例1: testMethodInCodeBase

 public function testMethodInCodeBase()
 {
     $context = $this->contextForCode("\n                namespace A;\n                Class B {\n                    public function c() {\n                        return 42;\n                    }\n                }\n            ");
     $class_fqsen = FullyQualifiedClassName::fromFullyQualifiedString('\\A\\b');
     self::assertTrue($this->code_base->hasClassWithFQSEN($class_fqsen), "Class with FQSEN {$class_fqsen} not found");
     $clazz = $this->code_base->getClassByFQSEN($class_fqsen);
     self::assertTrue($clazz->hasMethodWithName($this->code_base, 'c'), "Method with FQSEN not found");
 }
开发者ID:Jvbzephir,项目名称:phan,代码行数:8,代码来源:AnalyzerTest.php

示例2: __construct

 /**
  * @param Context $context
  * The context of the current execution
  *
  * @param CodeBase $code_base
  * The global code base
  *
  * @param string $class_name
  * The name we're trying to validate
  */
 public function __construct(Context $context, CodeBase $code_base, string $class_name)
 {
     $this->context = $context;
     $this->code_base = $code_base;
     $this->class_name = $class_name;
     // Compute the FQSEN based on the current context
     $this->class_fqsen = FullyQualifiedClassName::fromStringInContext($this->class_name, $this->context);
 }
开发者ID:mgonyan,项目名称:phan,代码行数:18,代码来源:ValidationVisitor.php

示例3: testFullyQualifiedClassConstantName

 public function testFullyQualifiedClassConstantName()
 {
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::make(FullyQualifiedClassName::make('\\Name\\Space', 'a'), 'c'), '\\Name\\Space\\a::c');
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::fromFullyQualifiedString('\\Name\\a::c'), '\\Name\\a::c');
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::fromFullyQualifiedString('Name\\a::c'), '\\Name\\a::c');
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::fromFullyQualifiedString('\\Name\\Space\\a::c,2'), '\\Name\\Space\\a::c,2');
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::fromFullyQualifiedString('\\Name\\Space\\a,1::c,2'), '\\Name\\Space\\a,1::c,2');
     $this->assertFQSENEqual(FullyQualifiedClassConstantName::fromStringInContext('a::methodName', $this->context), '\\a::methodName');
 }
开发者ID:nagyistge,项目名称:phan,代码行数:9,代码来源:FQSENTest.php

示例4: testSimple

 public function testSimple()
 {
     $context = new Context();
     $context_namespace = $context->withNamespace('\\A');
     $context_class = $context_namespace->withScope(new ClassScope($context_namespace->getScope(), FullyQualifiedClassName::fromFullyQualifiedString('\\A\\B')));
     $context_method = $context_namespace->withScope(new FunctionLikeScope($context_namespace->getScope(), FullyQualifiedMethodName::fromFullyQualifiedString('\\A\\b::c')));
     $this->assertTrue(!empty($context));
     $this->assertTrue(!empty($context_namespace));
     $this->assertTrue(!empty($context_class));
     $this->assertTrue(!empty($context_method));
 }
开发者ID:etsy,项目名称:phan,代码行数:11,代码来源:ContextTest.php

示例5: testSimple

 public function testSimple()
 {
     $context = new Context();
     $context_namespace = $context->withNamespace('\\A');
     $context_class = $context_namespace->withClassFQSEN(FullyQualifiedClassName::fromFullyQualifiedString('\\A\\B'));
     $context_method = $context_namespace->withMethodFQSEN(FullyQualifiedMethodName::fromFullyQualifiedString('\\A\\b::c'));
     $this->assertTrue(!empty($context));
     $this->assertTrue(!empty($context_namespace));
     $this->assertTrue(!empty($context_class));
     $this->assertTrue(!empty($context_method));
 }
开发者ID:ablyler,项目名称:phan,代码行数:11,代码来源:ContextTest.php

示例6: 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) : Clazz
 {
     $parent_fqsen = $row['parent_class_fqsen'] ? FullyQualifiedClassName::fromFullyQualifiedString($row['parent_class_fqsen']) : null;
     $interface_fqsen_list = array_map(function (string $fqsen_string) {
         return FullyQualifiedClassName::fromFullyQualifiedString($fqsen_string);
     }, array_filter(explode('|', $row['interface_fqsen_list'])));
     $trait_fqsen_list = array_map(function (string $fqsen_string) {
         return FullyQualifiedClassName::fromFullyQualifiedString($fqsen_string);
     }, array_filter(explode('|', $row['trait_fqsen_list'])));
     $clazz = new ClazzElement(unserialize(base64_decode($row['context'])), $row['name'], UnionType::fromFullyQualifiedString($row['type']), (int) $row['flags'], $parent_fqsen, $interface_fqsen_list, $trait_fqsen_list);
     return new Clazz($clazz);
 }
开发者ID:hslatman,项目名称:phan,代码行数:19,代码来源:Clazz.php

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

示例8: visitClass

 /**
  * Visit a node with kind `\ast\AST_CLASS`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitClass(Decl $node) : Context
 {
     if ($node->flags & \ast\flags\CLASS_ANONYMOUS) {
         $class_name = (new ContextNode($this->code_base, $this->context, $node))->getUnqualifiedNameForAnonymousClass();
     } else {
         $class_name = (string) $node->name;
     }
     assert(!empty($class_name), "Class name cannot be empty");
     $alternate_id = 0;
     // Hunt for the alternate of this class defined
     // in this file
     do {
         $class_fqsen = FullyQualifiedClassName::fromStringInContext($class_name, $this->context)->withAlternateId($alternate_id++);
         if (!$this->code_base->hasClassWithFQSEN($class_fqsen)) {
             throw new CodeBaseException($class_fqsen, "Can't find class {$class_fqsen} - aborting");
         }
         $clazz = $this->code_base->getClassByFQSEN($class_fqsen);
     } while ($this->context->getProjectRelativePath() != $clazz->getContext()->getProjectRelativePath() || $this->context->getLineNumberStart() != $clazz->getContext()->getLineNumberStart());
     return $clazz->getContext()->withClassFQSEN($class_fqsen);
 }
开发者ID:actank,项目名称:phan,代码行数:30,代码来源:PreOrderAnalysisVisitor.php

示例9: fromStringInContext

 /**
  * @param Context $context
  * The context in which the FQSEN string was found
  *
  * @param $fqsen_string
  * An FQSEN string like '\Namespace\Class::methodName'
  *
  * @return FullyQualifiedMethodName
  */
 public static function fromStringInContext(string $fqsen_string, Context $context)
 {
     // Test to see if we have a class defined
     if (false === strpos($fqsen_string, '::')) {
         assert($context->isInClassScope(), "Cannot reference class element without class name when not in class scope.");
         $fully_qualified_class_name = $context->getClassFQSEN();
     } else {
         assert(false !== strpos($fqsen_string, '::'), "Fully qualified class element lacks '::' delimiter");
         list($class_name_string, $fqsen_string) = explode('::', $fqsen_string);
         $fully_qualified_class_name = FullyQualifiedClassName::fromStringInContext($class_name_string, $context);
     }
     // Split off the alternate ID
     $parts = explode(',', $fqsen_string);
     $name = $parts[0];
     $alternate_id = (int) ($parts[1] ?? 0);
     assert(is_int($alternate_id), "Alternate must be an integer");
     return static::make($fully_qualified_class_name, $name, $alternate_id);
 }
开发者ID:tpunt,项目名称:phan,代码行数:27,代码来源:FullyQualifiedClassElement.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: visitCatch

 /**
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitCatch(Node $node) : Context
 {
     // Get the name of the class
     $class_name = $node->children['class']->children['name'];
     $clazz = null;
     // If we can't figure out the class name (which happens
     // from time to time), then give up
     if (!empty($class_name)) {
         $class_fqsen = FullyQualifiedClassName::fromStringInContext($class_name, $this->context);
         // Check to see if the class actually exists
         if ($this->code_base->hasClassWithFQSEN($class_fqsen)) {
             $clazz = $this->code_base->getClassByFQSEN($class_fqsen);
         } else {
             Log::err(Log::EUNDEF, "call to method on undeclared class {$class_name}", $this->context->getFile(), $node->lineno);
         }
     }
     $variable_name = AST::variableName($node->children['var']);
     if (!empty($variable_name)) {
         $variable = Variable::fromNodeInContext($node->children['var'], $this->context, $this->code_base, false);
         if ($clazz) {
             $variable->setUnionType($clazz->getUnionType());
         }
         $this->context->addScopeVariable($variable);
     }
     return $this->context;
 }
开发者ID:hslatman,项目名称:phan,代码行数:34,代码来源:DepthFirstVisitor.php

示例12: fromReflectionClass

 /**
  * @param CodeBase $code_base
  * A reference to the entire code base in which this
  * context exists
  *
  * @param ReflectionClass $class
  * A reflection class representing a builtin class.
  *
  * @return Clazz
  * A Class structural element representing the given named
  * builtin.
  */
 public static function fromReflectionClass(CodeBase $code_base, \ReflectionClass $class) : Clazz
 {
     // Build a set of flags based on the constitution
     // of the built-in class
     $flags = 0;
     if ($class->isFinal()) {
         $flags = \ast\flags\CLASS_FINAL;
     } elseif ($class->isInterface()) {
         $flags = \ast\flags\CLASS_INTERFACE;
     } elseif ($class->isTrait()) {
         $flags = \ast\flags\CLASS_TRAIT;
     }
     if ($class->isAbstract()) {
         $flags |= \ast\flags\CLASS_ABSTRACT;
     }
     $context = new Context();
     // Build a base class element
     $clazz = new Clazz($context, $class->getName(), UnionType::fromStringInContext($class->getName(), $context), $flags);
     $clazz->setFQSEN(FullyQualifiedClassName::fromStringInContext($class->getName(), $context));
     // If this class has a parent class, add it to the
     // class info
     if ($parent_class = $class->getParentClass()) {
         $parent_class_fqsen = FullyQualifiedClassName::fromFullyQualifiedString('\\' . $parent_class->getName());
         $clazz->setParentClassFQSEN($parent_class_fqsen);
     }
     foreach ($class->getDefaultProperties() as $name => $value) {
         // TODO: whats going on here?
         $reflection_property = new \ReflectionProperty($class->getName(), $name);
         $property_context = $context->withClassFQSEN($clazz->getFQSEN());
         $property = new Property($property_context, $name, Type::fromObject($value)->asUnionType(), 0);
         $property->setFQSEN(FullyQualifiedPropertyName::make($clazz->getFQSEN(), $name));
         $clazz->addProperty($code_base, $property);
     }
     foreach ($class->getInterfaceNames() as $name) {
         $clazz->addInterfaceClassFQSEN(FullyQualifiedClassName::fromFullyQualifiedString('\\' . $name));
     }
     foreach ($class->getTraitNames() as $name) {
         $clazz->addTraitFQSEN(FullyQualifiedClassName::fromFullyQualifiedString('\\' . $name));
     }
     foreach ($class->getConstants() as $name => $value) {
         $constant = new ClassConstant($context, $name, Type::fromObject($value)->asUnionType(), 0);
         $constant->setFQSEN(FullyQualifiedClassConstantName::make($clazz->getFQSEN(), $name));
         $clazz->addConstant($code_base, $constant);
     }
     foreach ($class->getMethods() as $reflection_method) {
         $method_list = FunctionFactory::methodListFromReflectionClassAndMethod($context->withClassFQSEN($clazz->getFQSEN()), $code_base, $class, $reflection_method);
         foreach ($method_list as $method) {
             $clazz->addMethod($code_base, $method);
         }
     }
     return $clazz;
 }
开发者ID:black-silence,项目名称:phan,代码行数:64,代码来源:Clazz.php

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

示例14: getFQSEN

 /**
  * @return FQSEN
  */
 public function getFQSEN() : FullyQualifiedClassName
 {
     // Allow overrides
     if ($this->fqsen) {
         return $this->fqsen;
     }
     return FullyQualifiedClassName::fromStringInContext($this->getName(), $this->getContext());
 }
开发者ID:hslatman,项目名称:phan,代码行数:11,代码来源:Clazz.php

示例15: unserialize

 /**
  * @return void
  */
 public function unserialize($serialized)
 {
     list($file_ref, $serialized) = explode('^', $serialized);
     parent::unserialize($file_ref);
     list($namespace, $class_fqsen, $method_fqsen, $closure_fqsen) = explode('|', $serialized);
     $this->namespace = $namespace;
     $this->class_fqsen = $class_fqsen ? FullyQualifiedClassName::fromFullyQualifiedString($class_fqsen) : null;
     // Determine if we have a method or a function
     if (false === strpos($method_fqsen, '::')) {
         $this->method_fqsen = $method_fqsen ? FullyQualifiedFunctionName::fromFullyQualifiedString($method_fqsen) : null;
     } else {
         $this->method_fqsen = $method_fqsen ? FullyQualifiedMethodName::fromFullyQualifiedString($method_fqsen) : null;
     }
     $this->closure_fqsen = $closure_fqsen ? FullyQualifiedFunctionName::fromFullyQualifiedString($closure_fqsen) : null;
 }
开发者ID:nagyistge,项目名称:phan,代码行数:18,代码来源:Context.php


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