[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8200":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":15,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":16,"starSnapshotCount":16,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},8200,"TypeResolver","phpDocumentor\u002FTypeResolver","phpDocumentor","A PSR-5 based resolver of Class names, Types and Structural Element Names","",null,"PHP",9181,51,9,3,0,1,61.95,"MIT License",false,"2.x",true,[24],"typeresolver","2026-06-12 04:00:38","[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n![](https:\u002F\u002Fgithub.com\u002Fphpdocumentor\u002Ftyperesolver\u002Fworkflows\u002FQa%20workflow\u002Fbadge.svg?branch=1.x)\n[![Coveralls Coverage](https:\u002F\u002Fimg.shields.io\u002Fcoveralls\u002Fgithub\u002FphpDocumentor\u002FTypeResolver.svg)](https:\u002F\u002Fcoveralls.io\u002Fgithub\u002FphpDocumentor\u002FTypeResolver?branch=1.x)\n[![Scrutinizer Code Coverage](https:\u002F\u002Fimg.shields.io\u002Fscrutinizer\u002Fcoverage\u002Fg\u002FphpDocumentor\u002FTypeResolver.svg)](https:\u002F\u002Fscrutinizer-ci.com\u002Fg\u002FphpDocumentor\u002FTypeResolver\u002F?branch=1.x)\n[![Scrutinizer Code Quality](https:\u002F\u002Fimg.shields.io\u002Fscrutinizer\u002Fg\u002FphpDocumentor\u002FTypeResolver.svg)](https:\u002F\u002Fscrutinizer-ci.com\u002Fg\u002FphpDocumentor\u002FTypeResolver\u002F?branch=1.x)\n![Packagist Version](https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fv\u002Fphpdocumentor\u002Ftype-resolver?label=Packagist%20stable)\n![Packagist Version](https:\u002F\u002Fimg.shields.io\u002Fpackagist\u002Fvpre\u002Fphpdocumentor\u002Ftype-resolver?label=Packagist%20unstable)\n\nTypeResolver and FqsenResolver\n==============================\n\nThe specification on types in DocBlocks (PSR-5) describes various keywords and special constructs\nbut also how to statically resolve the partial name of a Class into a Fully Qualified Class Name (FQCN).\n\nPSR-5 also introduces an additional way to describe deeper elements than Classes, Interfaces and Traits \ncalled the Fully Qualified Structural Element Name (FQSEN). Using this it is possible to refer to methods,\nproperties and class constants but also functions and global constants.\n\nThis package provides two Resolvers that are capable of \n\n1. Returning a series of Value Object for given expression while resolving any partial class names, and \n2. Returning an FQSEN object after resolving any partial Structural Element Names into Fully Qualified Structural \n   Element names.\n\n## Installing\n\nThe easiest way to install this library is with [Composer](https:\u002F\u002Fgetcomposer.org) using the following command:\n\n    $ composer require phpdocumentor\u002Ftype-resolver\n\n## Examples\n\nReady to dive in and don't want to read through all that text below? Just consult the [examples](examples) folder and check which type of action that your want to accomplish.\n\n## On Types and Element Names\n\nThis component can be used in one of two ways\n \n1. To resolve a Type or\n2. To resolve a Fully Qualified Structural Element Name\n \nThe big difference between these two is in the number of things it can resolve. \n\nThe TypeResolver can resolve:\n\n- a php primitive or pseudo-primitive such as a string or void (`@var string` or `@return void`).\n- a composite such as an array of string (`@var string[]`).\n- a compound such as a string or integer (`@var string|integer`).\n- an array expression (`@var (string|TypeResolver)[]`)\n- an object or interface such as the TypeResolver class (`@var TypeResolver` \n  or `@var \\phpDocumentor\\Reflection\\TypeResolver`)\n\n  > please note that if you want to pass partial class names that additional steps are necessary, see the \n  > chapter `Resolving partial classes and FQSENs` for more information.\n\nWhere the FqsenResolver can resolve:\n\n- Constant expressions (i.e. `@see \\MyNamespace\\MY_CONSTANT`)\n- Function expressions (i.e. `@see \\MyNamespace\\myFunction()`)\n- Class expressions (i.e. `@see \\MyNamespace\\MyClass`)\n- Interface expressions (i.e. `@see \\MyNamespace\\MyInterface`)\n- Trait expressions (i.e. `@see \\MyNamespace\\MyTrait`)\n- Class constant expressions (i.e. `@see \\MyNamespace\\MyClass::MY_CONSTANT`)\n- Property expressions (i.e. `@see \\MyNamespace\\MyClass::$myProperty`)\n- Method expressions (i.e. `@see \\MyNamespace\\MyClass::myMethod()`)\n\n## Resolving a type\n\nIn order to resolve a type you will have to instantiate the class `\\phpDocumentor\\Reflection\\TypeResolver` and call its `resolve` method like this:\n\n```php\n$typeResolver = new \\phpDocumentor\\Reflection\\TypeResolver();\n$type = $typeResolver->resolve('string|integer');\n```\n\nIn this example you will receive a Value Object of class `\\phpDocumentor\\Reflection\\Types\\Compound` that has two \nelements, one of type `\\phpDocumentor\\Reflection\\Types\\String_` and one of type \n`\\phpDocumentor\\Reflection\\Types\\Integer`.\n\nThe real power of this resolver is in its capability to expand partial class names into fully qualified class names; but in order to do that we need an additional `\\phpDocumentor\\Reflection\\Types\\Context` class that will inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply.\n\n### Resolving nullable types\n\nPhp 7.1 introduced nullable types e.g. `?string`. Type resolver will resolve the original type without the nullable notation `?`\njust like it would do without the `?`. After that the type is wrapped in a `\\phpDocumentor\\Reflection\\Types\\Nullable` object.\nThe `Nullable` type has a method to fetch the actual type. \n\n## Resolving an FQSEN\n\nA Fully Qualified Structural Element Name is a reference to another element in your code bases and can be resolved using the `\\phpDocumentor\\Reflection\\FqsenResolver` class' `resolve` method, like this:\n\n```php\n$fqsenResolver = new \\phpDocumentor\\Reflection\\FqsenResolver();\n$fqsen = $fqsenResolver->resolve('\\phpDocumentor\\Reflection\\FqsenResolver::resolve()');\n```\n\nIn this example we resolve a Fully Qualified Structural Element Name (meaning that it includes the full namespace, class name and element name) and receive a Value Object of type `\\phpDocumentor\\Reflection\\Fqsen`.\n\nThe real power of this resolver is in its capability to expand partial element names into Fully Qualified Structural Element Names; but in order to do that we need an additional `\\phpDocumentor\\Reflection\\Types\\Context` class that will inform the resolver in which namespace the given expression occurs and which namespace aliases (or imports) apply.\n\n## Resolving partial Classes and Structural Element Names\n\nPerhaps the best feature of this library is that it knows how to resolve partial class names into fully qualified class names.\n\nFor example, you have this file:\n\n```php\nnamespace My\\Example;\n\nuse phpDocumentor\\Reflection\\Types;\n\nclass Classy\n{\n    \u002F**\n     * @var Types\\Context\n     * @see Classy::otherFunction()\n     *\u002F\n    public function __construct($context) {}\n    \n    public function otherFunction(){}\n}\n```\n\nSuppose that you would want to resolve (and expand) the type in the `@var` tag and the element name in the `@see` tag.\n\nFor the resolvers to know how to expand partial names you have to provide a bit of _Context_ for them by instantiating a new class named `\\phpDocumentor\\Reflection\\Types\\Context` with the name of the namespace and the aliases that are in play.\n\n### Creating a Context\n\nYou can do this by manually creating a Context like this:\n\n```php\n$context = new \\phpDocumentor\\Reflection\\Types\\Context(\n    '\\My\\Example', \n    [ 'Types' => '\\phpDocumentor\\Reflection\\Types']\n);\n```\n\nOr by using the `\\phpDocumentor\\Reflection\\Types\\ContextFactory` to instantiate a new context based on a Reflector object or by providing the namespace that you'd like to extract and the source code of the file in which the given type expression occurs.\n\n```php\n$contextFactory = new \\phpDocumentor\\Reflection\\Types\\ContextFactory();\n$context = $contextFactory->createFromReflector(new ReflectionMethod('\\My\\Example\\Classy', '__construct'));\n```\n\nor\n\n```php\n$contextFactory = new \\phpDocumentor\\Reflection\\Types\\ContextFactory();\n$context = $contextFactory->createForNamespace('\\My\\Example', file_get_contents('My\u002FExample\u002FClassy.php'));\n```\n\n### Using the Context\n\nAfter you have obtained a Context it is just a matter of passing it along with the `resolve` method of either Resolver class as second argument and the Resolvers will take this into account when resolving partial names.\n\nTo obtain the resolved class name for the `@var` tag in the example above you can do:\n\n```php\n$typeResolver = new \\phpDocumentor\\Reflection\\TypeResolver();\n$type = $typeResolver->resolve('Types\\Context', $context);\n```\n\nWhen you do this you will receive an object of class `\\phpDocumentor\\Reflection\\Types\\Object_` for which you can call the `getFqsen` method to receive a Value Object that represents the complete FQSEN. So that would be `phpDocumentor\\Reflection\\Types\\Context`.\n\n> Why is the FQSEN wrapped in another object `Object_`?\n> \n> The resolve method of the TypeResolver only returns object with the interface `Type` and the FQSEN is a common type that does not represent a Type. Also: in some cases a type can represent an \"Untyped Object\", meaning that it is an object (signified by the `object` keyword) but does not refer to a specific element using an FQSEN.\n\nAnother example is on how to resolve the FQSEN of a method as can be seen with the `@see` tag in the example above. To resolve that you can do the following:\n\n```php\n$fqsenResolver = new \\phpDocumentor\\Reflection\\FqsenResolver();\n$type = $fqsenResolver->resolve('Classy::otherFunction()', $context);\n```\n\nBecause Classy is a Class in the current namespace its FQSEN will have the `My\\Example` namespace and by calling the `resolve` method of the FQSEN Resolver you will receive an `Fqsen` object that refers to `\\My\\Example\\Classy::otherFunction()`.\n","phpDocumentor\u002FTypeResolver 是一个基于 PSR-5 标准的类名、类型及结构元素名称解析器。其核心功能包括解析PHP原始类型或伪原始类型、复合类型、联合类型以及对象或接口，并能够将部分类名转换为完全限定类名（FQCN），同时支持解析完全限定结构元素名称（FQSEN）。该库适用于需要从文档块中提取类型信息并进行静态分析的场景，如代码生成工具、IDE插件开发等。采用MIT许可协议发布，表明了项目的开放性和可重用性。",2,"2026-06-11 03:16:45","top_language"]