Showing preview only (491K chars total). Download the full file or copy to clipboard to get everything.
Repository: phpDocumentor/ReflectionDocBlock
Branch: 6.x
Commit: 7bae67520aa9
Files: 165
Total size: 450.4 KB
Directory structure:
gitextract_rmb768rz/
├── .gitattributes
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ ├── documentation.yml
│ └── integrate.yaml
├── .gitignore
├── .yamllint.yaml
├── LICENSE
├── Makefile
├── README.md
├── composer-require-checker.json
├── composer.json
├── docs/
│ ├── contributing.rst
│ ├── examples/
│ │ ├── 01-interpreting-a-simple-docblock.php
│ │ ├── 02-interpreting-tags.php
│ │ ├── 03-reconstituting-a-docblock.php
│ │ ├── 04-adding-your-own-tag.php
│ │ └── playing-with-descriptions/
│ │ └── 02-escaping.php
│ ├── how-to/
│ │ ├── adding-your-own-tag.rst
│ │ ├── index.rst
│ │ ├── interpreting-a-simple-docblock.rst
│ │ ├── interpreting-tags.rst
│ │ └── reconstituting-a-docblock.rst
│ ├── index.rst
│ ├── installation.rst
│ └── upgrade-to-v6.rst
├── phive.xml
├── phpcs.xml.dist
├── phpdoc.dist.xml
├── phpmd.xml.dist
├── phpstan-baseline.neon
├── phpstan.neon
├── phpunit.xml.dist
├── psalm.xml
├── src/
│ ├── DocBlock/
│ │ ├── Description.php
│ │ ├── DescriptionFactory.php
│ │ ├── ExampleFinder.php
│ │ ├── Serializer.php
│ │ ├── StandardTagFactory.php
│ │ ├── Tag.php
│ │ ├── TagFactory.php
│ │ └── Tags/
│ │ ├── Author.php
│ │ ├── BaseTag.php
│ │ ├── Covers.php
│ │ ├── Deprecated.php
│ │ ├── Example.php
│ │ ├── Extends_.php
│ │ ├── Factory/
│ │ │ ├── AbstractPHPStanFactory.php
│ │ │ ├── ExtendsFactory.php
│ │ │ ├── Factory.php
│ │ │ ├── ImplementsFactory.php
│ │ │ ├── MethodFactory.php
│ │ │ ├── MethodParameterFactory.php
│ │ │ ├── MixinFactory.php
│ │ │ ├── PHPStanFactory.php
│ │ │ ├── ParamFactory.php
│ │ │ ├── PropertyFactory.php
│ │ │ ├── PropertyReadFactory.php
│ │ │ ├── PropertyWriteFactory.php
│ │ │ ├── ReturnFactory.php
│ │ │ ├── TemplateCovariantFactory.php
│ │ │ ├── TemplateFactory.php
│ │ │ ├── ThrowsFactory.php
│ │ │ └── VarFactory.php
│ │ ├── Formatter/
│ │ │ ├── AlignFormatter.php
│ │ │ └── PassthroughFormatter.php
│ │ ├── Formatter.php
│ │ ├── Generic.php
│ │ ├── Implements_.php
│ │ ├── InvalidTag.php
│ │ ├── Link.php
│ │ ├── Method.php
│ │ ├── MethodParameter.php
│ │ ├── Mixin.php
│ │ ├── Param.php
│ │ ├── Property.php
│ │ ├── PropertyRead.php
│ │ ├── PropertyWrite.php
│ │ ├── Reference/
│ │ │ ├── Fqsen.php
│ │ │ ├── Reference.php
│ │ │ └── Url.php
│ │ ├── Return_.php
│ │ ├── See.php
│ │ ├── Since.php
│ │ ├── Source.php
│ │ ├── TagWithType.php
│ │ ├── Template.php
│ │ ├── TemplateCovariant.php
│ │ ├── TemplateExtends.php
│ │ ├── TemplateImplements.php
│ │ ├── Throws.php
│ │ ├── Uses.php
│ │ ├── Var_.php
│ │ └── Version.php
│ ├── DocBlock.php
│ ├── DocBlockFactory.php
│ ├── DocBlockFactoryInterface.php
│ ├── Exception/
│ │ ├── CannotCreateTag.php
│ │ ├── ParserException.php
│ │ ├── PcreException.php
│ │ └── ReflectionDocblockException.php
│ └── Utils.php
└── tests/
├── coverage-checker.php
├── integration/
│ ├── DocblockSeeTagResolvingTest.php
│ ├── DocblocksWithAnnotationsTest.php
│ ├── InterpretingDocBlocksTest.php
│ ├── ModifyBackTraceSafeTest.php
│ ├── ReconstitutingADocBlockTest.php
│ ├── TypedTagsTest.php
│ └── UsingTagsTest.php
└── unit/
├── Assets/
│ ├── CustomParam.php
│ ├── CustomServiceClass.php
│ ├── CustomServiceInterface.php
│ └── CustomTagFactory.php
├── DocBlock/
│ ├── DescriptionFactoryTest.php
│ ├── DescriptionTest.php
│ ├── ExampleFinderTest.php
│ ├── SerializerTest.php
│ ├── StandardTagFactoryTest.php
│ └── Tags/
│ ├── AuthorTest.php
│ ├── CoversTest.php
│ ├── DeprecatedTest.php
│ ├── ExampleTest.php
│ ├── ExtendsTest.php
│ ├── Factory/
│ │ ├── AbstractPHPStanFactoryTest.php
│ │ ├── ExtendsFactoryTest.php
│ │ ├── ImplementsFactoryTest.php
│ │ ├── MethodFactoryTest.php
│ │ ├── MixinFactoryTest.php
│ │ ├── ParamFactoryTest.php
│ │ ├── PropertyFactoryTest.php
│ │ ├── PropertyReadFactoryTest.php
│ │ ├── PropertyWriteFactoryTest.php
│ │ ├── ReturnFactoryTest.php
│ │ ├── TagFactoryTestCase.php
│ │ ├── TemplateCovariantFactoryTest.php
│ │ ├── TemplateFactoryTest.php
│ │ ├── ThrowsFactoryTest.php
│ │ └── VarFactoryTest.php
│ ├── Formatter/
│ │ ├── AlignFormatterTest.php
│ │ └── PassthroughFormatterTest.php
│ ├── GenericTest.php
│ ├── ImplementsTest.php
│ ├── InvalidTagTest.php
│ ├── LinkTest.php
│ ├── MethodParameterTest.php
│ ├── MethodTest.php
│ ├── ParamTest.php
│ ├── PropertyReadTest.php
│ ├── PropertyTest.php
│ ├── PropertyWriteTest.php
│ ├── ReturnTest.php
│ ├── SeeTest.php
│ ├── SinceTest.php
│ ├── SourceTest.php
│ ├── TemplateExtendsTest.php
│ ├── TemplateImplementsTest.php
│ ├── TemplateTest.php
│ ├── ThrowsTest.php
│ ├── UsesTest.php
│ ├── VarTest.php
│ └── VersionTest.php
├── DocBlockFactoryTest.php
├── DocBlockTest.php
├── Exception/
│ └── PcreExceptionTest.php
└── PregSplitTest.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
/.gitattributes export-ignore
/.gitignore export-ignore
/.yamllint.yaml export-ignore
/composer-require-checker.json export-ignore
/composer.lock export-ignore
/phpmd.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/Makefile export-ignore
/phive.xml export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
/psalm.xml export-ignore
/phpdoc.dist.xml export-ignore
/tests/ export-ignore
/docs/ export-ignore
/.github/ export-ignore
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
================================================
FILE: .github/workflows/documentation.yml
================================================
# https://docs.github.com/en/actions
name: "Documentation"
on: # yamllint disable-line rule:truthy
push:
branches:
- "6.x"
workflow_dispatch: null
jobs:
run:
name: "Documentation"
uses: "phpDocumentor/.github/.github/workflows/documentation.yml@main"
with:
deploy: true
component: "reflection-docblock"
secrets:
token: "${{ secrets.BOT_TOKEN }}"
================================================
FILE: .github/workflows/integrate.yaml
================================================
# https://docs.github.com/en/actions
name: "Integrate"
on: # yamllint disable-line rule:truthy
push:
branches:
- "6.x"
pull_request: null
# Allow manually triggering the workflow.
workflow_dispatch: null
jobs:
code-coverage:
name: "Code Coverage"
uses: "phpDocumentor/.github/.github/workflows/code-coverage.yml@v0.9"
with:
composer-root-version: "6.x-dev"
coding-standards:
name: "Coding Standards"
uses: "phpDocumentor/.github/.github/workflows/coding-standards.yml@v0.9"
with:
composer-root-version: "6.x-dev"
dependency-analysis:
name: "Dependency analysis"
uses: "phpDocumentor/.github/.github/workflows/dependency-analysis.yml@v0.9"
with:
composer-root-version: "6.x-dev"
lint-root:
name: "Lint root"
uses: "phpDocumentor/.github/.github/workflows/lint.yml@v0.9"
with:
composer-options: "--no-check-publish --ansi"
static-analysis:
name: "Static analysis"
uses: "phpDocumentor/.github/.github/workflows/static-analysis.yml@v0.9"
with:
php-extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter, fileinfo, pcntl, posix"
composer-root-version: "6.x-dev"
unit-tests:
name: "Unit test"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.9"
with:
composer-root-version: "6.x-dev"
upcoming-releases: true
integration-tests:
name: "Integration test"
uses: "phpDocumentor/.github/.github/workflows/continuous-integration.yml@v0.9"
with:
composer-root-version: "6.x-dev"
upcoming-releases: true
test-suite: "integration"
================================================
FILE: .gitignore
================================================
# IDE Shizzle; it is recommended to use a global .gitignore for this but since this is an OSS project we want to make
# it easy to contribute
.idea
/nbproject/private/
.buildpath
.project
.settings
# Build folder and vendor folder are generated code; no need to version this
build/
temp/
tools/
vendor/
*.phar
# By default the phpunit.xml.dist is provided; you can override this using a local config file
phpunit.xml
.phpunit.result.cache
.phpdoc
================================================
FILE: .yamllint.yaml
================================================
extends: "default"
ignore: |
.build/
.notes/
vendor/
rules:
braces:
max-spaces-inside-empty: 0
max-spaces-inside: 1
min-spaces-inside-empty: 0
min-spaces-inside: 1
brackets:
max-spaces-inside-empty: 0
max-spaces-inside: 0
min-spaces-inside-empty: 0
min-spaces-inside: 0
colons:
max-spaces-after: 1
max-spaces-before: 0
commas:
max-spaces-after: 1
max-spaces-before: 0
min-spaces-after: 1
comments:
ignore-shebangs: true
min-spaces-from-content: 1
require-starting-space: true
comments-indentation: "enable"
document-end:
present: false
document-start:
present: false
indentation:
check-multi-line-strings: false
indent-sequences: true
spaces: 2
empty-lines:
max-end: 0
max-start: 0
max: 1
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
hyphens:
max-spaces-after: 2
key-duplicates: "enable"
key-ordering: "disable"
line-length: "disable"
new-line-at-end-of-file: "enable"
new-lines:
type: "unix"
octal-values:
forbid-implicit-octal: true
quoted-strings:
quote-type: "double"
trailing-spaces: "enable"
truthy:
allowed-values:
- "false"
- "true"
yaml-files:
- "*.yaml"
- "*.yml"
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2010 Mike van Riel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Makefile
================================================
.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: code-style
code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest -d memory_limit=1024M -s
.PHONY: fix-code-style
fix-code-style:
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpcs-ga:latest phpcbf
.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon --memory-limit=1024M
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/psalm.phar
.PHONY: test
test: test-unit ## Runs all test suites with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit
.PHONY: test-unit
test-unit: ## Runs unit tests with phpunit/phpunit
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpunit --testsuite=unit
.PHONY: dependency-analysis
dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 .phive/composer-require-checker check --config-file=/opt/project/composer-require-checker.json
vendor: composer.json composer.lock
composer validate --no-check-publish
composer install --no-interaction --no-progress
.PHONY: benchmark
benchmark:
docker run -it --rm -v${CURDIR}:/opt/project -w /opt/project php:7.4-cli tools/phpbench run
.PHONY: rector
rector: ## Refactor code using rector
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/rector process
.PHONY: pre-commit-test
pre-commit-test: fix-code-style test code-style static-code-analysis
.PHONY: docs
docs: ## Generate documentation with phpDocumentor
docker run -it --rm -v${PWD}:/opt/project -w /opt/project phpdoc/phpdoc:3
================================================
FILE: README.md
================================================
[](https://opensource.org/licenses/MIT)
[](https://github.com/phpDocumentor/ReflectionDocBlock/actions/workflows/integrate.yaml)
[](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionDocBlock/?branch=master)
[](https://scrutinizer-ci.com/g/phpDocumentor/ReflectionDocBlock/?branch=master)
[](https://packagist.org/packages/phpdocumentor/reflection-docblock)
[](https://packagist.org/packages/phpdocumentor/reflection-docblock)
ReflectionDocBlock
==================
Introduction
------------
The ReflectionDocBlock component of phpDocumentor provides a DocBlock parser
that is 100% compatible with the [PHPDoc standard](http://phpdoc.org/docs/latest).
With this component, a library can provide support for annotations via DocBlocks
or otherwise retrieve information that is embedded in a DocBlock.
Installation
------------
```bash
composer require phpdocumentor/reflection-docblock
```
Usage
-----
In order to parse the DocBlock one needs a DocBlockFactory that can be
instantiated using its `createInstance` factory method like this:
```php
$factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
```
Then we can use the `create` method of the factory to interpret the DocBlock.
Please note that it is also possible to provide a class that has the
`getDocComment()` method, such as an object of type `ReflectionClass`, the
create method will read that if it exists.
```php
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* This is a Description. A Summary and Description are separated by either
* two subsequent newlines (thus a whiteline in between as can be seen in this
* example), or when the Summary ends with a dot (`.`) and some form of
* whitespace.
*/
DOCCOMMENT;
$docblock = $factory->create($docComment);
```
The `create` method will yield an object of type `\phpDocumentor\Reflection\DocBlock`
whose methods can be queried:
```php
// Contains the summary for this DocBlock
$summary = $docblock->getSummary();
// Contains \phpDocumentor\Reflection\DocBlock\Description object
$description = $docblock->getDescription();
// You can either cast it to string
$description = (string) $docblock->getDescription();
// Or use the render method to get a string representation of the Description.
$description = $docblock->getDescription()->render();
```
> For more examples it would be best to review the scripts in the [`/docs/examples` folder](/docs/examples).
================================================
FILE: composer-require-checker.json
================================================
{
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor",
"PHPStan\\PhpDocParser\\ParserConfig"
],
"php-core-extensions" : [
"Core",
"pcre",
"Reflection",
"tokenizer",
"SPL",
"standard"
]
}
================================================
FILE: composer.json
================================================
{
"name": "phpdocumentor/reflection-docblock",
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
},
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"require": {
"php": "^7.4 || ^8.0",
"phpdocumentor/type-resolver": "^2.0",
"webmozart/assert": "^1.9.1 || ^2",
"phpdocumentor/reflection-common": "^2.2",
"ext-filter": "*",
"phpstan/phpdoc-parser": "^2.0",
"doctrine/deprecations": "^1.1"
},
"require-dev": {
"mockery/mockery": "~1.3.5 || ~1.6.0",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-webmozart-assert": "^1.2",
"psalm/phar": "^5.26",
"shipmonk/dead-code-detector": "^0.5.1"
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"phpDocumentor\\Reflection\\": ["tests/unit", "tests/integration"]
}
},
"config": {
"platform": {
"php":"7.4.0"
},
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "5.x-dev"
}
}
}
================================================
FILE: docs/contributing.rst
================================================
Contributing
============
Contributions are welcome! If you would like to contribute to ReflectionDocBlock, please follow these guidelines:
- Fork the repository and create your branch from ``main``.
- Ensure your code follows the project's coding standards.
- Write tests for your changes.
- Submit a pull request with a clear description of your changes.
For questions or discussions, please open an issue on GitHub.
================================================
FILE: docs/examples/01-interpreting-a-simple-docblock.php
================================================
<?php
require_once(__DIR__ . '/../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* This is a Description. A Summary and Description are separated by either
* two subsequent newlines (thus a whiteline in between as can be seen in this
* example), or when the Summary ends with a dot (`.`) and some form of
* whitespace.
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Should contain the first line of the DocBlock
$summary = $docblock->getSummary();
// Contains an object of type Description; you can either cast it to string or use
// the render method to get a string representation of the Description.
//
// In subsequent examples we will be fiddling a bit more with the Description.
$description = $docblock->getDescription();
================================================
FILE: docs/examples/02-interpreting-tags.php
================================================
<?php
require_once(__DIR__ . '/../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// You can check if a DocBlock has one or more see tags
$hasSeeTag = $docblock->hasTag('see');
// Or we can get a complete list of all tags
$tags = $docblock->getTags();
// But we can also grab all tags of a specific type, such as `see`
$seeTags = $docblock->getTagsByName('see');
================================================
FILE: docs/examples/03-reconstituting-a-docblock.php
================================================
<?php
require_once(__DIR__ . '/../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlock\Serializer;
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* And here is an example of the description
* of a DocBlock that can span multiple lines.
*
* @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Create the serializer that will reconstitute the DocBlock back to its original form.
$serializer = new Serializer(0, '', true, null, null, PHP_EOL);
// Reconstitution is performed by the `getDocComment()` method.
$reconstitutedDocComment = $serializer->getDocComment($docblock);
================================================
FILE: docs/examples/04-adding-your-own-tag.php
================================================
<?php
/**
* In this example we demonstrate how you can add your own Tag using a Static Factory method in your Tag class.
*/
require_once(__DIR__ . '/../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlock\Serializer;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\BaseTag;
use phpDocumentor\Reflection\Types\Context;
use Webmozart\Assert\Assert;
/**
* An example of a custom tag called `my-tag` with an optional description.
*
* A Custom Tag is a class that can consist of two parts:
*
* 1. a method `create` that is a static factory for this class.
* 2. methods and properties that have this object act as an immutable Value Object representing a Tag instance.
*
* The static factory `create` is used to convert a tag line (without the tag name) into an instance of the
* same tag object with the right constructor parameters set. This method has a dynamic list of parameters so that you
* can inject various dependencies, see the method's DocBlock for more information.
*
* An object of this class, and its methods and properties, represent a single instance of that tag in your
* documentation in the form of a Value Object whose properties should not be changed after instantiation (it should be
* immutable).
*
* > Important: Tag classes that act as Factories using the `create` method should implement the Tag interface.
* > Instead, you could extend the abstract class BaseTag that already implements the Tag interface
*/
final class MyTag extends BaseTag
{
/**
* A required property that is used by Formatters to reconstitute the complete tag line.
*
* @see Formatter
*
* @var string
*/
protected string $name = 'my-tag';
/**
* The constructor for this Tag; this should contain all properties for this object.
*
* @param Description $description An example of how to add a Description to the tag; the Description is often
* an optional variable so passing null is allowed in this instance (though you can
* also construct an empty description object).
*
* @see BaseTag for the declaration of the description property and getDescription method.
*/
public function __construct(?Description $description = null)
{
$this->description = $description;
}
/**
* A static Factory that creates a new instance of the current Tag.
*
* In this example the MyTag tag can be created by passing a description text as $body. Because we have added
* a $descriptionFactory that is type-hinted as DescriptionFactory we can now construct a new Description object
* and pass that to the constructor.
*
* > You could directly instantiate a Description object here but that won't be parsed for inline tags and Types
* > won't be resolved. The DescriptionFactory will take care of those actions.
*
* The `create` method's interface states that this method only features a single parameter (`$body`) but the
* {@see TagFactory} will read the signature of this method and if it has more parameters then it will try
* to find declarations for it in the ServiceLocator of the TagFactory (see {@see TagFactory::$serviceLocator}).
*
* > Important: all properties following the `$body` should default to `null`, otherwise PHP will error because
* > it no longer matches the interface. This is why you often see the default tags check that an optional argument
* > is not null nonetheless.
*
* @param string $body
* @param DescriptionFactory $descriptionFactory
* @param Context|null $context The Context is used to resolve Types and FQSENs, although optional
* it is highly recommended to pass it. If you omit it then it is assumed that
* the DocBlock is in the global namespace and has no `use` statements.
*
* @see Tag for the interface declaration of the `create` method.
* @see Tag::create() for more information on this method's workings.
*/
public static function create(string $body, ?DescriptionFactory $descriptionFactory = null, ?Context $context = null): self
{
Assert::notNull($descriptionFactory);
return new static($descriptionFactory->create($body, $context));
}
/**
* Returns a rendition of the original tag line.
*
* This method is used to reconstitute a DocBlock into its original form by the {@see Serializer}. It should
* feature all parts of the tag so that the serializer can put it back together.
*/
public function __toString(): string
{
return (string)$this->description;
}
}
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* @my-tag I have a description
*/
DOCCOMMENT;
// Make a mapping between the tag name `my-tag` and the Tag class containing the Factory Method `create`.
$customTags = ['my-tag' => MyTag::class];
// Do pass the list of custom tags to the Factory for the DocBlockFactory.
$factory = DocBlockFactory::createInstance($customTags);
// You can also add Tags later using `$factory->registerTagHandler()` with a tag name and Tag class name.
// Create the DocBlock
$docblock = $factory->create($docComment);
// Take a look: the $customTagObjects now contain an array with your newly added tag
$customTagObjects = $docblock->getTagsByName('my-tag');
// As an experiment: let's reconstitute the DocBlock and observe that because we added a __toString() method
// to the tag class that we can now also see it.
$serializer = new Serializer(0, '',true, null, null, PHP_EOL);
$reconstitutedDocComment = $serializer->getDocComment($docblock);
================================================
FILE: docs/examples/playing-with-descriptions/02-escaping.php
================================================
<?php
require_once(__DIR__ . '/../../../vendor/autoload.php');
use phpDocumentor\Reflection\DocBlockFactory;
$docComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
* inline tag by adding an opening brace in front of it like this: {}.
*
* Here are example texts where you can see how they could be used in a real life situation:
*
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
* Or an {@internal inline tag with a literal {{@}link{} in it}.
*
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
*/
DOCCOMMENT;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);
// Escaping is automatic so this happens in the DescriptionFactory.
$description = $docblock->getDescription();
// This is the rendition that we will receive of the Description.
$receivedDocComment = <<<DOCCOMMENT
/**
* This is an example of a summary.
*
* You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
* inline tag by adding an opening brace in front of it like this: {}.
*
* Here are example texts where you can see how they could be used in a real life situation:
*
* This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
* Or an {@internal inline tag with a literal {{@}link{} in it}.
*
* Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
*/
DOCCOMMENT;
// Render it using the default PassthroughFormatter
$foundDescription = $description->render();
================================================
FILE: docs/how-to/adding-your-own-tag.rst
================================================
Add Your Own Tag
=======================
This guide demonstrates how to add your own custom tag to a DocBlock using ReflectionDocBlock.
.. literalinclude:: ../examples/04-adding-your-own-tag.php
:language: php
:linenos:
================================================
FILE: docs/how-to/index.rst
================================================
How-to
=============
Practical guides for common tasks with ReflectionDocBlock:
.. toctree::
:maxdepth: 1
interpreting-a-simple-docblock
interpreting-tags
reconstituting-a-docblock
adding-your-own-tag
================================================
FILE: docs/how-to/interpreting-a-simple-docblock.rst
================================================
Interpret a Simple DocBlock
==================================
This guide demonstrates how to parse a simple DocBlock and extract its summary and description using ReflectionDocBlock.
.. literalinclude:: ../examples/01-interpreting-a-simple-docblock.php
:language: php
:linenos:
================================================
FILE: docs/how-to/interpreting-tags.rst
================================================
Interpret Tags in a DocBlock
===================================
This guide demonstrates how to interpret tags within a DocBlock using ReflectionDocBlock.
.. literalinclude:: ../examples/02-interpreting-tags.php
:language: php
:linenos:
================================================
FILE: docs/how-to/reconstituting-a-docblock.rst
================================================
Reconstituting a DocBlock
=========================
ReflectionDocBlock not only allows you to read and parse DocBlocks, but also to reconstruct them. This is useful if you need to add, remove, or modify tags in your codebase programmatically. For example, you might want to update type information, add custom tags, or strip deprecated tags as part of a refactoring or code generation process.
Below is a practical example of how to reconstitute a DocBlock using this library:
.. literalinclude:: ../examples/03-reconstituting-a-docblock.php
:language: php
:caption: examples/03-reconstituting-a-docblock.php
================================================
FILE: docs/index.rst
================================================
ReflectionDocBlock Documentation
===========================================
ReflectionDocBlock is a PHP library that provides a DocBlock parser fully compatible with the PHPDoc standard. It allows you to parse, interpret, and extract information from DocBlocks in your PHP code, enabling support for annotations and metadata extraction.
Key Features and Use Cases
--------------------------
- **Documentation Generation**: Used as a core component in tools like phpDocumentor to generate API documentation from your code's DocBlocks.
- **Type and Metadata Extraction**: Integrations and tools use this library to gather type information and other metadata, enabling advanced features such as static analysis, code introspection, and automated serialization.
- **Serializer Support**: Helps serializers and similar tools to interpret type information in array and object structures, making it easier to transform nested objects correctly.
- **DocBlock Reconstitution**: Not only can you read DocBlocks, but you can also reconstruct them. This is useful for adding, removing, or modifying tags in your codebase programmatically.
- **Standalone or Integrated**: Designed for standalone use, but also serves as a key component of the phpDocumentor suite.
Unique Advantages
-----------------
- **Simple, Intuitive API**: Focus on ease of use, so you can work with DocBlocks without needing to understand the complexities of parsing.
- **Widely Adopted**: Used by over 1000 packages on Packagist, making it a proven and reliable choice for PHP developers.
- **Actively Maintained**: Supports PHP 7.4 and 8+, and is maintained by the phpDocumentor team and contributors.
Quick Start Example
-------------------
Here's a minimal example of how to use ReflectionDocBlock in your project:
.. literalinclude:: examples/01-interpreting-a-simple-docblock.php
:language: php
:caption: examples/01-interpreting-a-simple-docblock.php
For more detailed usage and how-to guides, see the ``how-to/`` section.
.. toctree::
:maxdepth: 2
:hidden:
installation
how-to/index
upgrade-to-v6
contributing
================================================
FILE: docs/installation.rst
================================================
Installation
============
To install ReflectionDocBlock, use Composer:
.. code-block:: bash
composer require phpdocumentor/reflection-docblock
================================================
FILE: docs/upgrade-to-v6.rst
================================================
Upgrade Guide to v6
===================
This guide helps you upgrade your project to ReflectionDocBlock v6. It covers breaking changes, removals, new features, and migration tips to ensure a smooth transition.
Supported PHP Versions
----------------------
- v6 requires PHP 7.4 or higher (PHP 8+ recommended).
Breaking Changes & Removals
---------------------------
- **Removal of `::create` static method for type-based tags**
- The `create` static method has been removed from tag classes that represent type definitions, such as `@param` and `@return` tags. Most users will not be affected, as these methods are rarely used directly. The deprecation notice for these methods was present throughout v5.
- **Migration:**
- If you are instantiating these tag objects directly, use the tag factory or the recommended construction pattern instead.
- Before:
.. code-block:: php
$tag = Param::create($body);
- After:
.. code-block:: php
$factory = \phpDocumentor\Reflection\DocBlock\Tags\Factory\StandardTagFactory::createInstance();
$tag = $factory->create('@param int $foo');
- **StandardTagFactory instantiation**
- `StandardTagFactory` must now be created via `createInstance()`.
- **Migration:**
- Before:
.. code-block:: php
$factory = new StandardTagFactory();
- After:
.. code-block:: php
$factory = StandardTagFactory::createInstance();
- **Removed methods**
- `Method::getArguments` has been removed.
- `Method::create` has been removed.
- **Migration:**
- Refactor code to use the new API for method arguments and creation.
TypeResolver Upgrade
-------------------
- **Generics Support**: The TypeResolver component now supports generics,
which replaces the previous `Collection` type handling. This allows
for more accurate and expressive type definitions, such as `MyClass<int, MyClass>` or `Collection<MyClass>`,
and improves compatibility with modern PHPDoc standards.
- For more details and advanced migration scenarios, consult the `TypeResolver upgrade guide <https://docs.phpdoc.org/components/type-resolver/guides/upgrade-v1-to-v2.html#upgrade-to-version-2>`_
================================================
FILE: phive.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^9.5" installed="9.5.8" location="./tools/phpunit" copy="true"/>
</phive>
================================================
FILE: phpcs.xml.dist
================================================
<?xml version="1.0"?>
<ruleset name="ReflectionDocBlock">
<description>The coding standard for this library.</description>
<file>src</file>
<file>tests/unit</file>
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest\.php</exclude-pattern>
<exclude-pattern>*/tests/unit/Assets/*</exclude-pattern>
<arg value="p"/>
<!-- Set the minimum PHP version for PHPCompatibility.
This should be kept in sync with the requirements in the composer.json file. -->
<config name="testVersion" value="7.4-"/>
<rule ref="phpDocumentor">
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException" />
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
<exclude-pattern>*/src/*/Abstract*\.php</exclude-pattern>
</rule>
</ruleset>
================================================
FILE: phpdoc.dist.xml
================================================
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
configVersion="3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.phpdoc.org"
xsi:noNamespaceSchemaLocation="data/xsd/phpdoc.xsd"
>
<title>Reflection Docblock</title>
<paths>
<output>build/docs</output>
</paths>
<version number="6.0.0">
<folder>latest</folder>
<api>
<source dsn="./">
<path>src/</path>
</source>
<output>api</output>
<ignore hidden="true" symlinks="true">
<path>tests/**/*</path>
<path>build/**/*</path>
<path>var/**/*</path>
<path>vendor/**/*</path>
</ignore>
<extensions>
<extension>php</extension>
</extensions>
<ignore-tags>
<ignore-tag>template</ignore-tag>
<ignore-tag>template-extends</ignore-tag>
<ignore-tag>template-implements</ignore-tag>
<ignore-tag>extends</ignore-tag>
<ignore-tag>implements</ignore-tag>
</ignore-tags>
<default-package-name>phpDocumentor</default-package-name>
</api>
<guide>
<source dsn=".">
<path>docs</path>
</source>
<output>guides</output>
</guide>
</version>
<setting name="guides.enabled" value="true"/>
<template name="default" />
</phpdocumentor>
================================================
FILE: phpmd.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset
name="ProxyManager rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/design.xml">
<!-- eval is needed to generate runtime classes -->
<exclude name="EvalExpression"/>
</rule>
<rule ref="rulesets/naming.xml">
<exclude name="LongVariable"/>
</rule>
<rule ref="rulesets/naming.xml/LongVariable">
<properties>
<property name="minimum">40</property>
</properties>
</rule>
</ruleset>
================================================
FILE: phpstan-baseline.neon
================================================
parameters:
ignoreErrors:
-
message: "#^Unused phpDocumentor\\\\Reflection\\\\DocBlock\\\\ExampleFinder\\:\\:getExampleDirectories$#"
count: 1
path: src/DocBlock/ExampleFinder.php
-
message: "#^Unused phpDocumentor\\\\Reflection\\\\DocBlock\\\\ExampleFinder\\:\\:setExampleDirectories$#"
count: 1
path: src/DocBlock/ExampleFinder.php
-
message: "#^Unused phpDocumentor\\\\Reflection\\\\DocBlock\\\\ExampleFinder\\:\\:setSourceDirectory$#"
count: 1
path: src/DocBlock/ExampleFinder.php
-
message: "#^Unused phpDocumentor\\\\Reflection\\\\DocBlock\\\\Tags\\\\Factory\\\\MethodParameterFactory\\:\\:formatNull$#"
count: 1
path: src/DocBlock/Tags/Factory/MethodParameterFactory.php
================================================
FILE: phpstan.neon
================================================
includes:
- phpstan-baseline.neon
parameters:
level: max
ignoreErrors:
- '#Method phpDocumentor\\Reflection\\DocBlock\\StandardTagFactory::createTag\(\) should return phpDocumentor\\Reflection\\DocBlock\\Tag but returns mixed#'
- '#Offset 2 on array\{string, 28, int\} on left side of \?\? always exists and is not nullable\.#'
-
path: src/DocBlockFactoryInterface.php
identifier: shipmonk.deadMethod
-
path: src/DocBlock/TagFactory.php
identifier: shipmonk.deadMethod
paths:
- src
- tests/unit
================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" convertDeprecationsToExceptions="false" beStrictAboutOutputDuringTests="false" forceCoversAnnotation="true" verbose="true" bootstrap="vendor/autoload.php">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
</report>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="integration">
<directory>./tests/integration</directory>
</testsuite>
</testsuites>
<logging/>
<listeners>
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php"/>
</listeners>
</phpunit>
================================================
FILE: psalm.xml
================================================
<?xml version="1.0"?>
<psalm
errorLevel="2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config file:///composer/vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<RedundantConditionGivenDocblockType>
<errorLevel type="info">
<!-- Psalm is very strict and believe that because we documented a type, it is redundant to assert it -->
<file name="src/DocBlock/StandardTagFactory.php"/>
</errorLevel>
</RedundantConditionGivenDocblockType>
<PossiblyNullArrayOffset>
<errorLevel type="info">
<!-- Psalm forbid accessing an array with a null offset but it's still working code without notice -->
<file name="src/DocBlock/StandardTagFactory.php"/>
</errorLevel>
</PossiblyNullArrayOffset>
<DeprecatedInterface>
<errorLevel type="info">
<!-- Will be removed in 6.0.0 issues/211 -->
<referencedClass name="phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod"/>
</errorLevel>
</DeprecatedInterface>
<DeprecatedMethod>
<errorLevel type="info">
<!-- Will be removed in 6.0.0 issues/361 -->
<referencedMethod name="phpDocumentor\Reflection\DocBlock\Tags\Param::create"/>
</errorLevel>
</DeprecatedMethod>
<NoInterfaceProperties>
<errorLevel type="info">
<file name="src/DocBlock/Tags/Factory/ParamFactory.php"/>
<file name="src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php"/>
</errorLevel>
</NoInterfaceProperties>
<TooManyArguments>
<errorLevel type="info">
<file name="src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php"/>
</errorLevel>
</TooManyArguments>
<RedundantConditionGivenDocblockType>
<errorLevel type="info">
<!-- Psalm manage to infer a more precise type than PHPStan. notNull assert is needed for PHPStan but
Psalm sees it as redundant -->
<directory name="src/DocBlock/Tags/"/>
</errorLevel>
</RedundantConditionGivenDocblockType>
<ArgumentTypeCoercion>
<errorLevel type="info">
<!-- PHP handles invalid preg_split flags just fine. -->
<file name="src/Utils.php"/>
</errorLevel>
</ArgumentTypeCoercion>
<InvalidArgument>
<errorLevel type="suppress">
<referencedFunction name="PHPStan\PhpDocParser\Parser\PhpDocParser::__construct"/>
<referencedFunction name="PHPStan\PhpDocParser\Parser\TypeParser::__construct"/>
</errorLevel>
</InvalidArgument>
</issueHandlers>
</psalm>
================================================
FILE: src/DocBlock/Description.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
use function vsprintf;
/**
* Object representing to description for a DocBlock.
*
* A Description object can consist of plain text but can also include tags. A Description Formatter can then combine
* a body template with sprintf-style placeholders together with formatted tags in order to reconstitute a complete
* description text using the format that you would prefer.
*
* Because parsing a Description text can be a verbose process this is handled by the {@see DescriptionFactory}. It is
* thus recommended to use that to create a Description object, like this:
*
* $description = $descriptionFactory->create('This is a {@see Description}', $context);
*
* The description factory will interpret the given body and create a body template and list of tags from them, and pass
* that onto the constructor if this class.
*
* > The $context variable is a class of type {@see \phpDocumentor\Reflection\Types\Context} and contains the namespace
* > and the namespace aliases that apply to this DocBlock. These are used by the Factory to resolve and expand partial
* > type names and FQSENs.
*
* If you do not want to use the DescriptionFactory you can pass a body template and tag listing like this:
*
* $description = new Description(
* 'This is a %1$s',
* [ new See(new Fqsen('\phpDocumentor\Reflection\DocBlock\Description')) ]
* );
*
* It is generally recommended to use the Factory as that will also apply escaping rules, while the Description object
* is mainly responsible for rendering.
*
* @see DescriptionFactory to create a new Description.
* @see Tags\Formatter for the formatting of the body and tags.
*/
class Description
{
private string $bodyTemplate;
/** @var Tag[] */
private array $tags;
/**
* Initializes a Description with its body (template) and a listing of the tags used in the body template.
*
* @param Tag[] $tags
*/
public function __construct(string $bodyTemplate, array $tags = [])
{
$this->bodyTemplate = $bodyTemplate;
$this->tags = $tags;
}
/**
* Returns the body template.
*/
public function getBodyTemplate(): string
{
return $this->bodyTemplate;
}
/**
* Returns the tags for this DocBlock.
*
* @return Tag[]
*/
public function getTags(): array
{
return $this->tags;
}
/**
* Renders this description as a string where the provided formatter will format the tags in the expected string
* format.
*/
public function render(?Formatter $formatter = null): string
{
if ($this->tags === []) {
return vsprintf($this->bodyTemplate, []);
}
if ($formatter === null) {
$formatter = new PassthroughFormatter();
}
$tags = [];
foreach ($this->tags as $tag) {
$tags[] = '{' . $formatter->format($tag) . '}';
}
return vsprintf($this->bodyTemplate, $tags);
}
/**
* Returns a plain string representation of this description.
*/
public function __toString(): string
{
return $this->render();
}
}
================================================
FILE: src/DocBlock/DescriptionFactory.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\Utils;
use function count;
use function implode;
use function ltrim;
use function min;
use function str_replace;
use function strlen;
use function strpos;
use function substr;
use function trim;
use const PREG_SPLIT_DELIM_CAPTURE;
/**
* Creates a new Description object given a body of text.
*
* Descriptions in phpDocumentor are somewhat complex entities as they can contain one or more tags inside their
* body that can be replaced with a readable output. The replacing is done by passing a Formatter object to the
* Description object's `render` method.
*
* In addition to the above does a Description support two types of escape sequences:
*
* 1. `{@}` to escape the `@` character to prevent it from being interpreted as part of a tag, i.e. `{{@}link}`
* 2. `{}` to escape the `}` character, this can be used if you want to use the `}` character in the description
* of an inline tag.
*
* If a body consists of multiple lines then this factory will also remove any superfluous whitespace at the beginning
* of each line while maintaining any indentation that is used. This will prevent formatting parsers from tripping
* over unexpected spaces as can be observed with tag descriptions.
*/
class DescriptionFactory
{
private Factory $tagFactory;
/**
* Initializes this factory with the means to construct (inline) tags.
*/
public function __construct(Factory $tagFactory)
{
$this->tagFactory = $tagFactory;
}
/**
* Returns the parsed text of this description.
*/
public function create(string $contents, ?TypeContext $context = null): Description
{
$tokens = $this->lex($contents);
$count = count($tokens);
$tagCount = 0;
$tags = [];
for ($i = 1; $i < $count; $i += 2) {
$tags[] = $this->tagFactory->create($tokens[$i], $context);
$tokens[$i] = '%' . ++$tagCount . '$s';
}
//In order to allow "literal" inline tags, the otherwise invalid
//sequence "{@}" is changed to "@", and "{}" is changed to "}".
//"%" is escaped to "%%" because of vsprintf.
//See unit tests for examples.
for ($i = 0; $i < $count; $i += 2) {
$tokens[$i] = str_replace(['{@}', '{}', '%'], ['@', '}', '%%'], $tokens[$i]);
}
return new Description(implode('', $tokens), $tags);
}
/**
* Strips the contents from superfluous whitespace and splits the description into a series of tokens.
*
* @return string[] A series of tokens of which the description text is composed.
*/
private function lex(string $contents): array
{
$contents = $this->removeSuperfluousStartingWhitespace($contents);
// performance optimalization; if there is no inline tag, don't bother splitting it up.
if (strpos($contents, '{@') === false) {
return [$contents];
}
return Utils::pregSplit(
'/\{
# "{@}" and "{@*}" are not a valid inline tags. This ensures that we do not treat them as one, but treat
# them literally.
(?!(?:@\}|@\*\}) )
# We want to capture the whole tag line, but without the inline tag delimiters.
(\@
# Match everything up to the next delimiter.
[^{}]*
# Nested inline tag content should not be captured, or it will appear in the result separately.
(?:
# Match nested inline tags.
(?:
# Because we did not catch the tag delimiters earlier, we must be explicit with them here.
# Notice that this also matches "{}", as a way to later introduce it as an escape sequence.
\{(?1)?\}
|
# Make sure we match hanging "{".
\{
)
# Match content after the nested inline tag.
[^{}]*
)* # If there are more inline tags, match them as well. We use "*" since there may not be any
# nested inline tags.
)
\}/Sux',
$contents,
0,
PREG_SPLIT_DELIM_CAPTURE
);
}
/**
* Removes the superfluous from a multi-line description.
*
* When a description has more than one line then it can happen that the second and subsequent lines have an
* additional indentation. This is commonly in use with tags like this:
*
* {@}since 1.1.0 This is an example
* description where we have an
* indentation in the second and
* subsequent lines.
*
* If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent
* lines and this may cause rendering issues when, for example, using a Markdown converter.
*/
private function removeSuperfluousStartingWhitespace(string $contents): string
{
$lines = Utils::pregSplit("/\r\n?|\n/", $contents);
// if there is only one line then we don't have lines with superfluous whitespace and
// can use the contents as-is
if (count($lines) <= 1) {
return $contents;
}
// determine how many whitespace characters need to be stripped
$startingSpaceCount = 9999999;
for ($i = 1, $iMax = count($lines); $i < $iMax; ++$i) {
// lines with a no length do not count as they are not indented at all
if (trim($lines[$i]) === '') {
continue;
}
// determine the number of prefixing spaces by checking the difference in line length before and after
// an ltrim
$startingSpaceCount = min($startingSpaceCount, strlen($lines[$i]) - strlen(ltrim($lines[$i])));
}
// strip the number of spaces from each line
if ($startingSpaceCount > 0) {
for ($i = 1, $iMax = count($lines); $i < $iMax; ++$i) {
$lines[$i] = substr($lines[$i], $startingSpaceCount);
}
}
return implode("\n", $lines);
}
}
================================================
FILE: src/DocBlock/ExampleFinder.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Example;
use function array_slice;
use function file;
use function getcwd;
use function implode;
use function is_readable;
use function rtrim;
use function sprintf;
use function trim;
use const DIRECTORY_SEPARATOR;
/**
* Class used to find an example file's location based on a given ExampleDescriptor.
*/
class ExampleFinder
{
private string $sourceDirectory = '';
/** @var string[] */
private array $exampleDirectories = [];
/**
* Attempts to find the example contents for the given descriptor.
*/
public function find(Example $example): string
{
$filename = $example->getFilePath();
$file = $this->getExampleFileContents($filename);
if ($file === null) {
return sprintf('** File not found : %s **', $filename);
}
return implode('', array_slice($file, $example->getStartingLine() - 1, $example->getLineCount()));
}
/**
* Registers the project's root directory where an 'examples' folder can be expected.
*/
public function setSourceDirectory(string $directory = ''): void
{
$this->sourceDirectory = $directory;
}
/**
* Returns the project's root directory where an 'examples' folder can be expected.
*/
public function getSourceDirectory(): string
{
return $this->sourceDirectory;
}
/**
* Registers a series of directories that may contain examples.
*
* @param string[] $directories
*/
public function setExampleDirectories(array $directories): void
{
$this->exampleDirectories = $directories;
}
/**
* Returns a series of directories that may contain examples.
*
* @return string[]
*/
public function getExampleDirectories(): array
{
return $this->exampleDirectories;
}
/**
* Attempts to find the requested example file and returns its contents or null if no file was found.
*
* This method will try several methods in search of the given example file, the first one it encounters is
* returned:
*
* 1. Iterates through all examples folders for the given filename
* 2. Checks the source folder for the given filename
* 3. Checks the 'examples' folder in the current working directory for examples
* 4. Checks the path relative to the current working directory for the given filename
*
* @return string[] all lines of the example file
*/
private function getExampleFileContents(string $filename): ?array
{
$normalizedPath = null;
foreach ($this->exampleDirectories as $directory) {
$exampleFileFromConfig = $this->constructExamplePath($directory, $filename);
if (is_readable($exampleFileFromConfig)) {
$normalizedPath = $exampleFileFromConfig;
break;
}
}
if ($normalizedPath === null) {
if (is_readable($this->getExamplePathFromSource($filename))) {
$normalizedPath = $this->getExamplePathFromSource($filename);
} elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) {
$normalizedPath = $this->getExamplePathFromExampleDirectory($filename);
} elseif (is_readable($filename)) {
$normalizedPath = $filename;
}
}
$lines = $normalizedPath !== null && is_readable($normalizedPath) ? file($normalizedPath) : false;
return $lines !== false ? $lines : null;
}
/**
* Get example filepath based on the example directory inside your project.
*/
private function getExamplePathFromExampleDirectory(string $file): string
{
return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file;
}
/**
* Returns a path to the example file in the given directory..
*/
private function constructExamplePath(string $directory, string $file): string
{
return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file;
}
/**
* Get example filepath based on sourcecode.
*/
private function getExamplePathFromSource(string $file): string
{
return sprintf(
'%s%s%s',
trim($this->getSourceDirectory(), '\\/'),
DIRECTORY_SEPARATOR,
trim($file, '"')
);
}
}
================================================
FILE: src/DocBlock/Serializer.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
use function sprintf;
use function str_repeat;
use function str_replace;
use function strlen;
use function wordwrap;
/**
* Converts a DocBlock back from an object to a complete DocComment including Asterisks.
*/
class Serializer
{
/** @var string The string to indent the comment with. */
protected string $indentString = ' ';
/** @var int The number of times the indent string is repeated. */
protected int $indent = 0;
/** @var bool Whether to indent the first line with the given indent amount and string. */
protected bool $isFirstLineIndented = true;
/** @var int|null The max length of a line. */
protected ?int $lineLength = null;
/** @var Formatter A custom tag formatter. */
protected Formatter $tagFormatter;
private string $lineEnding;
/**
* Create a Serializer instance.
*
* @param int $indent The number of times the indent string is repeated.
* @param string $indentString The string to indent the comment with.
* @param bool $indentFirstLine Whether to indent the first line.
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
* @param Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
* @param string $lineEnding Line ending used in the output, by default \n is used.
*/
public function __construct(
int $indent = 0,
string $indentString = ' ',
bool $indentFirstLine = true,
?int $lineLength = null,
?Formatter $tagFormatter = null,
string $lineEnding = "\n"
) {
$this->indent = $indent;
$this->indentString = $indentString;
$this->isFirstLineIndented = $indentFirstLine;
$this->lineLength = $lineLength;
$this->tagFormatter = $tagFormatter ?: new PassthroughFormatter();
$this->lineEnding = $lineEnding;
}
/**
* Generate a DocBlock comment.
*
* @param DocBlock $docblock The DocBlock to serialize.
*
* @return string The serialized doc block.
*/
public function getDocComment(DocBlock $docblock): string
{
$indent = str_repeat($this->indentString, $this->indent);
$firstIndent = $this->isFirstLineIndented ? $indent : '';
// 3 === strlen(' * ')
$wrapLength = $this->lineLength !== null ? $this->lineLength - strlen($indent) - 3 : null;
$text = $this->removeTrailingSpaces(
$indent,
$this->addAsterisksForEachLine(
$indent,
$this->getSummaryAndDescriptionTextBlock($docblock, $wrapLength)
)
);
$comment = $firstIndent . "/**\n";
if ($text) {
$comment .= $indent . ' * ' . $text . "\n";
$comment .= $indent . " *\n";
}
$comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment);
return str_replace("\n", $this->lineEnding, $comment . $indent . ' */');
}
private function removeTrailingSpaces(string $indent, string $text): string
{
return str_replace(
sprintf("\n%s * \n", $indent),
sprintf("\n%s *\n", $indent),
$text
);
}
private function addAsterisksForEachLine(string $indent, string $text): string
{
return str_replace(
"\n",
sprintf("\n%s * ", $indent),
$text
);
}
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength): string
{
$text = $docblock->getSummary() . ((string) $docblock->getDescription() ? "\n\n" . $docblock->getDescription()
: '');
if ($wrapLength !== null) {
$text = wordwrap($text, $wrapLength);
return $text;
}
return $text;
}
private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment): string
{
foreach ($docblock->getTags() as $tag) {
$tagText = $this->tagFormatter->format($tag);
if ($wrapLength !== null) {
$tagText = wordwrap($tagText, $wrapLength);
}
$tagText = str_replace(
"\n",
sprintf("\n%s * ", $indent),
$tagText
);
$comment .= sprintf("%s * %s\n", $indent, $tagText);
}
return $comment;
}
}
================================================
FILE: src/DocBlock/StandardTagFactory.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tags\Author;
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ExtendsFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MixinFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateCovariantFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ThrowsFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
use phpDocumentor\Reflection\DocBlock\Tags\Since;
use phpDocumentor\Reflection\DocBlock\Tags\Source;
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
use phpDocumentor\Reflection\DocBlock\Tags\Version;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionParameter;
use Webmozart\Assert\Assert;
use function array_key_exists;
use function array_merge;
use function array_slice;
use function call_user_func_array;
use function get_class;
use function is_object;
use function preg_match;
use function sprintf;
use function strpos;
use function trim;
/**
* Creates a Tag object given the contents of a tag.
*
* This Factory is capable of determining the appropriate class for a tag and instantiate it using its `create`
* factory method. The `create` factory method of a Tag can have a variable number of arguments; this way you can
* pass the dependencies that you need to construct a tag object.
*
* > Important: each parameter in addition to the body variable for the `create` method must default to null, otherwise
* > it violates the constraint with the interface; it is recommended to use the {@see Assert::notNull()} method to
* > verify that a dependency is actually passed.
*
* This Factory also features a Service Locator component that is used to pass the right dependencies to the
* `create` method of a tag; each dependency should be registered as a service or as a parameter.
*
* When you want to use a Tag of your own with custom handling you need to call the `registerTagHandler` method, pass
* the name of the tag and a Fully Qualified Class Name pointing to a class that implements the Tag interface.
*/
final class StandardTagFactory implements TagFactory
{
/** PCRE regular expression matching a tag name. */
public const REGEX_TAGNAME = '[\w\-\_\\\\:]+';
/**
* @var array<string, class-string<Tag>|Tag|Factory> An array with a tag as a key, and an
* FQCN to a class that handles it as an array value.
*/
private array $tagHandlerMappings = [
'author' => Author::class,
'covers' => Covers::class,
'deprecated' => Deprecated::class,
'link' => LinkTag::class,
'see' => SeeTag::class,
'since' => Since::class,
'source' => Source::class,
'uses' => Uses::class,
'version' => Version::class,
];
/**
* @var array<class-string<Tag>> An array with an annotation as a key, and an
* FQCN to a class that handles it as an array value.
*/
private array $annotationMappings = [];
/**
* @var ReflectionParameter[][] a lazy-loading cache containing parameters
* for each tagHandler that has been used.
*/
private array $tagHandlerParameterCache = [];
private FqsenResolver $fqsenResolver;
/**
* @var mixed[] an array representing a simple Service Locator where we can store parameters and
* services that can be inserted into the Factory Methods of Tag Handlers.
*/
private array $serviceLocator = [];
private function __construct(FqsenResolver $fqsenResolver)
{
$this->fqsenResolver = $fqsenResolver;
$this->addService($fqsenResolver, FqsenResolver::class);
}
/**
* Initialize this tag factory with the means to resolve an FQSEN.
*
* @see self::registerTagHandler() to add a new tag handler to the existing default list.
*/
public static function createInstance(FqsenResolver $fqsenResolver): self
{
$tagFactory = new self($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$typeResolver = new TypeResolver($fqsenResolver);
$phpstanTagFactory = new AbstractPHPStanFactory(
new ParamFactory($typeResolver, $descriptionFactory),
new VarFactory($typeResolver, $descriptionFactory),
new ReturnFactory($typeResolver, $descriptionFactory),
new PropertyFactory($typeResolver, $descriptionFactory),
new PropertyReadFactory($typeResolver, $descriptionFactory),
new PropertyWriteFactory($typeResolver, $descriptionFactory),
new MethodFactory($typeResolver, $descriptionFactory),
new MixinFactory($typeResolver, $descriptionFactory),
new ImplementsFactory($typeResolver, $descriptionFactory),
new ExtendsFactory($typeResolver, $descriptionFactory),
new TemplateFactory($typeResolver, $descriptionFactory),
new TemplateCovariantFactory($typeResolver, $descriptionFactory),
new ThrowsFactory($typeResolver, $descriptionFactory),
);
$tagFactory->addService($descriptionFactory);
$tagFactory->addService($typeResolver);
$tagFactory->registerTagHandler('param', $phpstanTagFactory);
$tagFactory->registerTagHandler('var', $phpstanTagFactory);
$tagFactory->registerTagHandler('return', $phpstanTagFactory);
$tagFactory->registerTagHandler('property', $phpstanTagFactory);
$tagFactory->registerTagHandler('property-read', $phpstanTagFactory);
$tagFactory->registerTagHandler('property-write', $phpstanTagFactory);
$tagFactory->registerTagHandler('method', $phpstanTagFactory);
$tagFactory->registerTagHandler('mixin', $phpstanTagFactory);
$tagFactory->registerTagHandler('extends', $phpstanTagFactory);
$tagFactory->registerTagHandler('implements', $phpstanTagFactory);
$tagFactory->registerTagHandler('template', $phpstanTagFactory);
$tagFactory->registerTagHandler('template-covariant', $phpstanTagFactory);
$tagFactory->registerTagHandler('template-extends', $phpstanTagFactory);
$tagFactory->registerTagHandler('template-implements', $phpstanTagFactory);
$tagFactory->registerTagHandler('throws', $phpstanTagFactory);
return $tagFactory;
}
public function create(string $tagLine, ?TypeContext $context = null): Tag
{
if (!$context) {
$context = new TypeContext('');
}
[$tagName, $tagBody] = $this->extractTagParts($tagLine);
return $this->createTag(trim($tagBody), $tagName, $context);
}
/**
* @param mixed $value
*/
public function addParameter(string $name, $value): void
{
$this->serviceLocator[$name] = $value;
}
public function addService(object $service, ?string $alias = null): void
{
$this->serviceLocator[$alias ?? get_class($service)] = $service;
}
/** {@inheritDoc} */
public function registerTagHandler(string $tagName, $handler): void
{
Assert::stringNotEmpty($tagName);
if (strpos($tagName, '\\') !== false && $tagName[0] !== '\\') {
throw new InvalidArgumentException(
'A namespaced tag must have a leading backslash as it must be fully qualified'
);
}
if (is_object($handler)) {
Assert::isInstanceOf($handler, Factory::class);
$this->tagHandlerMappings[$tagName] = $handler;
return;
}
Assert::classExists($handler);
Assert::implementsInterface($handler, Tag::class);
$this->tagHandlerMappings[$tagName] = $handler;
}
/**
* Extracts all components for a tag.
*
* @return string[]
*/
private function extractTagParts(string $tagLine): array
{
$matches = [];
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
throw new InvalidArgumentException(
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
);
}
return array_slice($matches, 1);
}
/**
* Creates a new tag object with the given name and body or returns null if the tag name was recognized but the
* body was invalid.
*/
private function createTag(string $body, string $name, TypeContext $context): Tag
{
$handlerClassName = $this->findHandlerClassName($name, $context);
$arguments = $this->getArgumentsForParametersFromWiring(
$this->fetchParametersForHandlerFactoryMethod($handlerClassName),
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
);
if (array_key_exists('tagLine', $arguments)) {
$arguments['tagLine'] = sprintf('@%s %s', $name, $body);
}
try {
$callable = [$handlerClassName, 'create'];
Assert::isCallable($callable);
/** @phpstan-var callable(string): ?Tag $callable */
$tag = call_user_func_array($callable, $arguments);
return $tag ?? InvalidTag::create($body, $name);
} catch (InvalidArgumentException $e) {
return InvalidTag::create($body, $name)->withError($e);
}
}
/**
* Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).
*
* @return class-string<Tag>|Tag|Factory
*/
private function findHandlerClassName(string $tagName, TypeContext $context)
{
$handlerClassName = Generic::class;
if (isset($this->tagHandlerMappings[$tagName])) {
$handlerClassName = $this->tagHandlerMappings[$tagName];
} elseif ($this->isAnnotation($tagName)) {
// TODO: Annotation support is planned for a later stage and as such is disabled for now
$tagName = (string) $this->fqsenResolver->resolve($tagName, $context);
if (isset($this->annotationMappings[$tagName])) {
$handlerClassName = $this->annotationMappings[$tagName];
}
}
return $handlerClassName;
}
/**
* Retrieves the arguments that need to be passed to the Factory Method with the given Parameters.
*
* @param ReflectionParameter[] $parameters
* @param mixed[] $locator
*
* @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters
* is provided with this method.
*/
private function getArgumentsForParametersFromWiring(array $parameters, array $locator): array
{
$arguments = [];
foreach ($parameters as $parameter) {
$type = $parameter->getType();
$typeHint = null;
if ($type instanceof ReflectionNamedType) {
$typeHint = $type->getName();
if ($typeHint === 'self') {
$declaringClass = $parameter->getDeclaringClass();
if ($declaringClass !== null) {
$typeHint = $declaringClass->getName();
}
}
}
$parameterName = $parameter->getName();
if (isset($locator[$typeHint ?? ''])) {
$arguments[$parameterName] = $locator[$typeHint ?? ''];
continue;
}
if (isset($locator[$parameterName])) {
$arguments[$parameterName] = $locator[$parameterName];
continue;
}
$arguments[$parameterName] = null;
}
return $arguments;
}
/**
* Retrieves a series of ReflectionParameter objects for the static 'create' method of the given
* tag handler class name.
*
* @param class-string<Tag>|Tag|Factory $handler
*
* @return ReflectionParameter[]
*/
private function fetchParametersForHandlerFactoryMethod($handler): array
{
$handlerClassName = is_object($handler) ? get_class($handler) : $handler;
if (!isset($this->tagHandlerParameterCache[$handlerClassName])) {
$methodReflection = new ReflectionMethod($handlerClassName, 'create');
$this->tagHandlerParameterCache[$handlerClassName] = $methodReflection->getParameters();
}
return $this->tagHandlerParameterCache[$handlerClassName];
}
/**
* Returns a copy of this class' Service Locator with added dynamic parameters,
* such as the tag's name, body and Context.
*
* @param TypeContext $context The Context (namespace and aliases) that may be
* passed and is used to resolve FQSENs.
* @param string $tagName The name of the tag that may be
* passed onto the factory method of the Tag class.
* @param string $tagBody The body of the tag that may be
* passed onto the factory method of the Tag class.
*
* @return mixed[]
*/
private function getServiceLocatorWithDynamicParameters(
TypeContext $context,
string $tagName,
string $tagBody
): array {
return array_merge(
$this->serviceLocator,
[
'name' => $tagName,
'body' => $tagBody,
TypeContext::class => $context,
]
);
}
/**
* Returns whether the given tag belongs to an annotation.
*
* @todo this method should be populated once we implement Annotation notation support.
*/
private function isAnnotation(string $tagContent): bool
{
// 1. Contains a namespace separator
// 2. Contains parenthesis
// 3. Is present in a list of known annotations (make the algorithm smart by first checking is the last part
// of the annotation class name matches the found tag name
return false;
}
}
================================================
FILE: src/DocBlock/Tag.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
interface Tag
{
public function getName(): string;
/**
* @return Tag|mixed Class that implements Tag
* @phpstan-return ?Tag
*/
public static function create(string $body);
public function render(?Formatter $formatter = null): string;
public function __toString(): string;
}
================================================
FILE: src/DocBlock/TagFactory.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
interface TagFactory extends Factory
{
/**
* Adds a parameter to the service locator that can be injected in a tag's factory method.
*
* When calling a tag's "create" method we always check the signature for dependencies to inject. One way is to
* typehint a parameter in the signature so that we can use that interface or class name to inject a dependency
* (see {@see addService()} for more information on that).
*
* Another way is to check the name of the argument against the names in the Service Locator. With this method
* you can add a variable that will be inserted when a tag's create method is not typehinted and has a matching
* name.
*
* Be aware that there are two reserved names:
*
* - name, representing the name of the tag.
* - body, representing the complete body of the tag.
*
* These parameters are injected at the last moment and will override any existing parameter with those names.
*
* @param mixed $value
*/
public function addParameter(string $name, $value): void;
/**
* Registers a service with the Service Locator using the FQCN of the class or the alias, if provided.
*
* When calling a tag's "create" method we always check the signature for dependencies to inject. If a parameter
* has a typehint then the ServiceLocator is queried to see if a Service is registered for that typehint.
*
* Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the
* interface is passed as alias then every time that interface is requested the provided service will be returned.
*/
public function addService(object $service): void;
/**
* Registers a handler for tags.
*
* If you want to use your own tags then you can use this method to instruct the TagFactory
* to register the name of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement
* the {@see Tag} interface (and thus the create method).
*
* @param string $tagName Name of tag to register a handler for. When registering a namespaced
* tag, the full name, along with a prefixing slash MUST be provided.
* @param class-string<Tag>|Factory $handler FQCN of handler.
*
* @throws InvalidArgumentException If the tag name is not a string.
* @throws InvalidArgumentException If the tag name is namespaced (contains backslashes) but
* does not start with a backslash.
* @throws InvalidArgumentException If the handler is not a string.
* @throws InvalidArgumentException If the handler is not an existing class.
* @throws InvalidArgumentException If the handler does not implement the {@see Tag} interface.
*/
public function registerTagHandler(string $tagName, $handler): void;
}
================================================
FILE: src/DocBlock/Tags/Author.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use InvalidArgumentException;
use function filter_var;
use function preg_match;
use function trim;
use const FILTER_VALIDATE_EMAIL;
/**
* Reflection class for an {@}author tag in a Docblock.
*/
final class Author extends BaseTag
{
/** @var string register that this is the author tag. */
protected string $name = 'author';
/** @var string The name of the author */
private string $authorName;
/** @var string The email of the author */
private string $authorEmail;
/**
* Initializes this tag with the author name and e-mail.
*/
public function __construct(string $authorName, string $authorEmail)
{
if ($authorEmail && !filter_var($authorEmail, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException('The author tag does not have a valid e-mail address');
}
$this->authorName = $authorName;
$this->authorEmail = $authorEmail;
}
/**
* Gets the author's name.
*
* @return string The author's name.
*/
public function getAuthorName(): string
{
return $this->authorName;
}
/**
* Returns the author's email.
*
* @return string The author's email.
*/
public function getEmail(): string
{
return $this->authorEmail;
}
/**
* Returns this tag in string form.
*/
public function __toString(): string
{
if ($this->authorEmail) {
$authorEmail = '<' . $this->authorEmail . '>';
} else {
$authorEmail = '';
}
$authorName = $this->authorName;
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
}
/**
* Attempts to create a new Author object based on the tag body.
*/
public static function create(string $body): ?self
{
$splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches);
if (!$splitTagContent) {
return null;
}
$authorName = trim($matches[1]);
$email = isset($matches[2]) ? trim($matches[2]) : '';
return new static($authorName, $email);
}
}
================================================
FILE: src/DocBlock/Tags/BaseTag.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Description;
/**
* Parses a tag definition for a DocBlock.
*/
abstract class BaseTag implements DocBlock\Tag
{
/** @var string Name of the tag */
protected string $name = '';
/** @var Description|null Description of the tag. */
protected ?Description $description = null;
/**
* Gets the name of this tag.
*
* @return string The name of this tag.
*/
public function getName(): string
{
return $this->name;
}
public function getDescription(): ?Description
{
return $this->description;
}
public function render(?Formatter $formatter = null): string
{
if ($formatter === null) {
$formatter = new Formatter\PassthroughFormatter();
}
return $formatter->format($this);
}
}
================================================
FILE: src/DocBlock/Tags/Covers.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\Utils;
use Webmozart\Assert\Assert;
use function array_key_exists;
use function explode;
/**
* Reflection class for a @covers tag in a Docblock.
*/
final class Covers extends BaseTag
{
protected string $name = 'covers';
private Fqsen $refers;
/**
* Initializes this tag.
*/
public function __construct(Fqsen $refers, ?Description $description = null)
{
$this->refers = $refers;
$this->description = $description;
}
public static function create(
string $body,
?DescriptionFactory $descriptionFactory = null,
?FqsenResolver $resolver = null,
?TypeContext $context = null
): self {
Assert::stringNotEmpty($body);
Assert::notNull($descriptionFactory);
Assert::notNull($resolver);
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
return new static(
self::resolveFqsen($parts[0], $resolver, $context),
$descriptionFactory->create($parts[1] ?? '', $context)
);
}
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
{
Assert::notNull($fqsenResolver);
$fqsenParts = explode('::', $parts);
$resolved = $fqsenResolver->resolve($fqsenParts[0], $context);
if (!array_key_exists(1, $fqsenParts)) {
return $resolved;
}
return new Fqsen($resolved . '::' . $fqsenParts[1]);
}
/**
* Returns the structural element this tag refers to.
*/
public function getReference(): Fqsen
{
return $this->refers;
}
/**
* Returns a string representation of this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$refers = (string) $this->refers;
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Deprecated.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
use function preg_match;
/**
* Reflection class for a {@}deprecated tag in a Docblock.
*/
final class Deprecated extends BaseTag
{
protected string $name = 'deprecated';
/**
* PCRE regular expression matching a version vector.
* Assumes the "x" modifier.
*/
public const REGEX_VECTOR = '(?:
# Normal release vectors.
\d\S*
|
# VCS version vectors. Per PHPCS, they are expected to
# follow the form of the VCS name, followed by ":", followed
# by the version vector itself.
# By convention, popular VCSes like CVS, SVN and GIT use "$"
# around the actual version vector.
[^\s\:]+\:\s*\$[^\$]+\$
)';
/** @var string|null The version vector. */
private ?string $version = null;
public function __construct(?string $version = null, ?Description $description = null)
{
Assert::nullOrNotEmpty($version);
$this->version = $version;
$this->description = $description;
}
/**
* @return static
*/
public static function create(
?string $body,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
if ($body === null || $body === '') {
return new static();
}
$matches = [];
if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) {
return new static(
null,
$descriptionFactory !== null ? $descriptionFactory->create($body, $context) : null
);
}
Assert::notNull($descriptionFactory);
return new static(
$matches[1],
$descriptionFactory->create($matches[2] ?? '', $context)
);
}
/**
* Gets the version section of the tag.
*/
public function getVersion(): ?string
{
return $this->version;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$version = (string) $this->version;
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Example.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tag;
use Webmozart\Assert\Assert;
use function array_key_exists;
use function preg_match;
use function rawurlencode;
use function str_replace;
use function strpos;
use function trim;
/**
* Reflection class for a {@}example tag in a Docblock.
*/
final class Example implements Tag
{
/** @var string Path to a file to use as an example. May also be an absolute URI. */
private string $filePath;
/**
* @var bool Whether the file path component represents an URI. This determines how the file portion
* appears at {@link getContent()}.
*/
private bool $isURI;
private int $startingLine;
private int $lineCount;
private ?string $content = null;
public function __construct(
string $filePath,
bool $isURI,
int $startingLine,
int $lineCount,
?string $content
) {
Assert::stringNotEmpty($filePath);
Assert::greaterThanEq($startingLine, 1);
Assert::greaterThanEq($lineCount, 0);
$this->filePath = $filePath;
$this->startingLine = $startingLine;
$this->lineCount = $lineCount;
if ($content !== null) {
$this->content = trim($content);
}
$this->isURI = $isURI;
}
public function getContent(): string
{
if ($this->content === null || $this->content === '') {
$filePath = $this->filePath;
if ($this->isURI) {
$filePath = $this->isUriRelative($this->filePath)
? str_replace('%2F', '/', rawurlencode($this->filePath))
: $this->filePath;
}
return trim($filePath);
}
return $this->content;
}
public function getDescription(): ?string
{
return $this->content;
}
public static function create(string $body): ?Tag
{
// File component: File path in quotes or File URI / Source information
if (!preg_match('/^\s*(?:(\"[^\"]+\")|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
return null;
}
$filePath = null;
$fileUri = null;
if (array_key_exists(1, $matches) && $matches[1] !== '') {
$filePath = $matches[1];
} else {
$fileUri = array_key_exists(2, $matches) ? $matches[2] : '';
}
$startingLine = 1;
$lineCount = 0;
$description = null;
if (array_key_exists(3, $matches)) {
$description = $matches[3];
// Starting line / Number of lines / Description
if (preg_match('/^([1-9]\d*)(?:\s+((?1))\s*)?(.*)$/sux', $matches[3], $contentMatches)) {
$startingLine = (int) $contentMatches[1];
if (isset($contentMatches[2])) {
$lineCount = (int) $contentMatches[2];
}
if (array_key_exists(3, $contentMatches)) {
$description = $contentMatches[3];
}
}
}
return new static(
$filePath ?? ($fileUri ?? ''),
$fileUri !== null,
$startingLine,
$lineCount,
$description
);
}
/**
* Returns the file path.
*
* @return string Path to a file to use as an example.
* May also be an absolute URI.
*/
public function getFilePath(): string
{
return trim($this->filePath, '"');
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
$filePath = $this->filePath;
$isDefaultLine = $this->startingLine === 1 && $this->lineCount === 0;
$startingLine = !$isDefaultLine ? (string) $this->startingLine : '';
$lineCount = !$isDefaultLine ? (string) $this->lineCount : '';
$content = (string) $this->content;
return $filePath
. ($startingLine !== ''
? ($filePath !== '' ? ' ' : '') . $startingLine
: '')
. ($lineCount !== ''
? ($filePath !== '' || $startingLine !== '' ? ' ' : '') . $lineCount
: '')
. ($content !== ''
? ($filePath !== '' || $startingLine !== '' || $lineCount !== '' ? ' ' : '') . $content
: '');
}
/**
* Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute).
*/
private function isUriRelative(string $uri): bool
{
return strpos($uri, ':') === false;
}
public function getStartingLine(): int
{
return $this->startingLine;
}
public function getLineCount(): int
{
return $this->lineCount;
}
public function getName(): string
{
return 'example';
}
public function render(?Formatter $formatter = null): string
{
if ($formatter === null) {
$formatter = new Formatter\PassthroughFormatter();
}
return $formatter->format($this);
}
}
================================================
FILE: src/DocBlock/Tags/Extends_.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}extends tag in a Docblock.
*/
class Extends_ extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'extends';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php
================================================
<?php
/*
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*
*/
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use PHPStan\PhpDocParser\Lexer\Lexer;
use PHPStan\PhpDocParser\Parser\ConstExprParser;
use PHPStan\PhpDocParser\Parser\ParserException;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
use PHPStan\PhpDocParser\ParserConfig;
use RuntimeException;
use function property_exists;
use function rtrim;
use function str_replace;
use function trim;
/**
* Factory class creating tags using phpstan's parser
*
* This class uses {@see PHPStanFactory} implementations to create tags
* from the ast of the phpstan docblock parser.
*
* @internal This class is not part of the BC promise of this library.
*/
class AbstractPHPStanFactory implements Factory
{
private PhpDocParser $parser;
private Lexer $lexer;
/** @var PHPStanFactory[] */
private array $factories;
public function __construct(PHPStanFactory ...$factories)
{
$config = new ParserConfig(['indexes' => true, 'lines' => true]);
$this->lexer = new Lexer($config);
$constParser = new ConstExprParser($config);
$this->parser = new PhpDocParser(
$config,
new TypeParser($config, $constParser),
$constParser
);
$this->factories = $factories;
}
public function create(string $tagLine, ?TypeContext $context = null): Tag
{
try {
$tokens = $this->tokenizeLine($tagLine);
$ast = $this->parser->parseTag($tokens);
if (property_exists($ast->value, 'description') === true) {
$ast->value->setAttribute(
'description',
rtrim($ast->value->description . $tokens->joinUntil(Lexer::TOKEN_END), "\n")
);
}
} catch (ParserException $e) {
return InvalidTag::create($tagLine, '')->withError($e);
}
if ($context === null) {
$context = new TypeContext('');
}
try {
foreach ($this->factories as $factory) {
if ($factory->supports($ast, $context)) {
return $factory->create($ast, $context);
}
}
} catch (RuntimeException $e) {
return InvalidTag::create((string) $ast->value, 'method')->withError($e);
} catch (ParserException $e) {
return InvalidTag::create((string) $ast->value, $ast->name)->withError($e);
}
return InvalidTag::create(
(string) $ast->value,
$ast->name
);
}
/**
* Solve the issue with the lexer not tokenizing the line correctly
*
* This method is a workaround for the lexer that includes newline tokens with spaces. For
* phpstan this isn't an issue, as it doesn't do a lot of things with the indentation of descriptions.
* But for us is important to keep the indentation of the descriptions, so we need to fix the lexer output.
*/
private function tokenizeLine(string $tagLine): TokenIterator
{
// Prefix continuation lines with "* ", which is consumed by the phpstan parser as TOKEN_PHPDOC_EOL.
$tagLine = str_replace("\n", "\n* ", $tagLine);
$tokens = $this->lexer->tokenize($tagLine . "\n");
$fixed = [];
foreach ($tokens as $token) {
if ($token[Lexer::TYPE_OFFSET] === Lexer::TOKEN_PHPDOC_EOL) {
// Strip "* " prefix (and other horizontal whitespace) again so it doesn't and up in the
// description when we joinUntil() in create().
$fixed[] = [
Lexer::VALUE_OFFSET => trim($token[Lexer::VALUE_OFFSET], "* \t"),
Lexer::TYPE_OFFSET => $token[Lexer::TYPE_OFFSET],
Lexer::LINE_OFFSET => $token[Lexer::LINE_OFFSET] ?? 0,
];
continue;
}
$fixed[] = $token;
}
return new TokenIterator($fixed);
}
}
================================================
FILE: src/DocBlock/Tags/Factory/ExtendsFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class ExtendsFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ExtendsTagValueNode && $node->name === '@extends';
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, ExtendsTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Extends_(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
}
================================================
FILE: src/DocBlock/Tags/Factory/Factory.php
================================================
<?php
/*
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*
*/
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\Types\Context as TypeContext;
interface Factory
{
/**
* Factory method responsible for instantiating the correct sub type.
*
* @param string $tagLine The text for this tag, including description.
*
* @return Tag A new tag object.
*
* @throws InvalidArgumentException If an invalid tag line was presented.
*/
public function create(string $tagLine, ?TypeContext $context = null): Tag;
}
================================================
FILE: src/DocBlock/Tags/Factory/ImplementsFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class ImplementsFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ImplementsTagValueNode && $node->name === '@implements';
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, ImplementsTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Implements_(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
}
================================================
FILE: src/DocBlock/Tags/Factory/MethodFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Method;
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\Mixed_;
use phpDocumentor\Reflection\Types\Void_;
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Webmozart\Assert\Assert;
use function array_map;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class MethodFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, MethodTagValueNode::class);
return new Method(
$tagValue->methodName,
array_map(
function (MethodTagValueParameterNode $param) use ($context) {
return new MethodParameter(
trim($param->parameterName, '$'),
$param->type === null ? new Mixed_() : $this->typeResolver->createType(
$param->type,
$context
),
$param->isReference,
$param->isVariadic,
$param->defaultValue === null ?
MethodParameter::NO_DEFAULT_VALUE :
(string) $param->defaultValue
);
},
$tagValue->parameters
),
$this->createReturnType($tagValue, $context),
$tagValue->isStatic,
$this->descriptionFactory->create($tagValue->description, $context),
false,
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof MethodTagValueNode;
}
private function createReturnType(MethodTagValueNode $tagValue, Context $context): Type
{
if ($tagValue->returnType === null) {
return new Void_();
}
return $this->typeResolver->createType($tagValue->returnType, $context);
}
}
================================================
FILE: src/DocBlock/Tags/Factory/MethodParameterFactory.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use function array_key_last;
use function get_class;
use function gettype;
use function method_exists;
use function ucfirst;
use function var_export;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class MethodParameterFactory
{
/**
* Formats the given default value to a string-able mixin
*
* @param mixed $defaultValue
*/
public function format($defaultValue): string
{
$method = 'format' . ucfirst(gettype($defaultValue));
if (method_exists($this, $method)) {
return $this->{$method}($defaultValue);
}
return '';
}
private function formatDouble(float $defaultValue): string
{
return var_export($defaultValue, true);
}
/**
* @param mixed $defaultValue
*/
private function formatNull($defaultValue): string
{
return 'null';
}
private function formatInteger(int $defaultValue): string
{
return var_export($defaultValue, true);
}
private function formatString(string $defaultValue): string
{
return var_export($defaultValue, true);
}
private function formatBoolean(bool $defaultValue): string
{
return var_export($defaultValue, true);
}
/**
* @param array<(array<mixed>|int|float|bool|string|object|null)> $defaultValue
*/
private function formatArray(array $defaultValue): string
{
$formatedValue = '[';
foreach ($defaultValue as $key => $value) {
$method = 'format' . ucfirst(gettype($value));
if (!method_exists($this, $method)) {
continue;
}
$formatedValue .= $this->{$method}($value);
if ($key === array_key_last($defaultValue)) {
continue;
}
$formatedValue .= ',';
}
return $formatedValue . ']';
}
private function formatObject(object $defaultValue): string
{
return 'new ' . get_class($defaultValue) . '()';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/MixinFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\MixinTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class MixinFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, MixinTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Mixin(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof MixinTagValueNode;
}
}
================================================
FILE: src/DocBlock/Tags/Factory/PHPStanFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
interface PHPStanFactory
{
public function create(PhpDocTagNode $node, Context $context): Tag;
public function supports(PhpDocTagNode $node, Context $context): bool;
}
================================================
FILE: src/DocBlock/Tags/Factory/ParamFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\Exception\ParserException;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\TypelessParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\OffsetAccessTypeNode;
use Webmozart\Assert\Assert;
use function is_string;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class ParamFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
if ($tagValue instanceof InvalidTagValueNode) {
return InvalidTag::create($tagValue->value, 'param')->withError(
ParserException::from($tagValue->exception)
);
}
Assert::isInstanceOfAny(
$tagValue,
[
ParamTagValueNode::class,
TypelessParamTagValueNode::class,
]
);
if (($tagValue->type ?? null) instanceof OffsetAccessTypeNode) {
return InvalidTag::create(
(string) $tagValue,
'param'
);
}
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Param(
trim($tagValue->parameterName, '$'),
$this->typeResolver->createType($tagValue->type ?? new IdentifierTypeNode('mixed'), $context),
$tagValue->isVariadic,
$this->descriptionFactory->create($description, $context),
$tagValue->isReference
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ParamTagValueNode
|| $node->value instanceof TypelessParamTagValueNode
|| $node->name === '@param';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/PropertyFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Property;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class PropertyFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, PropertyTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Property(
trim($tagValue->propertyName, '$'),
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof PropertyTagValueNode && $node->name === '@property';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/PropertyReadFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class PropertyReadFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->typeResolver = $typeResolver;
$this->descriptionFactory = $descriptionFactory;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, PropertyTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new PropertyRead(
trim($tagValue->propertyName, '$'),
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof PropertyTagValueNode && $node->name === '@property-read';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/PropertyWriteFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class PropertyWriteFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, PropertyTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new PropertyWrite(
trim($tagValue->propertyName, '$'),
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof PropertyTagValueNode && $node->name === '@property-write';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/ReturnFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class ReturnFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, ReturnTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Return_(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ReturnTagValueNode;
}
}
================================================
FILE: src/DocBlock/Tags/Factory/TemplateCovariantFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class TemplateCovariantFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof TemplateTagValueNode && $node->name === '@template-covariant';
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new TemplateCovariant(
$this->typeResolver->createType(new IdentifierTypeNode($tagValue->name), $context),
$this->descriptionFactory->create($description, $context)
);
}
}
================================================
FILE: src/DocBlock/Tags/Factory/TemplateFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Template;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class TemplateFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
$name = $tagValue->name;
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Template(
$name,
$this->typeResolver->createType($tagValue->bound, $context),
$this->typeResolver->createType($tagValue->default, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof TemplateTagValueNode && $node->name === '@template';
}
}
================================================
FILE: src/DocBlock/Tags/Factory/ThrowsFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class ThrowsFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, ThrowsTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Throws(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ThrowsTagValueNode;
}
}
================================================
FILE: src/DocBlock/Tags/Factory/VarFactory.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use Webmozart\Assert\Assert;
use function is_string;
use function trim;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class VarFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, VarTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new Var_(
trim($tagValue->variableName, '$'),
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof VarTagValueNode;
}
}
================================================
FILE: src/DocBlock/Tags/Formatter/AlignFormatter.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use function max;
use function str_repeat;
use function strlen;
class AlignFormatter implements Formatter
{
/** @var int The maximum tag name length. */
protected int $maxLen = 0;
/**
* @param Tag[] $tags All tags that should later be aligned with the formatter.
*/
public function __construct(array $tags)
{
foreach ($tags as $tag) {
$this->maxLen = max($this->maxLen, strlen($tag->getName()));
}
}
/**
* Formats the given tag to return a simple plain text version.
*/
public function format(Tag $tag): string
{
return '@' . $tag->getName() .
str_repeat(
' ',
$this->maxLen - strlen($tag->getName()) + 1
) .
$tag;
}
}
================================================
FILE: src/DocBlock/Tags/Formatter/PassthroughFormatter.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use function trim;
class PassthroughFormatter implements Formatter
{
/**
* Formats the given tag to return a simple plain text version.
*/
public function format(Tag $tag): string
{
return trim('@' . $tag->getName() . ' ' . $tag);
}
}
================================================
FILE: src/DocBlock/Tags/Formatter.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tag;
interface Formatter
{
/**
* Formats a tag into a string representation according to a specific format, such as Markdown.
*/
public function format(Tag $tag): string;
}
================================================
FILE: src/DocBlock/Tags/Generic.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
use function preg_match;
/**
* Parses a tag definition for a DocBlock.
*/
final class Generic extends BaseTag
{
/**
* Parses a tag and populates the member variables.
*
* @param string $name Name of the tag.
* @param Description $description The contents of the given tag.
*/
public function __construct(string $name, ?Description $description = null)
{
$this->validateTagName($name);
$this->name = $name;
$this->description = $description;
}
/**
* Creates a new tag that represents any unknown tag type.
*
* @return static
*/
public static function create(
string $body,
string $name = '',
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
Assert::stringNotEmpty($name);
Assert::notNull($descriptionFactory);
$description = $body !== '' ? $descriptionFactory->create($body, $context) : null;
return new static($name, $description);
}
/**
* Returns the tag as a serialized string
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
return $description;
}
/**
* Validates if the tag name matches the expected format, otherwise throws an exception.
*/
private function validateTagName(string $name): void
{
if (!preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) {
throw new InvalidArgumentException(
'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, '
. 'hyphens and backslashes.'
);
}
}
}
================================================
FILE: src/DocBlock/Tags/Implements_.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}implements tag in a Docblock.
*/
class Implements_ extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'implements';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/InvalidTag.php
================================================
<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Closure;
use Exception;
use phpDocumentor\Reflection\DocBlock\Tag;
use ReflectionClass;
use ReflectionException;
use ReflectionFunction;
use Throwable;
use function array_map;
use function get_class;
use function get_resource_type;
use function is_array;
use function is_object;
use function is_resource;
use function sprintf;
use const PHP_VERSION_ID;
/**
* This class represents an exception during the tag creation
*
* Since the internals of the library are relaying on the correct syntax of a docblock
* we cannot simply throw exceptions at all time because the exceptions will break the creation of a
* docklock. Just silently ignore the exceptions is not an option because the user as an issue to fix.
*
* This tag holds that error information until a using application is able to display it. The object will just behave
* like any normal tag. So the normal application flow will not break.
*/
final class InvalidTag implements Tag
{
private string $name;
private string $body;
private ?Throwable $throwable = null;
private function __construct(string $name, string $body)
{
$this->name = $name;
$this->body = $body;
}
public function getException(): ?Throwable
{
return $this->throwable;
}
public function getName(): string
{
return $this->name;
}
public static function create(string $body, string $name = ''): self
{
return new self($name, $body);
}
public function withError(Throwable $exception): self
{
$this->flattenExceptionBacktrace($exception);
$tag = new self($this->name, $this->body);
$tag->throwable = $exception;
return $tag;
}
/**
* Removes all complex types from backtrace
*
* Not all objects are serializable. So we need to remove them from the
* stored exception to be sure that we do not break existing library usage.
*/
private function flattenExceptionBacktrace(Throwable $exception): void
{
$traceProperty = (new ReflectionClass(Exception::class))->getProperty('trace');
if (PHP_VERSION_ID < 80100) {
$traceProperty->setAccessible(true);
}
do {
$trace = $exception->getTrace();
if (isset($trace[0]['args'])) {
$trace = array_map(
function (array $call): array {
$call['args'] = array_map([$this, 'flattenArguments'], $call['args'] ?? []);
return $call;
},
$trace
);
}
$traceProperty->setValue($exception, $trace);
$exception = $exception->getPrevious();
} while ($exception !== null);
if (PHP_VERSION_ID >= 80100) {
return;
}
$traceProperty->setAccessible(false);
}
/**
* @param mixed $value
*
* @return mixed
*
* @throws ReflectionException
*/
private function flattenArguments($value)
{
if ($value instanceof Closure) {
$closureReflection = new ReflectionFunction($value);
$value = sprintf(
'(Closure at %s:%s)',
$closureReflection->getFileName(),
$closureReflection->getStartLine()
);
} elseif (is_object($value)) {
$value = sprintf('object(%s)', get_class($value));
} elseif (is_resource($value)) {
$value = sprintf('resource(%s)', get_resource_type($value));
} elseif (is_array($value)) {
$value = array_map([$this, 'flattenArguments'], $value);
}
return $value;
}
public function render(?Formatter $formatter = null): string
{
if ($formatter === null) {
$formatter = new Formatter\PassthroughFormatter();
}
return $formatter->format($this);
}
public function __toString(): string
{
return $this->body;
}
}
================================================
FILE: src/DocBlock/Tags/Link.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\Utils;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}link tag in a Docblock.
*/
final class Link extends BaseTag
{
protected string $name = 'link';
private string $link;
/**
* Initializes a link to a URL.
*/
public function __construct(string $link, ?Description $description = null)
{
$this->link = $link;
$this->description = $description;
}
public static function create(
string $body,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
Assert::notNull($descriptionFactory);
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
return new static($parts[0], $description);
}
/**
* Gets the link
*/
public function getLink(): string
{
return $this->link;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$link = $this->link;
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Method.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Exception\CannotCreateTag;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Void_;
use Webmozart\Assert\Assert;
use function implode;
/**
* Reflection class for an {@}method in a Docblock.
*/
final class Method extends BaseTag
{
protected string $name = 'method';
private string $methodName;
private bool $isStatic;
private Type $returnType;
private bool $returnsReference;
/** @var MethodParameter[] */
private array $parameters;
/**
* @param MethodParameter[] $parameters
*/
public function __construct(
string $methodName,
array $parameters = [],
?Type $returnType = null,
bool $static = false,
?Description $description = null,
bool $returnsReference = false
) {
Assert::stringNotEmpty($methodName);
if ($returnType === null) {
$returnType = new Void_();
}
$this->methodName = $methodName;
$this->returnType = $returnType;
$this->isStatic = $static;
$this->description = $description;
$this->returnsReference = $returnsReference;
$this->parameters = $parameters;
}
/**
* Retrieves the method name.
*/
public function getMethodName(): string
{
return $this->methodName;
}
/** @return MethodParameter[] */
public function getParameters(): array
{
return $this->parameters;
}
/**
* Checks whether the method tag describes a static method or not.
*
* @return bool TRUE if the method declaration is for a static method, FALSE otherwise.
*/
public function isStatic(): bool
{
return $this->isStatic;
}
public function getReturnType(): Type
{
return $this->returnType;
}
public function returnsReference(): bool
{
return $this->returnsReference;
}
public function __toString(): string
{
$arguments = [];
foreach ($this->parameters as $parameter) {
$arguments[] = (string) $parameter;
}
$argumentStr = '(' . implode(', ', $arguments) . ')';
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$static = $this->isStatic ? 'static' : '';
$returnType = (string) $this->returnType;
$methodName = $this->methodName;
$reference = $this->returnsReference ? '&' : '';
return $static
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')
. ($methodName !== '' ? ($static !== '' || $returnType !== '' ? ' ' : '') . $reference . $methodName : '')
. $argumentStr
. ($description !== '' ? ' ' . $description : '');
}
public static function create(string $body): void
{
throw new CannotCreateTag('Method tag cannot be created');
}
}
================================================
FILE: src/DocBlock/Tags/MethodParameter.php
================================================
<?php
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodParameterFactory;
use phpDocumentor\Reflection\Type;
final class MethodParameter
{
private Type $type;
private bool $isReference;
private bool $isVariadic;
private string $name;
/** @var mixed */
private $defaultValue;
public const NO_DEFAULT_VALUE = '__NO_VALUE__';
/**
* @param mixed $defaultValue
*/
public function __construct(
string $name,
Type $type,
bool $isReference = false,
bool $isVariadic = false,
$defaultValue = self::NO_DEFAULT_VALUE
) {
$this->type = $type;
$this->isReference = $isReference;
$this->isVariadic = $isVariadic;
$this->name = $name;
$this->defaultValue = $defaultValue;
}
public function getName(): string
{
return $this->name;
}
public function getType(): Type
{
return $this->type;
}
public function isReference(): bool
{
return $this->isReference;
}
public function isVariadic(): bool
{
return $this->isVariadic;
}
public function getDefaultValue(): ?string
{
if ($this->defaultValue === self::NO_DEFAULT_VALUE) {
return null;
}
return (new MethodParameterFactory())->format($this->defaultValue);
}
public function __toString(): string
{
return $this->getType() . ' ' .
($this->isReference() ? '&' : '') .
($this->isVariadic() ? '...' : '') .
'$' . $this->getName() .
(
$this->defaultValue !== self::NO_DEFAULT_VALUE ?
' = ' . (new MethodParameterFactory())->format($this->defaultValue) :
''
);
}
}
================================================
FILE: src/DocBlock/Tags/Mixin.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}mixin tag in a Docblock.
*/
final class Mixin extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'mixin';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/Param.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for the {@}param tag in a Docblock.
*/
final class Param extends TagWithType
{
private ?string $variableName = null;
/** @var bool determines whether this is a variadic argument */
private bool $isVariadic;
/** @var bool determines whether this is passed by reference */
private bool $isReference;
public function __construct(
?string $variableName,
?Type $type = null,
bool $isVariadic = false,
?Description $description = null,
bool $isReference = false
) {
$this->name = 'param';
$this->variableName = $variableName;
$this->type = $type;
$this->isVariadic = $isVariadic;
$this->description = $description;
$this->isReference = $isReference;
}
/**
* Returns the variable's name.
*/
public function getVariableName(): ?string
{
return $this->variableName;
}
/**
* Returns whether this tag is variadic.
*/
public function isVariadic(): bool
{
return $this->isVariadic;
}
/**
* Returns whether this tag is passed by reference.
*/
public function isReference(): bool
{
return $this->isReference;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$variableName = '';
if ($this->variableName !== null && $this->variableName !== '') {
$variableName .= ($this->isReference ? '&' : '') . ($this->isVariadic ? '...' : '');
$variableName .= '$' . $this->variableName;
}
$type = (string) $this->type;
return $type
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Property.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}property tag in a Docblock.
*/
final class Property extends TagWithType
{
protected ?string $variableName = null;
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
{
Assert::string($variableName);
$this->name = 'property';
$this->variableName = $variableName;
$this->type = $type;
$this->description = $description;
}
/**
* Returns the variable's name.
*/
public function getVariableName(): ?string
{
return $this->variableName;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description !== null) {
$description = $this->description->render();
} else {
$description = '';
}
if ($this->variableName !== null && $this->variableName !== '') {
$variableName = '$' . $this->variableName;
} else {
$variableName = '';
}
$type = (string) $this->type;
return $type
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/PropertyRead.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}property-read tag in a Docblock.
*/
final class PropertyRead extends TagWithType
{
protected ?string $variableName = null;
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
{
Assert::string($variableName);
$this->name = 'property-read';
$this->variableName = $variableName;
$this->type = $type;
$this->description = $description;
}
/**
* Returns the variable's name.
*/
public function getVariableName(): ?string
{
return $this->variableName;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description !== null) {
$description = $this->description->render();
} else {
$description = '';
}
if ($this->variableName !== null && $this->variableName !== '') {
$variableName = '$' . $this->variableName;
} else {
$variableName = '';
}
$type = (string) $this->type;
return $type
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/PropertyWrite.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}property-write tag in a Docblock.
*/
final class PropertyWrite extends TagWithType
{
protected string $variableName;
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
{
Assert::string($variableName);
$this->name = 'property-write';
$this->variableName = $variableName;
$this->type = $type;
$this->description = $description;
}
/**
* Returns the variable's name.
*/
public function getVariableName(): ?string
{
return $this->variableName;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
if ($this->variableName) {
$variableName = '$' . $this->variableName;
} else {
$variableName = '';
}
$type = (string) $this->type;
return $type
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Reference/Fqsen.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
use phpDocumentor\Reflection\Fqsen as RealFqsen;
/**
* Fqsen reference used by {@see \phpDocumentor\Reflection\DocBlock\Tags\See}
*/
final class Fqsen implements Reference
{
private RealFqsen $fqsen;
public function __construct(RealFqsen $fqsen)
{
$this->fqsen = $fqsen;
}
/**
* @return string string representation of the referenced fqsen
*/
public function __toString(): string
{
return (string) $this->fqsen;
}
}
================================================
FILE: src/DocBlock/Tags/Reference/Reference.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
/**
* Interface for references in {@see \phpDocumentor\Reflection\DocBlock\Tags\See}
*/
interface Reference
{
public function __toString(): string;
}
================================================
FILE: src/DocBlock/Tags/Reference/Url.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
use Webmozart\Assert\Assert;
/**
* Url reference used by {@see \phpDocumentor\Reflection\DocBlock\Tags\See}
*/
final class Url implements Reference
{
private string $uri;
public function __construct(string $uri)
{
Assert::stringNotEmpty($uri);
$this->uri = $uri;
}
public function __toString(): string
{
return $this->uri;
}
}
================================================
FILE: src/DocBlock/Tags/Return_.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}return tag in a Docblock.
*/
final class Return_ extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'return';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/See.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Reference;
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\Utils;
use Webmozart\Assert\Assert;
use function array_key_exists;
use function explode;
use function preg_match;
/**
* Reflection class for an {@}see tag in a Docblock.
*/
final class See extends BaseTag
{
protected string $name = 'see';
protected Reference $refers;
/**
* Initializes this tag.
*/
public function __construct(Reference $refers, ?Description $description = null)
{
$this->refers = $refers;
$this->description = $description;
}
public static function create(
string $body,
?FqsenResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
Assert::notNull($descriptionFactory);
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
// https://tools.ietf.org/html/rfc2396#section-3
if (preg_match('#\w://\w#', $parts[0])) {
return new static(new Url($parts[0]), $description);
}
return new static(new FqsenRef(self::resolveFqsen($parts[0], $typeResolver, $context)), $description);
}
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
{
Assert::notNull($fqsenResolver);
$fqsenParts = explode('::', $parts);
$resolved = $fqsenResolver->resolve($fqsenParts[0], $context);
if (!array_key_exists(1, $fqsenParts)) {
return $resolved;
}
return new Fqsen($resolved . '::' . $fqsenParts[1]);
}
/**
* Returns the ref of this tag.
*/
public function getReference(): Reference
{
return $this->refers;
}
/**
* Returns a string representation of this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$refers = (string) $this->refers;
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Since.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
use function preg_match;
/**
* Reflection class for a {@}since tag in a Docblock.
*/
final class Since extends BaseTag
{
protected string $name = 'since';
/**
* PCRE regular expression matching a version vector.
* Assumes the "x" modifier.
*/
public const REGEX_VECTOR = '(?:
# Normal release vectors.
\d\S*
|
# VCS version vectors. Per PHPCS, they are expected to
# follow the form of the VCS name, followed by ":", followed
# by the version vector itself.
# By convention, popular VCSes like CVS, SVN and GIT use "$"
# around the actual version vector.
[^\s\:]+\:\s*\$[^\$]+\$
)';
/** @var string|null The version vector. */
private ?string $version = null;
public function __construct(?string $version = null, ?Description $description = null)
{
Assert::nullOrNotEmpty($version);
$this->version = $version;
$this->description = $description;
}
public static function create(
?string $body,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): ?self {
if ($body === null || $body === '') {
return new static();
}
$matches = [];
if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) {
return null;
}
Assert::notNull($descriptionFactory);
return new static(
$matches[1],
$descriptionFactory->create($matches[2] ?? '', $context)
);
}
/**
* Gets the version section of the tag.
*/
public function getVersion(): ?string
{
return $this->version;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description !== null) {
$description = $this->description->render();
} else {
$description = '';
}
$version = (string) $this->version;
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Source.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
use function preg_match;
/**
* Reflection class for a {@}source tag in a Docblock.
*/
final class Source extends BaseTag
{
protected string $name = 'source';
/** @var int The starting line, relative to the structural element's location. */
private int $startingLine;
/** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */
private ?int $lineCount = null;
/**
* @param int|string $startingLine should be a to int convertible value
* @param int|string|null $lineCount should be a to int convertible value
*/
public function __construct($startingLine, $lineCount = null, ?Description $description = null)
{
Assert::integerish($startingLine);
Assert::nullOrIntegerish($lineCount);
$this->startingLine = (int) $startingLine;
$this->lineCount = $lineCount !== null ? (int) $lineCount : null;
$this->description = $description;
}
public static function create(
string $body,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
Assert::stringNotEmpty($body);
Assert::notNull($descriptionFactory);
$startingLine = 1;
$lineCount = null;
$description = null;
// Starting line / Number of lines / Description
if (preg_match('/^([1-9]\d*)\s*(?:((?1))\s+)?(.*)$/sux', $body, $matches)) {
$startingLine = (int) $matches[1];
if (isset($matches[2]) && $matches[2] !== '') {
$lineCount = (int) $matches[2];
}
$description = $matches[3];
}
return new static($startingLine, $lineCount, $descriptionFactory->create($description ?? '', $context));
}
/**
* Gets the starting line.
*
* @return int The starting line, relative to the structural element's
* location.
*/
public function getStartingLine(): int
{
return $this->startingLine;
}
/**
* Returns the number of lines.
*
* @return int|null The number of lines, relative to the starting line. NULL
* means "to the end".
*/
public function getLineCount(): ?int
{
return $this->lineCount;
}
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$startingLine = (string) $this->startingLine;
$lineCount = $this->lineCount !== null ? ' ' . $this->lineCount : '';
return $startingLine
. $lineCount
. ($description !== ''
? ' ' . $description
: '');
}
}
================================================
FILE: src/DocBlock/Tags/TagWithType.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\Exception\CannotCreateTag;
use phpDocumentor\Reflection\Type;
abstract class TagWithType extends BaseTag
{
/** @var ?Type */
protected ?Type $type = null;
/**
* Returns the type section of the variable.
*/
public function getType(): ?Type
{
return $this->type;
}
final public static function create(string $body): Tag
{
throw new CannotCreateTag('Typed tag cannot be created');
}
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$type = (string) $this->type;
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Template.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\Exception\CannotCreateTag;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}template tag in a Docblock.
*/
final class Template extends BaseTag
{
/** @var non-empty-string */
private string $templateName;
/** @var ?Type The real type */
private ?Type $bound;
private ?Type $default;
/** @param non-empty-string $templateName */
public function __construct(
string $templateName,
?Type $bound = null,
?Type $default = null,
?Description $description = null
) {
$this->name = 'template';
$this->templateName = $templateName;
$this->bound = $bound;
$this->default = $default;
$this->description = $description;
}
/**
* @deprecated Create using static factory is deprecated,
* this method should not be called directly by library consumers
*/
public static function create(string $body): ?Tag
{
throw new CannotCreateTag('Template tag cannot be created');
}
public function getTemplateName(): string
{
return $this->templateName;
}
public function getBound(): ?Type
{
return $this->bound;
}
public function getDefault(): ?Type
{
return $this->default;
}
public function __toString(): string
{
$bound = $this->bound !== null ? ' of ' . $this->bound : '';
$default = $this->default !== null ? ' = ' . $this->default : '';
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
return $this->templateName . $bound . $default . ($description !== '' ? ' ' . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/TemplateCovariant.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}template-covariant tag in a Docblock.
*/
final class TemplateCovariant extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'template-covariant';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/TemplateExtends.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}template-extends tag in a Docblock.
*/
final class TemplateExtends extends Extends_
{
public function __construct(Type $type, ?Description $description = null)
{
parent::__construct($type, $description);
$this->name = 'template-extends';
}
}
================================================
FILE: src/DocBlock/Tags/TemplateImplements.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}template-implements tag in a Docblock.
*/
final class TemplateImplements extends Implements_
{
public function __construct(Type $type, ?Description $description = null)
{
parent::__construct($type, $description);
$this->name = 'template-implements';
}
}
================================================
FILE: src/DocBlock/Tags/Throws.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
/**
* Reflection class for a {@}throws tag in a Docblock.
*/
final class Throws extends TagWithType
{
public function __construct(Type $type, ?Description $description = null)
{
$this->name = 'throws';
$this->type = $type;
$this->description = $description;
}
}
================================================
FILE: src/DocBlock/Tags/Uses.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use phpDocumentor\Reflection\Utils;
use Webmozart\Assert\Assert;
use function array_key_exists;
use function explode;
/**
* Reflection class for a {@}uses tag in a Docblock.
*/
final class Uses extends BaseTag
{
protected string $name = 'uses';
protected Fqsen $refers;
/**
* Initializes this tag.
*/
public function __construct(Fqsen $refers, ?Description $description = null)
{
$this->refers = $refers;
$this->description = $description;
}
public static function create(
string $body,
?FqsenResolver $resolver = null,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): self {
Assert::notNull($resolver);
Assert::notNull($descriptionFactory);
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
return new static(
self::resolveFqsen($parts[0], $resolver, $context),
$descriptionFactory->create($parts[1] ?? '', $context)
);
}
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
{
Assert::notNull($fqsenResolver);
$fqsenParts = explode('::', $parts);
$resolved = $fqsenResolver->resolve($fqsenParts[0], $context);
if (!array_key_exists(1, $fqsenParts)) {
return $resolved;
}
return new Fqsen($resolved . '::' . $fqsenParts[1]);
}
/**
* Returns the structural element this tag refers to.
*/
public function getReference(): Fqsen
{
return $this->refers;
}
/**
* Returns a string representation of this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$refers = (string) $this->refers;
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Var_.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\Type;
use Webmozart\Assert\Assert;
/**
* Reflection class for a {@}var tag in a Docblock.
*/
final class Var_ extends TagWithType
{
protected ?string $variableName = '';
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
{
Assert::string($variableName);
$this->name = 'var';
$this->variableName = $variableName;
$this->type = $type;
$this->description = $description;
}
/**
* Returns the variable's name.
*/
public function getVariableName(): ?string
{
return $this->variableName;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description !== null) {
$description = $this->description->render();
} else {
$description = '';
}
if ($this->variableName !== null && $this->variableName !== '') {
$variableName = '$' . $this->variableName;
} else {
$variableName = '';
}
$type = (string) $this->type;
return $type
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock/Tags/Version.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert;
use function preg_match;
/**
* Reflection class for a {@}version tag in a Docblock.
*/
final class Version extends BaseTag
{
protected string $name = 'version';
/**
* PCRE regular expression matching a version vector.
* Assumes the "x" modifier.
*/
public const REGEX_VECTOR = '(?:
# Normal release vectors.
\d\S*
|
# VCS version vectors. Per PHPCS, they are expected to
# follow the form of the VCS name, followed by ":", followed
# by the version vector itself.
# By convention, popular VCSes like CVS, SVN and GIT use "$"
# around the actual version vector.
[^\s\:]+\:\s*\$[^\$]+\$
)';
/** @var string|null The version vector. */
private ?string $version = null;
public function __construct(?string $version = null, ?Description $description = null)
{
Assert::nullOrStringNotEmpty($version);
$this->version = $version;
$this->description = $description;
}
public static function create(
?string $body,
?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null
): ?self {
if ($body === null || $body === '') {
return new static();
}
$matches = [];
if (!preg_match('/^(' . self::REGEX_VECTOR . ')\s*(.+)?$/sux', $body, $matches)) {
return null;
}
$description = null;
if ($descriptionFactory !== null) {
$description = $descriptionFactory->create($matches[2] ?? '', $context);
}
return new static(
$matches[1],
$description
);
}
/**
* Gets the version section of the tag.
*/
public function getVersion(): ?string
{
return $this->version;
}
/**
* Returns a string representation for this tag.
*/
public function __toString(): string
{
if ($this->description) {
$description = $this->description->render();
} else {
$description = '';
}
$version = (string) $this->version;
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
}
}
================================================
FILE: src/DocBlock.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
use Webmozart\Assert\Assert;
final class DocBlock
{
/** @var string The opening line for this docblock. */
private string $summary;
/** @var DocBlock\Description The actual description for this docblock. */
private DocBlock\Description $description;
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
private array $tags = [];
/** @var Types\Context|null Information about the context of this DocBlock. */
private ?Types\Context $context = null;
/** @var Location|null Information about the location of this DocBlock. */
private ?Location $location = null;
/** @var bool Is this DocBlock (the start of) a template? */
private bool $isTemplateStart;
/** @var bool Does this DocBlock signify the end of a DocBlock template? */
private bool $isTemplateEnd;
/**
* @param DocBlock\Tag[] $tags
* @param Types\Context $context The context in which the DocBlock occurs.
* @param Location $location The location within the file that this DocBlock occurs in.
*/
public function __construct(
string $summary = '',
?DocBlock\Description $description = null,
array $tags = [],
?Types\Context $context = null,
?Location $location = null,
bool $isTemplateStart = false,
bool $isTemplateEnd = false
) {
Assert::allIsInstanceOf($tags, Tag::class);
$this->summary = $summary;
$this->description = $description ?: new DocBlock\Description('');
foreach ($tags as $tag) {
$this->addTag($tag);
}
$this->context = $context;
$this->location = $location;
$this->isTemplateEnd = $isTemplateEnd;
$this->isTemplateStart = $isTemplateStart;
}
public function getSummary(): string
{
return $this->summary;
}
public function getDescription(): DocBlock\Description
{
return $this->description;
}
/**
* Returns the current context.
*/
public function getContext(): ?Types\Context
{
return $this->context;
}
/**
* Returns the current location.
*/
public function getLocation(): ?Location
{
return $this->location;
}
/**
* Returns whether this DocBlock is the start of a Template section.
*
* A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker
* (`#@+`) that is appended directly after the opening `/**` of a DocBlock.
*
* An example of such an opening is:
*
* ```
* /**#@+
* * My DocBlock
* * /
* ```
*
* The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all
* elements that follow until another DocBlock is found that contains the closing marker (`#@-`).
*
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
*/
public function isTemplateStart(): bool
{
return $this->isTemplateStart;
}
/**
* Returns whether this DocBlock is the end of a Template section.
*
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
*/
public function isTemplateEnd(): bool
{
return $this->isTemplateEnd;
}
/**
* Returns the tags for this DocBlock.
*
* @return Tag[]
*/
public function getTags(): array
{
return $this->tags;
}
/**
* Returns an array of tags matching the given name. If no tags are found
* an empty array is returned.
*
* @param string $name String to search by.
*
* @return Tag[]
*/
public function getTagsByName(string $name): array
{
$result = [];
foreach ($this->getTags() as $tag) {
if ($tag->getName() !== $name) {
continue;
}
$result[] = $tag;
}
return $result;
}
/**
* Returns an array of tags with type matching the given name. If no tags are found
* an empty array is returned.
*
* @param string $name String to search by.
*
* @return TagWithType[]
*/
public function getTagsWithTypeByName(string $name): array
{
$result = [];
foreach ($this->getTagsByName($name) as $tag) {
if (!$tag instanceof TagWithType) {
continue;
}
$result[] = $tag;
}
return $result;
}
/**
* Checks if a tag of a certain type is present in this DocBlock.
*
* @param string $name Tag name to check for.
*/
public function hasTag(string $name): bool
{
foreach ($this->getTags() as $tag) {
if ($tag->getName() === $name) {
return true;
}
}
return false;
}
/**
* Remove a tag from this DocBlock.
*
* @param Tag $tagToRemove The tag to remove.
*/
public function removeTag(Tag $tagToRemove): void
{
foreach ($this->tags as $key => $tag) {
if ($tag === $tagToRemove) {
unset($this->tags[$key]);
break;
}
}
}
/**
* Adds a tag to this DocBlock.
*
* @param Tag $tag The tag to add.
*/
private function addTag(Tag $tag): void
{
$this->tags[] = $tag;
}
}
================================================
FILE: src/DocBlockFactory.php
================================================
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection;
use InvalidArgumentException;
use LogicException;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use Webmozart\Assert\Assert;
use function array_shift;
use function count;
use function explode;
use function is_object;
use function method_exists;
use function preg_match;
use function preg_replace;
use function str_replace;
use function strpos;
use function substr;
use function trim;
final class DocBlockFactory implements DocBlockFactoryInterface
{
private DocBlock\DescriptionFactory $descriptionFactory;
private TagFactory $tagFactory;
/**
* Initializes this factory with the required subcontractors.
*/
public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->tagFactory = $tagFactory;
}
/**
* Factory method for easy instantiation.
*
* @param array<string, class-string<Tag>|Factory> $additionalTags
*/
public static function createInstance(array $additionalTags = []): DocBlockFactoryInterface
{
$fqsenResolver = new FqsenResolver();
$tagFactory = StandardTagFactory::createInstance($fqsenResolver);
$descriptionFactory = new DescriptionFactory($tagFactory);
$docBlockFactory = new self($descriptionFactory, $tagFactory);
foreach ($additionalTags as $tagName => $tagHandler) {
$docBlockFactory->registerTagHandler($tagName, $tagHandler);
}
return $docBlockFactory;
}
/**
* @param object|string $docblock A string containing the DocBlock to parse or an object supporting the
* getDocComment method (such as a ReflectionClass object).
*/
public function create($docblock, ?Types\Context $context = null, ?Location $location = null): DocBlock
{
if (is_object($docblock)) {
if (!method_exists($docblock, 'getDocComment')) {
$exceptionMessage = 'Invalid object passed; the given object must support the getDocComment method';
throw new InvalidArgumentException($exceptionMessage);
}
$docblock = $docblock->getDocComment();
Assert::string($docblock);
}
Assert::stringNotEmpty($docblock);
if ($context === null) {
$context = new Types\Context('');
}
$parts = $this->splitDocBlock($this->stripDocComment($docblock));
[$templateMarker, $summary, $description, $tags] = $parts;
return new DocBlock(
$summary,
$description ? $this->descriptionFactory->create($description, $context) : null,
$this->parseTagBlock($tags, $context),
$context,
$location,
$templateMarker === '#@+',
$templateMarker === '#@-'
);
}
/**
* @param class-string<Tag>|Factory $handler
*/
public function registerTagHandler(string $tagName, $handler): void
{
$this->tagFactory->registerTagHandler($tagName, $handler);
}
/**
* Strips the asterisks from the DocBlock comment.
*
* @param string $comment String containing the comment text.
*/
private function stripDocComment(string $comment): string
{
$comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]?(.*)?#u', '$1', $comment);
Assert::string($comment);
$comment = trim($comment);
// reg ex above is not able to remove */ from a single line docblock
if (substr($comment, -2) === '*/') {
$comment = trim(substr($comment, 0, -2));
}
return str_replace(["\r\n", "\r"], "\n", $comment);
}
// phpcs:disable
/**
* Splits the DocBlock into a template marker, summary, description and block of tags.
*
* @param string $comment Comment to split into the sub-parts.
*
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
*
* @author Mike van Riel <me@mikevanriel.com> for extending the regex with template marker support.
*
* @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split.
*/
private function splitDocBlock(string $comment): array
{
// phpcs:enable
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
// method does not split tags so
gitextract_rmb768rz/
├── .gitattributes
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ ├── documentation.yml
│ └── integrate.yaml
├── .gitignore
├── .yamllint.yaml
├── LICENSE
├── Makefile
├── README.md
├── composer-require-checker.json
├── composer.json
├── docs/
│ ├── contributing.rst
│ ├── examples/
│ │ ├── 01-interpreting-a-simple-docblock.php
│ │ ├── 02-interpreting-tags.php
│ │ ├── 03-reconstituting-a-docblock.php
│ │ ├── 04-adding-your-own-tag.php
│ │ └── playing-with-descriptions/
│ │ └── 02-escaping.php
│ ├── how-to/
│ │ ├── adding-your-own-tag.rst
│ │ ├── index.rst
│ │ ├── interpreting-a-simple-docblock.rst
│ │ ├── interpreting-tags.rst
│ │ └── reconstituting-a-docblock.rst
│ ├── index.rst
│ ├── installation.rst
│ └── upgrade-to-v6.rst
├── phive.xml
├── phpcs.xml.dist
├── phpdoc.dist.xml
├── phpmd.xml.dist
├── phpstan-baseline.neon
├── phpstan.neon
├── phpunit.xml.dist
├── psalm.xml
├── src/
│ ├── DocBlock/
│ │ ├── Description.php
│ │ ├── DescriptionFactory.php
│ │ ├── ExampleFinder.php
│ │ ├── Serializer.php
│ │ ├── StandardTagFactory.php
│ │ ├── Tag.php
│ │ ├── TagFactory.php
│ │ └── Tags/
│ │ ├── Author.php
│ │ ├── BaseTag.php
│ │ ├── Covers.php
│ │ ├── Deprecated.php
│ │ ├── Example.php
│ │ ├── Extends_.php
│ │ ├── Factory/
│ │ │ ├── AbstractPHPStanFactory.php
│ │ │ ├── ExtendsFactory.php
│ │ │ ├── Factory.php
│ │ │ ├── ImplementsFactory.php
│ │ │ ├── MethodFactory.php
│ │ │ ├── MethodParameterFactory.php
│ │ │ ├── MixinFactory.php
│ │ │ ├── PHPStanFactory.php
│ │ │ ├── ParamFactory.php
│ │ │ ├── PropertyFactory.php
│ │ │ ├── PropertyReadFactory.php
│ │ │ ├── PropertyWriteFactory.php
│ │ │ ├── ReturnFactory.php
│ │ │ ├── TemplateCovariantFactory.php
│ │ │ ├── TemplateFactory.php
│ │ │ ├── ThrowsFactory.php
│ │ │ └── VarFactory.php
│ │ ├── Formatter/
│ │ │ ├── AlignFormatter.php
│ │ │ └── PassthroughFormatter.php
│ │ ├── Formatter.php
│ │ ├── Generic.php
│ │ ├── Implements_.php
│ │ ├── InvalidTag.php
│ │ ├── Link.php
│ │ ├── Method.php
│ │ ├── MethodParameter.php
│ │ ├── Mixin.php
│ │ ├── Param.php
│ │ ├── Property.php
│ │ ├── PropertyRead.php
│ │ ├── PropertyWrite.php
│ │ ├── Reference/
│ │ │ ├── Fqsen.php
│ │ │ ├── Reference.php
│ │ │ └── Url.php
│ │ ├── Return_.php
│ │ ├── See.php
│ │ ├── Since.php
│ │ ├── Source.php
│ │ ├── TagWithType.php
│ │ ├── Template.php
│ │ ├── TemplateCovariant.php
│ │ ├── TemplateExtends.php
│ │ ├── TemplateImplements.php
│ │ ├── Throws.php
│ │ ├── Uses.php
│ │ ├── Var_.php
│ │ └── Version.php
│ ├── DocBlock.php
│ ├── DocBlockFactory.php
│ ├── DocBlockFactoryInterface.php
│ ├── Exception/
│ │ ├── CannotCreateTag.php
│ │ ├── ParserException.php
│ │ ├── PcreException.php
│ │ └── ReflectionDocblockException.php
│ └── Utils.php
└── tests/
├── coverage-checker.php
├── integration/
│ ├── DocblockSeeTagResolvingTest.php
│ ├── DocblocksWithAnnotationsTest.php
│ ├── InterpretingDocBlocksTest.php
│ ├── ModifyBackTraceSafeTest.php
│ ├── ReconstitutingADocBlockTest.php
│ ├── TypedTagsTest.php
│ └── UsingTagsTest.php
└── unit/
├── Assets/
│ ├── CustomParam.php
│ ├── CustomServiceClass.php
│ ├── CustomServiceInterface.php
│ └── CustomTagFactory.php
├── DocBlock/
│ ├── DescriptionFactoryTest.php
│ ├── DescriptionTest.php
│ ├── ExampleFinderTest.php
│ ├── SerializerTest.php
│ ├── StandardTagFactoryTest.php
│ └── Tags/
│ ├── AuthorTest.php
│ ├── CoversTest.php
│ ├── DeprecatedTest.php
│ ├── ExampleTest.php
│ ├── ExtendsTest.php
│ ├── Factory/
│ │ ├── AbstractPHPStanFactoryTest.php
│ │ ├── ExtendsFactoryTest.php
│ │ ├── ImplementsFactoryTest.php
│ │ ├── MethodFactoryTest.php
│ │ ├── MixinFactoryTest.php
│ │ ├── ParamFactoryTest.php
│ │ ├── PropertyFactoryTest.php
│ │ ├── PropertyReadFactoryTest.php
│ │ ├── PropertyWriteFactoryTest.php
│ │ ├── ReturnFactoryTest.php
│ │ ├── TagFactoryTestCase.php
│ │ ├── TemplateCovariantFactoryTest.php
│ │ ├── TemplateFactoryTest.php
│ │ ├── ThrowsFactoryTest.php
│ │ └── VarFactoryTest.php
│ ├── Formatter/
│ │ ├── AlignFormatterTest.php
│ │ └── PassthroughFormatterTest.php
│ ├── GenericTest.php
│ ├── ImplementsTest.php
│ ├── InvalidTagTest.php
│ ├── LinkTest.php
│ ├── MethodParameterTest.php
│ ├── MethodTest.php
│ ├── ParamTest.php
│ ├── PropertyReadTest.php
│ ├── PropertyTest.php
│ ├── PropertyWriteTest.php
│ ├── ReturnTest.php
│ ├── SeeTest.php
│ ├── SinceTest.php
│ ├── SourceTest.php
│ ├── TemplateExtendsTest.php
│ ├── TemplateImplementsTest.php
│ ├── TemplateTest.php
│ ├── ThrowsTest.php
│ ├── UsesTest.php
│ ├── VarTest.php
│ └── VersionTest.php
├── DocBlockFactoryTest.php
├── DocBlockTest.php
├── Exception/
│ └── PcreExceptionTest.php
└── PregSplitTest.php
SYMBOL INDEX (779 symbols across 132 files)
FILE: docs/examples/04-adding-your-own-tag.php
class MyTag (line 36) | final class MyTag extends BaseTag
method __construct (line 56) | public function __construct(?Description $description = null)
method create (line 88) | public static function create(string $body, ?DescriptionFactory $descr...
method __toString (line 101) | public function __toString(): string
FILE: src/DocBlock.php
class DocBlock (line 20) | final class DocBlock
method __construct (line 48) | public function __construct(
method getSummary (line 72) | public function getSummary(): string
method getDescription (line 77) | public function getDescription(): DocBlock\Description
method getContext (line 85) | public function getContext(): ?Types\Context
method getLocation (line 93) | public function getLocation(): ?Location
method isTemplateStart (line 117) | public function isTemplateStart(): bool
method isTemplateEnd (line 127) | public function isTemplateEnd(): bool
method getTags (line 137) | public function getTags(): array
method getTagsByName (line 150) | public function getTagsByName(string $name): array
method getTagsWithTypeByName (line 173) | public function getTagsWithTypeByName(string $name): array
method hasTag (line 193) | public function hasTag(string $name): bool
method removeTag (line 209) | public function removeTag(Tag $tagToRemove): void
method addTag (line 224) | private function addTag(Tag $tag): void
FILE: src/DocBlock/Description.php
class Description (line 53) | class Description
method __construct (line 65) | public function __construct(string $bodyTemplate, array $tags = [])
method getBodyTemplate (line 74) | public function getBodyTemplate(): string
method getTags (line 84) | public function getTags(): array
method render (line 93) | public function render(?Formatter $formatter = null): string
method __toString (line 114) | public function __toString(): string
FILE: src/DocBlock/DescriptionFactory.php
class DescriptionFactory (line 49) | class DescriptionFactory
method __construct (line 56) | public function __construct(Factory $tagFactory)
method create (line 64) | public function create(string $contents, ?TypeContext $context = null)...
method lex (line 92) | private function lex(string $contents): array
method removeSuperfluousStartingWhitespace (line 147) | private function removeSuperfluousStartingWhitespace(string $contents)...
FILE: src/DocBlock/ExampleFinder.php
class ExampleFinder (line 32) | class ExampleFinder
method find (line 42) | public function find(Example $example): string
method setSourceDirectory (line 57) | public function setSourceDirectory(string $directory = ''): void
method getSourceDirectory (line 65) | public function getSourceDirectory(): string
method setExampleDirectories (line 75) | public function setExampleDirectories(array $directories): void
method getExampleDirectories (line 85) | public function getExampleDirectories(): array
method getExampleFileContents (line 103) | private function getExampleFileContents(string $filename): ?array
method getExamplePathFromExampleDirectory (line 133) | private function getExamplePathFromExampleDirectory(string $file): string
method constructExamplePath (line 141) | private function constructExamplePath(string $directory, string $file)...
method getExamplePathFromSource (line 149) | private function getExamplePathFromSource(string $file): string
FILE: src/DocBlock/Serializer.php
class Serializer (line 29) | class Serializer
method __construct (line 57) | public function __construct(
method getDocComment (line 80) | public function getDocComment(DocBlock $docblock): string
method removeTrailingSpaces (line 106) | private function removeTrailingSpaces(string $indent, string $text): s...
method addAsterisksForEachLine (line 115) | private function addAsterisksForEachLine(string $indent, string $text)...
method getSummaryAndDescriptionTextBlock (line 124) | private function getSummaryAndDescriptionTextBlock(DocBlock $docblock,...
method addTagBlock (line 137) | private function addTagBlock(DocBlock $docblock, ?int $wrapLength, str...
FILE: src/DocBlock/StandardTagFactory.php
class StandardTagFactory (line 79) | final class StandardTagFactory implements TagFactory
method __construct (line 120) | private function __construct(FqsenResolver $fqsenResolver)
method createInstance (line 132) | public static function createInstance(FqsenResolver $fqsenResolver): self
method create (line 176) | public function create(string $tagLine, ?TypeContext $context = null):...
method addParameter (line 190) | public function addParameter(string $name, $value): void
method addService (line 195) | public function addService(object $service, ?string $alias = null): void
method registerTagHandler (line 201) | public function registerTagHandler(string $tagName, $handler): void
method extractTagParts (line 227) | private function extractTagParts(string $tagLine): array
method createTag (line 243) | private function createTag(string $body, string $name, TypeContext $co...
method findHandlerClassName (line 272) | private function findHandlerClassName(string $tagName, TypeContext $co...
method getArgumentsForParametersFromWiring (line 297) | private function getArgumentsForParametersFromWiring(array $parameters...
method fetchParametersForHandlerFactoryMethod (line 338) | private function fetchParametersForHandlerFactoryMethod($handler): array
method getServiceLocatorWithDynamicParameters (line 363) | private function getServiceLocatorWithDynamicParameters(
method isAnnotation (line 383) | private function isAnnotation(string $tagContent): bool
FILE: src/DocBlock/Tag.php
type Tag (line 18) | interface Tag
method getName (line 20) | public function getName(): string;
method create (line 26) | public static function create(string $body);
method render (line 28) | public function render(?Formatter $formatter = null): string;
method __toString (line 30) | public function __toString(): string;
FILE: src/DocBlock/TagFactory.php
type TagFactory (line 19) | interface TagFactory extends Factory
method addParameter (line 41) | public function addParameter(string $name, $value): void;
method addService (line 52) | public function addService(object $service): void;
method registerTagHandler (line 72) | public function registerTagHandler(string $tagName, $handler): void;
FILE: src/DocBlock/Tags/Author.php
class Author (line 27) | final class Author extends BaseTag
method __construct (line 41) | public function __construct(string $authorName, string $authorEmail)
method getAuthorName (line 56) | public function getAuthorName(): string
method getEmail (line 66) | public function getEmail(): string
method __toString (line 74) | public function __toString(): string
method create (line 90) | public static function create(string $body): ?self
FILE: src/DocBlock/Tags/BaseTag.php
class BaseTag (line 22) | abstract class BaseTag implements DocBlock\Tag
method getName (line 35) | public function getName(): string
method getDescription (line 40) | public function getDescription(): ?Description
method render (line 45) | public function render(?Formatter $formatter = null): string
FILE: src/DocBlock/Tags/Covers.php
class Covers (line 30) | final class Covers extends BaseTag
method __construct (line 39) | public function __construct(Fqsen $refers, ?Description $description =...
method create (line 45) | public static function create(
method resolveFqsen (line 63) | private static function resolveFqsen(string $parts, ?FqsenResolver $fq...
method getReference (line 79) | public function getReference(): Fqsen
method __toString (line 87) | public function __toString(): string
FILE: src/DocBlock/Tags/Deprecated.php
class Deprecated (line 26) | final class Deprecated extends BaseTag
method __construct (line 49) | public function __construct(?string $version = null, ?Description $des...
method create (line 60) | public static function create(
method getVersion (line 88) | public function getVersion(): ?string
method __toString (line 96) | public function __toString(): string
FILE: src/DocBlock/Tags/Example.php
class Example (line 29) | final class Example implements Tag
method __construct (line 46) | public function __construct(
method getContent (line 67) | public function getContent(): string
method getDescription (line 83) | public function getDescription(): ?string
method create (line 88) | public static function create(string $body): ?Tag
method getFilePath (line 138) | public function getFilePath(): string
method __toString (line 146) | public function __toString(): string
method isUriRelative (line 169) | private function isUriRelative(string $uri): bool
method getStartingLine (line 174) | public function getStartingLine(): int
method getLineCount (line 179) | public function getLineCount(): int
method getName (line 184) | public function getName(): string
method render (line 189) | public function render(?Formatter $formatter = null): string
FILE: src/DocBlock/Tags/Extends_.php
class Extends_ (line 22) | class Extends_ extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php
class AbstractPHPStanFactory (line 41) | class AbstractPHPStanFactory implements Factory
method __construct (line 48) | public function __construct(PHPStanFactory ...$factories)
method create (line 62) | public function create(string $tagLine, ?TypeContext $context = null):...
method tokenizeLine (line 106) | private function tokenizeLine(string $tagLine): TokenIterator
FILE: src/DocBlock/Tags/Factory/ExtendsFactory.php
class ExtendsFactory (line 21) | final class ExtendsFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method supports (line 32) | public function supports(PhpDocTagNode $node, Context $context): bool
method create (line 37) | public function create(PhpDocTagNode $node, Context $context): Tag
FILE: src/DocBlock/Tags/Factory/Factory.php
type Factory (line 29) | interface Factory
method create (line 40) | public function create(string $tagLine, ?TypeContext $context = null):...
FILE: src/DocBlock/Tags/Factory/ImplementsFactory.php
class ImplementsFactory (line 21) | final class ImplementsFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method supports (line 32) | public function supports(PhpDocTagNode $node, Context $context): bool
method create (line 37) | public function create(PhpDocTagNode $node, Context $context): Tag
FILE: src/DocBlock/Tags/Factory/MethodFactory.php
class MethodFactory (line 27) | final class MethodFactory implements PHPStanFactory
method __construct (line 32) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 38) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 69) | public function supports(PhpDocTagNode $node, Context $context): bool
method createReturnType (line 74) | private function createReturnType(MethodTagValueNode $tagValue, Contex...
FILE: src/DocBlock/Tags/Factory/MethodParameterFactory.php
class MethodParameterFactory (line 26) | final class MethodParameterFactory
method format (line 33) | public function format($defaultValue): string
method formatDouble (line 43) | private function formatDouble(float $defaultValue): string
method formatNull (line 51) | private function formatNull($defaultValue): string
method formatInteger (line 56) | private function formatInteger(int $defaultValue): string
method formatString (line 61) | private function formatString(string $defaultValue): string
method formatBoolean (line 66) | private function formatBoolean(bool $defaultValue): string
method formatArray (line 74) | private function formatArray(array $defaultValue): string
method formatObject (line 96) | private function formatObject(object $defaultValue): string
FILE: src/DocBlock/Tags/Factory/MixinFactory.php
class MixinFactory (line 21) | final class MixinFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 32) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 48) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/PHPStanFactory.php
type PHPStanFactory (line 11) | interface PHPStanFactory
method create (line 13) | public function create(PhpDocTagNode $node, Context $context): Tag;
method supports (line 15) | public function supports(PhpDocTagNode $node, Context $context): bool;
FILE: src/DocBlock/Tags/Factory/ParamFactory.php
class ParamFactory (line 28) | final class ParamFactory implements PHPStanFactory
method __construct (line 33) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 39) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 78) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/PropertyFactory.php
class PropertyFactory (line 22) | final class PropertyFactory implements PHPStanFactory
method __construct (line 27) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 33) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 50) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/PropertyReadFactory.php
class PropertyReadFactory (line 22) | final class PropertyReadFactory implements PHPStanFactory
method __construct (line 27) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 33) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 50) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/PropertyWriteFactory.php
class PropertyWriteFactory (line 22) | final class PropertyWriteFactory implements PHPStanFactory
method __construct (line 27) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 33) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 50) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/ReturnFactory.php
class ReturnFactory (line 21) | final class ReturnFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 32) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 48) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/TemplateCovariantFactory.php
class TemplateCovariantFactory (line 22) | final class TemplateCovariantFactory implements PHPStanFactory
method __construct (line 27) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method supports (line 33) | public function supports(PhpDocTagNode $node, Context $context): bool
method create (line 38) | public function create(PhpDocTagNode $node, Context $context): Tag
FILE: src/DocBlock/Tags/Factory/TemplateFactory.php
class TemplateFactory (line 21) | final class TemplateFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 32) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 52) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/ThrowsFactory.php
class ThrowsFactory (line 21) | final class ThrowsFactory implements PHPStanFactory
method __construct (line 26) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 32) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 48) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Factory/VarFactory.php
class VarFactory (line 22) | final class VarFactory implements PHPStanFactory
method __construct (line 27) | public function __construct(TypeResolver $typeResolver, DescriptionFac...
method create (line 33) | public function create(PhpDocTagNode $node, Context $context): Tag
method supports (line 50) | public function supports(PhpDocTagNode $node, Context $context): bool
FILE: src/DocBlock/Tags/Formatter.php
type Formatter (line 18) | interface Formatter
method format (line 23) | public function format(Tag $tag): string;
FILE: src/DocBlock/Tags/Formatter/AlignFormatter.php
class AlignFormatter (line 23) | class AlignFormatter implements Formatter
method __construct (line 31) | public function __construct(array $tags)
method format (line 41) | public function format(Tag $tag): string
FILE: src/DocBlock/Tags/Formatter/PassthroughFormatter.php
class PassthroughFormatter (line 21) | class PassthroughFormatter implements Formatter
method format (line 26) | public function format(Tag $tag): string
FILE: src/DocBlock/Tags/Generic.php
class Generic (line 28) | final class Generic extends BaseTag
method __construct (line 36) | public function __construct(string $name, ?Description $description = ...
method create (line 49) | public static function create(
method __toString (line 66) | public function __toString(): string
method validateTagName (line 80) | private function validateTagName(string $name): void
FILE: src/DocBlock/Tags/Implements_.php
class Implements_ (line 22) | class Implements_ extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/InvalidTag.php
class InvalidTag (line 35) | final class InvalidTag implements Tag
method __construct (line 43) | private function __construct(string $name, string $body)
method getException (line 49) | public function getException(): ?Throwable
method getName (line 54) | public function getName(): string
method create (line 59) | public static function create(string $body, string $name = ''): self
method withError (line 64) | public function withError(Throwable $exception): self
method flattenExceptionBacktrace (line 79) | private function flattenExceptionBacktrace(Throwable $exception): void
method flattenArguments (line 117) | private function flattenArguments($value)
method render (line 137) | public function render(?Formatter $formatter = null): string
method __toString (line 146) | public function __toString(): string
FILE: src/DocBlock/Tags/Link.php
class Link (line 25) | final class Link extends BaseTag
method __construct (line 34) | public function __construct(string $link, ?Description $description = ...
method create (line 40) | public static function create(
method getLink (line 56) | public function getLink(): string
method __toString (line 64) | public function __toString(): string
FILE: src/DocBlock/Tags/Method.php
class Method (line 27) | final class Method extends BaseTag
method __construct (line 45) | public function __construct(
method getMethodName (line 70) | public function getMethodName(): string
method getParameters (line 76) | public function getParameters(): array
method isStatic (line 86) | public function isStatic(): bool
method getReturnType (line 91) | public function getReturnType(): Type
method returnsReference (line 96) | public function returnsReference(): bool
method __toString (line 101) | public function __toString(): string
method create (line 131) | public static function create(string $body): void
FILE: src/DocBlock/Tags/MethodParameter.php
class MethodParameter (line 18) | final class MethodParameter
method __construct (line 36) | public function __construct(
method getName (line 50) | public function getName(): string
method getType (line 55) | public function getType(): Type
method isReference (line 60) | public function isReference(): bool
method isVariadic (line 65) | public function isVariadic(): bool
method getDefaultValue (line 70) | public function getDefaultValue(): ?string
method __toString (line 79) | public function __toString(): string
FILE: src/DocBlock/Tags/Mixin.php
class Mixin (line 22) | final class Mixin extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/Param.php
class Param (line 22) | final class Param extends TagWithType
method __construct (line 32) | public function __construct(
method getVariableName (line 50) | public function getVariableName(): ?string
method isVariadic (line 58) | public function isVariadic(): bool
method isReference (line 66) | public function isReference(): bool
method __toString (line 74) | public function __toString(): string
FILE: src/DocBlock/Tags/Property.php
class Property (line 23) | final class Property extends TagWithType
method __construct (line 27) | public function __construct(?string $variableName, ?Type $type = null,...
method getVariableName (line 40) | public function getVariableName(): ?string
method __toString (line 48) | public function __toString(): string
FILE: src/DocBlock/Tags/PropertyRead.php
class PropertyRead (line 23) | final class PropertyRead extends TagWithType
method __construct (line 27) | public function __construct(?string $variableName, ?Type $type = null,...
method getVariableName (line 40) | public function getVariableName(): ?string
method __toString (line 48) | public function __toString(): string
FILE: src/DocBlock/Tags/PropertyWrite.php
class PropertyWrite (line 23) | final class PropertyWrite extends TagWithType
method __construct (line 27) | public function __construct(?string $variableName, ?Type $type = null,...
method getVariableName (line 40) | public function getVariableName(): ?string
method __toString (line 48) | public function __toString(): string
FILE: src/DocBlock/Tags/Reference/Fqsen.php
class Fqsen (line 21) | final class Fqsen implements Reference
method __construct (line 25) | public function __construct(RealFqsen $fqsen)
method __toString (line 33) | public function __toString(): string
FILE: src/DocBlock/Tags/Reference/Reference.php
type Reference (line 19) | interface Reference
method __toString (line 21) | public function __toString(): string;
FILE: src/DocBlock/Tags/Reference/Url.php
class Url (line 21) | final class Url implements Reference
method __construct (line 25) | public function __construct(string $uri)
method __toString (line 31) | public function __toString(): string
FILE: src/DocBlock/Tags/Return_.php
class Return_ (line 22) | final class Return_ extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/See.php
class See (line 34) | final class See extends BaseTag
method __construct (line 43) | public function __construct(Reference $refers, ?Description $descripti...
method create (line 49) | public static function create(
method resolveFqsen (line 68) | private static function resolveFqsen(string $parts, ?FqsenResolver $fq...
method getReference (line 84) | public function getReference(): Reference
method __toString (line 92) | public function __toString(): string
FILE: src/DocBlock/Tags/Since.php
class Since (line 26) | final class Since extends BaseTag
method __construct (line 49) | public function __construct(?string $version = null, ?Description $des...
method create (line 57) | public static function create(
method getVersion (line 82) | public function getVersion(): ?string
method __toString (line 90) | public function __toString(): string
FILE: src/DocBlock/Tags/Source.php
class Source (line 26) | final class Source extends BaseTag
method __construct (line 40) | public function __construct($startingLine, $lineCount = null, ?Descrip...
method create (line 50) | public static function create(
method getStartingLine (line 81) | public function getStartingLine(): int
method getLineCount (line 92) | public function getLineCount(): ?int
method __toString (line 97) | public function __toString(): string
FILE: src/DocBlock/Tags/TagWithType.php
class TagWithType (line 20) | abstract class TagWithType extends BaseTag
method getType (line 28) | public function getType(): ?Type
method create (line 33) | final public static function create(string $body): Tag
method __toString (line 38) | public function __toString(): string
FILE: src/DocBlock/Tags/Template.php
class Template (line 24) | final class Template extends BaseTag
method __construct (line 35) | public function __construct(
method create (line 52) | public static function create(string $body): ?Tag
method getTemplateName (line 57) | public function getTemplateName(): string
method getBound (line 62) | public function getBound(): ?Type
method getDefault (line 67) | public function getDefault(): ?Type
method __toString (line 72) | public function __toString(): string
FILE: src/DocBlock/Tags/TemplateCovariant.php
class TemplateCovariant (line 22) | final class TemplateCovariant extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/TemplateExtends.php
class TemplateExtends (line 22) | final class TemplateExtends extends Extends_
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/TemplateImplements.php
class TemplateImplements (line 22) | final class TemplateImplements extends Implements_
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/Throws.php
class Throws (line 22) | final class Throws extends TagWithType
method __construct (line 24) | public function __construct(Type $type, ?Description $description = null)
FILE: src/DocBlock/Tags/Uses.php
class Uses (line 30) | final class Uses extends BaseTag
method __construct (line 39) | public function __construct(Fqsen $refers, ?Description $description =...
method create (line 45) | public static function create(
method resolveFqsen (line 62) | private static function resolveFqsen(string $parts, ?FqsenResolver $fq...
method getReference (line 78) | public function getReference(): Fqsen
method __toString (line 86) | public function __toString(): string
FILE: src/DocBlock/Tags/Var_.php
class Var_ (line 23) | final class Var_ extends TagWithType
method __construct (line 27) | public function __construct(?string $variableName, ?Type $type = null,...
method getVariableName (line 40) | public function getVariableName(): ?string
method __toString (line 48) | public function __toString(): string
FILE: src/DocBlock/Tags/Version.php
class Version (line 26) | final class Version extends BaseTag
method __construct (line 49) | public function __construct(?string $version = null, ?Description $des...
method create (line 57) | public static function create(
method getVersion (line 85) | public function getVersion(): ?string
method __toString (line 93) | public function __toString(): string
FILE: src/DocBlockFactory.php
class DocBlockFactory (line 37) | final class DocBlockFactory implements DocBlockFactoryInterface
method __construct (line 46) | public function __construct(DescriptionFactory $descriptionFactory, Ta...
method createInstance (line 57) | public static function createInstance(array $additionalTags = []): Doc...
method create (line 75) | public function create($docblock, ?Types\Context $context = null, ?Loc...
method registerTagHandler (line 112) | public function registerTagHandler(string $tagName, $handler): void
method stripDocComment (line 122) | private function stripDocComment(string $comment): string
method splitDocBlock (line 149) | private function splitDocBlock(string $comment): array
method parseTagBlock (line 232) | private function parseTagBlock(string $tags, Types\Context $context): ...
method splitTagBlockIntoTagLines (line 251) | private function splitTagBlockIntoTagLines(string $tags): array
method filterTagBlock (line 265) | private function filterTagBlock(string $tags): ?string
FILE: src/DocBlockFactoryInterface.php
type DocBlockFactoryInterface (line 10) | interface DocBlockFactoryInterface
method createInstance (line 17) | public static function createInstance(array $additionalTags = []): self;
method create (line 22) | public function create($docblock, ?Types\Context $context = null, ?Loc...
FILE: src/Exception/CannotCreateTag.php
class CannotCreateTag (line 9) | final class CannotCreateTag extends LogicException
FILE: src/Exception/ParserException.php
class ParserException (line 9) | final class ParserException extends InvalidArgumentException implements ...
method from (line 11) | public static function from(\PHPStan\PhpDocParser\Parser\ParserExcepti...
FILE: src/Exception/PcreException.php
class PcreException (line 17) | final class PcreException extends InvalidArgumentException
method createFromPhpError (line 19) | public static function createFromPhpError(int $errorCode): self
FILE: src/Exception/ReflectionDocblockException.php
type ReflectionDocblockException (line 9) | interface ReflectionDocblockException extends Throwable
FILE: src/Utils.php
class Utils (line 22) | abstract class Utils
method pregSplit (line 51) | public static function pregSplit(string $pattern, string $subject, int...
FILE: tests/integration/DocblockSeeTagResolvingTest.php
class DocblockSeeTagResolvingTest (line 14) | class DocblockSeeTagResolvingTest extends TestCase
method testResolvesSeeFQSENOfInlineTags (line 16) | public function testResolvesSeeFQSENOfInlineTags()
FILE: tests/integration/DocblocksWithAnnotationsTest.php
class DocblocksWithAnnotationsTest (line 22) | final class DocblocksWithAnnotationsTest extends TestCase
method tearDown (line 27) | public function tearDown(): void
method testDocblockWithAnnotations (line 32) | public function testDocblockWithAnnotations(): void
method testDocblockWithAnnotationHavingZeroValue (line 48) | public function testDocblockWithAnnotationHavingZeroValue(): void
FILE: tests/integration/InterpretingDocBlocksTest.php
class InterpretingDocBlocksTest (line 45) | class InterpretingDocBlocksTest extends TestCase
method tearDown (line 50) | public function tearDown(): void
method testInterpretingSummaryWithEllipsis (line 55) | public function testInterpretingSummaryWithEllipsis(): void
method testInterpretingASimpleDocBlock (line 80) | public function testInterpretingASimpleDocBlock(): void
method testInterpretingTags (line 112) | public function testInterpretingTags(): void
method testDescriptionsCanEscapeAtSignsAndClosingBraces (line 137) | public function testDescriptionsCanEscapeAtSignsAndClosingBraces(): void
method testMultilineTags (line 172) | public function testMultilineTags(): void
method testMethodRegression (line 204) | public function testMethodRegression(): void
method testInvalidTypeParamResultsInInvalidTag (line 233) | public function testInvalidTypeParamResultsInInvalidTag(): void
method testConstantReferenceTypes (line 267) | public function testConstantReferenceTypes(): void
method testRegressionWordpressDocblocks (line 286) | public function testRegressionWordpressDocblocks(): void
method testIndentationIsKept (line 377) | public function testIndentationIsKept(): void
method testProcessTemplateTag (line 444) | public function testProcessTemplateTag(): void
method testParamTagDescriptionIsCorrectly (line 475) | public function testParamTagDescriptionIsCorrectly(): void
method testParamBlockDescriptionPreservesStarContinuationLines (line 493) | public function testParamBlockDescriptionPreservesStarContinuationLine...
FILE: tests/integration/ModifyBackTraceSafeTest.php
class ModifyBackTraceSafeTest (line 13) | class ModifyBackTraceSafeTest extends TestCase
method testBackTraceModificationDoesNotImpactFunctionArguments (line 18) | public function testBackTraceModificationDoesNotImpactFunctionArguments()
class Node (line 30) | class Node {
class Traverser (line 34) | class Traverser
method traverse (line 36) | public function traverse(array $nodes)
method traverseArray (line 41) | public function traverseArray(array $nodes): array
method callback (line 55) | public function callback(Node $class) : Node
method traverseNode (line 70) | private function traverseNode(Node $node) : Node
FILE: tests/integration/ReconstitutingADocBlockTest.php
class ReconstitutingADocBlockTest (line 25) | class ReconstitutingADocBlockTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testReconstituteADocBlock (line 35) | public function testReconstituteADocBlock(): void
method testDescriptionCanContainPercent (line 61) | public function testDescriptionCanContainPercent(): void
FILE: tests/integration/TypedTagsTest.php
class TypedTagsTest (line 30) | final class TypedTagsTest extends TestCase
method testParamFormats (line 33) | public function testParamFormats(string $type, Type $expectedType): void
method testVarFormats (line 49) | public function testVarFormats(string $type, Type $expectedType): void
method testMethodFormats (line 65) | public function testMethodFormats(string $type, Type $expectedType): void
method testInvalidParam (line 82) | public function testInvalidParam(string $type): void
method testInvalidMethod (line 99) | public function testInvalidMethod(string $type): void
method typeProvider (line 115) | public static function typeProvider(): array
method invalidFormatsProvider (line 180) | public static function invalidFormatsProvider(): \Generator
FILE: tests/integration/UsingTagsTest.php
class UsingTagsTest (line 24) | class UsingTagsTest extends TestCase
method tearDown (line 29) | public function tearDown(): void
method testAddingYourOwnTagUsingAStaticMethodAsFactory (line 34) | public function testAddingYourOwnTagUsingAStaticMethodAsFactory(): void
FILE: tests/unit/Assets/CustomParam.php
class CustomParam (line 11) | final class CustomParam implements Tag
method getName (line 19) | public function getName() : string
method create (line 24) | public static function create(string $body, ?FqsenResolver $fqsenResol...
method render (line 33) | public function render(?Formatter $formatter = null) : string
method __toString (line 38) | public function __toString() : string
FILE: tests/unit/Assets/CustomServiceClass.php
class CustomServiceClass (line 11) | final class CustomServiceClass implements Tag
method getName (line 16) | public function getName() : string
method create (line 21) | public static function create(string $body, ?PassthroughFormatter $for...
method render (line 29) | public function render(?Formatter $formatter = null) : string
method __toString (line 34) | public function __toString() : string
FILE: tests/unit/Assets/CustomServiceInterface.php
class CustomServiceInterface (line 12) | final class CustomServiceInterface implements Tag
method getName (line 17) | public function getName() : string
method create (line 22) | public static function create(string $body, ?Formatter $formatter = null)
method render (line 30) | public function render(?Formatter $formatter = null) : string
method __toString (line 35) | public function __toString() : string
FILE: tests/unit/Assets/CustomTagFactory.php
class CustomTagFactory (line 21) | class CustomTagFactory implements Factory
method create (line 26) | public function create(string $tagLine, ?Context $context = null, ?Cus...
FILE: tests/unit/DocBlock/DescriptionFactoryTest.php
class DescriptionFactoryTest (line 30) | class DescriptionFactoryTest extends TestCase
method tearDown (line 35) | public function tearDown(): void
method testDescriptionCanParseASimpleString (line 47) | public function testDescriptionCanParseASimpleString(string $contents)...
method testEscapeSequences (line 65) | public function testEscapeSequences(string $contents, string $expected...
method testDescriptionCanParseAStringWithInlineTag (line 86) | public function testDescriptionCanParseAStringWithInlineTag(): void
method testDescriptionCanParseAStringStartingWithInlineTag (line 112) | public function testDescriptionCanParseAStringStartingWithInlineTag():...
method testDescriptionCanParseAStringContainingMultipleTags (line 138) | public function testDescriptionCanParseAStringContainingMultipleTags()...
method testIfSuperfluousStartingSpacesAreRemoved (line 165) | public function testIfSuperfluousStartingSpacesAreRemoved(): void
method testDescriptionWithBrokenInlineTags (line 210) | public function testDescriptionWithBrokenInlineTags(): void
method provideSimpleExampleDescriptions (line 231) | public function provideSimpleExampleDescriptions(): array
method provideEscapeSequences (line 244) | public function provideEscapeSequences(): array
FILE: tests/unit/DocBlock/DescriptionTest.php
class DescriptionTest (line 24) | class DescriptionTest extends TestCase
method tearDown (line 29) | public function tearDown(): void
method testDescriptionCanRenderUsingABodyWithPlaceholdersAndTags (line 42) | public function testDescriptionCanRenderUsingABodyWithPlaceholdersAndT...
method testDescriptionCanBeCastToString (line 68) | public function testDescriptionCanBeCastToString(): void
method testDescriptionTagsGetter (line 85) | public function testDescriptionTagsGetter(): void
method testDescriptionBodyTemplateGetter (line 110) | public function testDescriptionBodyTemplateGetter(): void
method testDescriptionMultipleTagsCanBeCastToString (line 128) | public function testDescriptionMultipleTagsCanBeCastToString(): void
method testDescriptionWithEscapedCharactersAndNoTagsCanBeCastToString (line 153) | public function testDescriptionWithEscapedCharactersAndNoTagsCanBeCast...
FILE: tests/unit/DocBlock/ExampleFinderTest.php
class ExampleFinderTest (line 15) | class ExampleFinderTest extends TestCase
method tearDown (line 22) | public function tearDown(): void
method setUp (line 27) | public function setUp(): void
method testFileNotFound (line 39) | public function testFileNotFound(): void
FILE: tests/unit/DocBlock/SerializerTest.php
class SerializerTest (line 28) | class SerializerTest extends TestCase
method tearDown (line 33) | public function tearDown(): void
method testReconstructsADocCommentFromADocBlock (line 48) | public function testReconstructsADocCommentFromADocBlock(): void
method testAddPrefixToDocBlock (line 83) | public function testAddPrefixToDocBlock(): void
method testAddPrefixToDocBlockExceptFirstLine (line 118) | public function testAddPrefixToDocBlockExceptFirstLine(): void
method testWordwrapsAroundTheGivenAmountOfCharacters (line 153) | public function testWordwrapsAroundTheGivenAmountOfCharacters(): void
method testNoExtraSpacesAfterTagRemoval (line 188) | public function testNoExtraSpacesAfterTagRemoval(): void
method assertSameString (line 211) | public function assertSameString(string $expected, string $actual): void
FILE: tests/unit/DocBlock/StandardTagFactoryTest.php
class StandardTagFactoryTest (line 52) | class StandardTagFactoryTest extends TestCase
method tearDown (line 57) | public function tearDown(): void
method testCreatingAGenericTag (line 71) | public function testCreatingAGenericTag(): void
method testCreatingAGenericTagWithDescriptionText (line 104) | public function testCreatingAGenericTagWithDescriptionText(): void
method testCreatingASpecificTag (line 127) | public function testCreatingASpecificTag(): void
method testAnEmptyContextIsCreatedIfNoneIsProvided (line 148) | public function testAnEmptyContextIsCreatedIfNoneIsProvided(): void
method testPassingYourOwnSetOfTagHandlers (line 176) | public function testPassingYourOwnSetOfTagHandlers(): void
method testPassingYourOwnSetOfTagHandlersWithGermanChars (line 196) | public function testPassingYourOwnSetOfTagHandlersWithGermanChars(): void
method testPassingYourOwnSetOfTagHandlersWithoutComment (line 219) | public function testPassingYourOwnSetOfTagHandlersWithoutComment(): void
method testTagWithHandlerObject (line 232) | public function testTagWithHandlerObject(): void
method testPassingYourOwnSetOfTagHandlersWithEmptyComment (line 256) | public function testPassingYourOwnSetOfTagHandlersWithEmptyComment(): ...
method testExceptionIsThrownIfProvidedTagIsNotWellformed (line 279) | public function testExceptionIsThrownIfProvidedTagIsNotWellformed(): void
method testAddParameterToServiceLocator (line 295) | public function testAddParameterToServiceLocator(): void
method testAddServiceToServiceLocator (line 314) | public function testAddServiceToServiceLocator(): void
method testInjectConcreteServiceForInterfaceToServiceLocator (line 334) | public function testInjectConcreteServiceForInterfaceToServiceLocator(...
method testRegisteringAHandlerForANewTag (line 358) | public function testRegisteringAHandlerForANewTag(): void
method testHandlerRegistrationFailsIfProvidedTagNameIsNamespaceButNotFullyQualified (line 376) | public function testHandlerRegistrationFailsIfProvidedTagNameIsNamespa...
method testHandlerRegistrationFailsIfProvidedHandlerIsEmpty (line 394) | public function testHandlerRegistrationFailsIfProvidedHandlerIsEmpty()...
method testHandlerRegistrationFailsIfProvidedHandlerIsNotAnExistingClassName (line 409) | public function testHandlerRegistrationFailsIfProvidedHandlerIsNotAnEx...
method testHandlerRegistrationFailsIfProvidedHandlerDoesNotImplementTheTagInterface (line 425) | public function testHandlerRegistrationFailsIfProvidedHandlerDoesNotIm...
method testReturnTagIsMappedCorrectly (line 444) | public function testReturnTagIsMappedCorrectly(): void
method testValidFormattedTags (line 470) | public function testValidFormattedTags(string $input, string $tagName,...
method validTagProvider (line 485) | public function validTagProvider(): array
method testInValidFormattedTags (line 540) | public function testInValidFormattedTags(string $input): void
method invalidTagProvider (line 553) | public function invalidTagProvider(): array
method testCreateWithTagWithTypes (line 566) | public function testCreateWithTagWithTypes(string $input, string $expe...
method provideCreateWithTagWithTypesData (line 577) | public static function provideCreateWithTagWithTypesData(): array
FILE: tests/unit/DocBlock/Tags/AuthorTest.php
class AuthorTest (line 23) | class AuthorTest extends TestCase
method tearDown (line 28) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 38) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 53) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 65) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasTheAuthorName (line 79) | public function testHasTheAuthorName(): void
method testHasTheAuthorMailAddress (line 93) | public function testHasTheAuthorMailAddress(): void
method testInitializationFailsIfEmailIsNotValid (line 106) | public function testInitializationFailsIfEmailIsNotValid(): void
method testStringRepresentationIsReturned (line 116) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutName (line 133) | public function testStringRepresentationIsReturnedWithoutName(): void
method testStringRepresentationWithEmptyEmail (line 144) | public function testStringRepresentationWithEmptyEmail(): void
method testFactoryMethod (line 157) | public function testFactoryMethod(string $input, string $output, strin...
method authorTagProvider (line 168) | public function authorTagProvider(): array
method testFactoryMethodReturnsNullIfItCouldNotReadBody (line 197) | public function testFactoryMethodReturnsNullIfItCouldNotReadBody(): void
FILE: tests/unit/DocBlock/Tags/CoversTest.php
class CoversTest (line 29) | class CoversTest extends TestCase
method tearDown (line 34) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 45) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 61) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 74) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasReferenceToFqsen (line 88) | public function testHasReferenceToFqsen(): void
method testHasDescription (line 103) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 118) | public function testStringRepresentationIsReturned(): void
method testFactoryMethod (line 135) | public function testFactoryMethod(): void
method testStringRepresentationIsReturnedWithoutDescription (line 159) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethodWithSpaceBeforeClass (line 188) | public function testFactoryMethodWithSpaceBeforeClass(): void
method testStringRepresentationIsReturnedWithDescription (line 210) | public function testStringRepresentationIsReturnedWithDescription(): void
method testFactoryMethodFailsIfBodyIsNotEmpty (line 220) | public function testFactoryMethodFailsIfBodyIsNotEmpty(): void
FILE: tests/unit/DocBlock/Tags/DeprecatedTest.php
class DeprecatedTest (line 26) | class DeprecatedTest extends TestCase
method tearDown (line 31) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 42) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 71) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVersionNumber (line 85) | public function testHasVersionNumber(): void
method testHasDescription (line 100) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 115) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 134) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 161) | public function testFactoryMethod(): void
method testFactoryMethodCreatesEmptyDeprecatedTag (line 186) | public function testFactoryMethodCreatesEmptyDeprecatedTag(): void
method testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex (line 203) | public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex():...
FILE: tests/unit/DocBlock/Tags/ExampleTest.php
class ExampleTest (line 14) | class ExampleTest extends TestCase
method testExampleWithoutContent (line 23) | public function testExampleWithoutContent(): void
method testWithDescription (line 40) | public function testWithDescription(): void
method testStartlineIsParsed (line 56) | public function testStartlineIsParsed(): void
method testAllowOmittingLineCount (line 73) | public function testAllowOmittingLineCount(): void
method testLengthIsParsed (line 91) | public function testLengthIsParsed(): void
method testStringRepresentationIsReturned (line 104) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 139) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 158) | public function testFactoryMethod(
method tagContentProvider (line 176) | public function tagContentProvider(): array
method testValidatesArguments (line 234) | public function testValidatesArguments(
method invalidExampleProvider (line 253) | public function invalidExampleProvider(): array
FILE: tests/unit/DocBlock/Tags/ExtendsTest.php
class ExtendsTest (line 14) | final class ExtendsTest extends TestCase
method testExtendsCreatedCorrectly (line 16) | public function testExtendsCreatedCorrectly(): void
method testRendersCorrectly (line 24) | public function testRendersCorrectly(): void
FILE: tests/unit/DocBlock/Tags/Factory/AbstractPHPStanFactoryTest.php
class AbstractPHPStanFactoryTest (line 31) | class AbstractPHPStanFactoryTest extends TestCase
method tearDown (line 36) | public function tearDown(): void
method testCreateReturnsTagFromSupportingFactory (line 44) | public function testCreateReturnsTagFromSupportingFactory(): void
method testCreateReturnsInvalidTagWhenNoFactorySupports (line 61) | public function testCreateReturnsInvalidTagWhenNoFactorySupports(): void
method testCreateReturnsInvalidTagWithErrorOnFactoryRuntimeException (line 77) | public function testCreateReturnsInvalidTagWithErrorOnFactoryRuntimeEx...
method testCreateReturnsInvalidTagWithErrorOnFactoryParserException (line 95) | public function testCreateReturnsInvalidTagWithErrorOnFactoryParserExc...
FILE: tests/unit/DocBlock/Tags/Factory/ExtendsFactoryTest.php
class ExtendsFactoryTest (line 23) | final class ExtendsFactoryTest extends TagFactoryTestCase
method testExtendsIsCreated (line 30) | public function testExtendsIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/ImplementsFactoryTest.php
class ImplementsFactoryTest (line 23) | final class ImplementsFactoryTest extends TagFactoryTestCase
method testImplementsIsCreated (line 30) | public function testImplementsIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php
class MethodFactoryTest (line 25) | final class MethodFactoryTest extends TagFactoryTestCase
method testIsCreated (line 33) | public function testIsCreated(string $tagLine, Method $tag): void
method tagProvider (line 47) | public function tagProvider(): array
FILE: tests/unit/DocBlock/Tags/Factory/MixinFactoryTest.php
class MixinFactoryTest (line 21) | final class MixinFactoryTest extends TagFactoryTestCase
method testMixinIsCreated (line 28) | public function testMixinIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php
class ParamFactoryTest (line 29) | final class ParamFactoryTest extends TagFactoryTestCase
method testParamIsCreated (line 37) | public function testParamIsCreated(string $input, Tag $expected): void
method paramInputProvider (line 53) | public function paramInputProvider(): array
FILE: tests/unit/DocBlock/Tags/Factory/PropertyFactoryTest.php
class PropertyFactoryTest (line 21) | final class PropertyFactoryTest extends TagFactoryTestCase
method testParamIsCreated (line 28) | public function testParamIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/PropertyReadFactoryTest.php
class PropertyReadFactoryTest (line 21) | final class PropertyReadFactoryTest extends TagFactoryTestCase
method testParamIsCreated (line 28) | public function testParamIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/PropertyWriteFactoryTest.php
class PropertyWriteFactoryTest (line 21) | final class PropertyWriteFactoryTest extends TagFactoryTestCase
method testParamIsCreated (line 28) | public function testParamIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/ReturnFactoryTest.php
class ReturnFactoryTest (line 21) | final class ReturnFactoryTest extends TagFactoryTestCase
method testParamIsCreated (line 28) | public function testParamIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/TagFactoryTestCase.php
class TagFactoryTestCase (line 32) | abstract class TagFactoryTestCase extends TestCase
method parseTag (line 34) | public function parseTag(string $tag): PhpDocTagNode
method giveTypeResolver (line 49) | public function giveTypeResolver(): TypeResolver
method givenDescriptionFactory (line 54) | public function givenDescriptionFactory(): DescriptionFactory
method closeMockery (line 67) | public function closeMockery(): void
FILE: tests/unit/DocBlock/Tags/Factory/TemplateCovariantFactoryTest.php
class TemplateCovariantFactoryTest (line 24) | final class TemplateCovariantFactoryTest extends TagFactoryTestCase
method testTemplateCovariantIsCreated (line 32) | public function testTemplateCovariantIsCreated(string $input, Tag $exp...
method templateCovariantInputProvider (line 48) | public function templateCovariantInputProvider(): array
FILE: tests/unit/DocBlock/Tags/Factory/TemplateFactoryTest.php
class TemplateFactoryTest (line 24) | final class TemplateFactoryTest extends TagFactoryTestCase
method testTemplateIsCreated (line 32) | public function testTemplateIsCreated(string $input, Tag $expected): void
method templateInputProvider (line 48) | public function templateInputProvider(): array
FILE: tests/unit/DocBlock/Tags/Factory/ThrowsFactoryTest.php
class ThrowsFactoryTest (line 21) | final class ThrowsFactoryTest extends TagFactoryTestCase
method testThrowsIsCreated (line 28) | public function testThrowsIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Factory/VarFactoryTest.php
class VarFactoryTest (line 21) | final class VarFactoryTest extends TagFactoryTestCase
method testVarIsCreated (line 28) | public function testVarIsCreated(): void
FILE: tests/unit/DocBlock/Tags/Formatter/AlignFormatterTest.php
class AlignFormatterTest (line 27) | class AlignFormatterTest extends TestCase
method tearDown (line 32) | public function tearDown(): void
method testFormatterCallsToStringAndReturnsAStandardRepresentation (line 48) | public function testFormatterCallsToStringAndReturnsAStandardRepresent...
FILE: tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php
class PassthroughFormatterTest (line 24) | class PassthroughFormatterTest extends TestCase
method tearDown (line 29) | public function tearDown(): void
method testFormatterCallsToStringAndReturnsAStandardRepresentation (line 41) | public function testFormatterCallsToStringAndReturnsAStandardRepresent...
method testFormatterToStringWithoutDescription (line 60) | public function testFormatterToStringWithoutDescription(): void
FILE: tests/unit/DocBlock/Tags/GenericTest.php
class GenericTest (line 26) | class GenericTest extends TestCase
method tearDown (line 31) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 42) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 71) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasDescription (line 87) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 103) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 117) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 138) | public function testFactoryMethod(): void
method testFactoryMethodFailsIfNameIsNotEmpty (line 158) | public function testFactoryMethodFailsIfNameIsNotEmpty(): void
method testFactoryMethodFailsIfNameContainsIllegalCharacters (line 168) | public function testFactoryMethodFailsIfNameContainsIllegalCharacters(...
FILE: tests/unit/DocBlock/Tags/ImplementsTest.php
class ImplementsTest (line 14) | final class ImplementsTest extends TestCase
method testCreatedCorrectly (line 16) | public function testCreatedCorrectly(): void
method testRendersCorrectly (line 24) | public function testRendersCorrectly(): void
FILE: tests/unit/DocBlock/Tags/InvalidTagTest.php
class InvalidTagTest (line 25) | final class InvalidTagTest extends TestCase
method testCreationWithoutError (line 27) | public function testCreationWithoutError(): void
method testCreationWithError (line 40) | public function testCreationWithError(): void
method testCreationWithErrorContainingClosure (line 51) | public function testCreationWithErrorContainingClosure(): void
method throwExceptionFromClosureWithClosureArgument (line 75) | private function throwExceptionFromClosureWithClosureArgument(): void
method testCreationWithErrorContainingResource (line 84) | public function testCreationWithErrorContainingResource(): void
method throwExceptionWithResourceArgument (line 109) | private function throwExceptionWithResourceArgument(): void
method testCreationWithErrorFromEval (line 118) | public function testCreationWithErrorFromEval(): void
FILE: tests/unit/DocBlock/Tags/LinkTest.php
class LinkTest (line 27) | class LinkTest extends TestCase
method tearDown (line 32) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 43) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 59) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 72) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasLinkUrl (line 86) | public function testHasLinkUrl(): void
method testHasDescription (line 101) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 116) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 129) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 150) | public function testFactoryMethod(): void
method testFactoryMethodWithoutSpaceBeforeUrl (line 177) | public function testFactoryMethodWithoutSpaceBeforeUrl(): void
method testFactoryMethodWithSpaceBeforeUrl (line 202) | public function testFactoryMethodWithSpaceBeforeUrl(): void
method testFactoryMethodCreatesEmptyLinkTag (line 225) | public function testFactoryMethodCreatesEmptyLinkTag(): void
FILE: tests/unit/DocBlock/Tags/MethodParameterTest.php
class MethodParameterTest (line 35) | class MethodParameterTest extends TestCase
method tearDown (line 40) | public function tearDown(): void
method collectionDefaultValuesProvider (line 46) | public function collectionDefaultValuesProvider(): array
method testIfTagCanBeRenderedUsingMethodParameterWithDefaultValue (line 73) | public function testIfTagCanBeRenderedUsingMethodParameterWithDefaultV...
method testIfTagCanBeRenderedUsingMethodParameterWithNoDefaultValue (line 99) | public function testIfTagCanBeRenderedUsingMethodParameterWithNoDefaul...
FILE: tests/unit/DocBlock/Tags/MethodTest.php
class MethodTest (line 28) | class MethodTest extends TestCase
method tearDown (line 33) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 43) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 60) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 87) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasMethodName (line 101) | public function testHasMethodName(): void
method testHasArguments (line 114) | public function testHasArguments(): void
method testHasReturnType (line 129) | public function testHasReturnType(): void
method testReturnTypeCanBeInferredAsVoid (line 142) | public function testReturnTypeCanBeInferredAsVoid(): void
method testMethodCanBeStatic (line 153) | public function testMethodCanBeStatic(): void
method testHasDescription (line 170) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 186) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 207) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testReturnsReference (line 232) | public function testReturnsReference(): void
method testFactoryMethodThrows (line 244) | public function testFactoryMethodThrows(): void
FILE: tests/unit/DocBlock/Tags/ParamTest.php
class ParamTest (line 25) | class ParamTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 78) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVariableName (line 92) | public function testHasVariableName(): void
method testHasType (line 105) | public function testHasType(): void
method testIfParameterIsVariadic (line 118) | public function testIfParameterIsVariadic(): void
method testHasDescription (line 133) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 150) | public function testStringRepresentationIsReturned(): void
method testIsReference (line 163) | public function testIsReference(): void
FILE: tests/unit/DocBlock/Tags/PropertyReadTest.php
class PropertyReadTest (line 25) | class PropertyReadTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 57) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 74) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVariableName (line 88) | public function testHasVariableName(): void
method testHasType (line 101) | public function testHasType(): void
method testHasDescription (line 116) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 132) | public function testStringRepresentationIsReturned(): void
FILE: tests/unit/DocBlock/Tags/PropertyTest.php
class PropertyTest (line 25) | class PropertyTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 57) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 74) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVariableName (line 88) | public function testHasVariableName(): void
method testHasType (line 101) | public function testHasType(): void
method testHasDescription (line 116) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 132) | public function testStringRepresentationIsReturned(): void
FILE: tests/unit/DocBlock/Tags/PropertyWriteTest.php
class PropertyWriteTest (line 25) | class PropertyWriteTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 57) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 74) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVariableName (line 88) | public function testHasVariableName(): void
method testHasType (line 101) | public function testHasType(): void
method testHasDescription (line 116) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 132) | public function testStringRepresentationIsReturned(): void
FILE: tests/unit/DocBlock/Tags/ReturnTest.php
class ReturnTest (line 25) | class ReturnTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 57) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 70) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasType (line 84) | public function testHasType(): void
method testHasDescription (line 99) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 114) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 127) | public function testStringRepresentationIsReturnedWithoutDescription()...
FILE: tests/unit/DocBlock/Tags/SeeTest.php
class SeeTest (line 32) | class SeeTest extends TestCase
method tearDown (line 37) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 50) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 67) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 82) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasReferenceToFqsen (line 99) | public function testHasReferenceToFqsen(): void
method testHasDescription (line 116) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 133) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 148) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 172) | public function testFactoryMethod(): void
method testFactoryMethodWithNonClassFQSEN (line 204) | public function testFactoryMethodWithNonClassFQSEN(): void
method testFactoryMethodWithUrl (line 235) | public function testFactoryMethodWithUrl(): void
method testFactoryMethodWithoutUrl (line 266) | public function testFactoryMethodWithoutUrl(): void
method testFactoryMethodFailsIfBodyIsNotEmpty (line 288) | public function testFactoryMethodFailsIfBodyIsNotEmpty(): void
method testFactoryMethodFailsIfResolverIsNull (line 297) | public function testFactoryMethodFailsIfResolverIsNull(): void
method testFactoryMethodFailsIfDescriptionFactoryIsNull (line 306) | public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
FILE: tests/unit/DocBlock/Tags/SinceTest.php
class SinceTest (line 26) | class SinceTest extends TestCase
method tearDown (line 31) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 42) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 71) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVersionNumber (line 85) | public function testHasVersionNumber(): void
method testHasDescription (line 100) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 115) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 128) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 149) | public function testFactoryMethod(): void
method testFactoryMethodCreatesEmptySinceTag (line 175) | public function testFactoryMethodCreatesEmptySinceTag(): void
method testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex (line 191) | public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex():...
FILE: tests/unit/DocBlock/Tags/SourceTest.php
class SourceTest (line 26) | class SourceTest extends TestCase
method tearDown (line 31) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 42) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 75) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasStartingLine (line 89) | public function testHasStartingLine(): void
method testHasLineCount (line 102) | public function testHasLineCount(): void
method testHasDescription (line 117) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 133) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 147) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 174) | public function testFactoryMethod(): void
method testFactoryMethodFailsIfEmptyBodyIsGiven (line 197) | public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
method testFactoryMethodFailsIfDescriptionFactoryIsNull (line 209) | public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
method testExceptionIsThrownIfStartingLineIsNotInteger (line 218) | public function testExceptionIsThrownIfStartingLineIsNotInteger(): void
method testExceptionIsThrownIfLineCountIsNotIntegerOrNull (line 227) | public function testExceptionIsThrownIfLineCountIsNotIntegerOrNull(): ...
FILE: tests/unit/DocBlock/Tags/TemplateExtendsTest.php
class TemplateExtendsTest (line 14) | final class TemplateExtendsTest extends TestCase
method testExtendsCreatedCorrectly (line 16) | public function testExtendsCreatedCorrectly(): void
method testRendersCorrectly (line 24) | public function testRendersCorrectly(): void
FILE: tests/unit/DocBlock/Tags/TemplateImplementsTest.php
class TemplateImplementsTest (line 14) | final class TemplateImplementsTest extends TestCase
method testCreatedCorrectly (line 16) | public function testCreatedCorrectly(): void
method testRendersCorrectly (line 24) | public function testRendersCorrectly(): void
FILE: tests/unit/DocBlock/Tags/TemplateTest.php
class TemplateTest (line 16) | final class TemplateTest extends TestCase
method testTemplateCreatedCorrectly (line 24) | public function testTemplateCreatedCorrectly(): void
method testRendersCorrectly (line 33) | public function testRendersCorrectly(): void
FILE: tests/unit/DocBlock/Tags/ThrowsTest.php
class ThrowsTest (line 25) | class ThrowsTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 57) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 70) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasType (line 84) | public function testHasType(): void
method testHasDescription (line 99) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 114) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 133) | public function testStringRepresentationIsReturnedWithoutDescription()...
FILE: tests/unit/DocBlock/Tags/UsesTest.php
class UsesTest (line 29) | class UsesTest extends TestCase
method tearDown (line 34) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 45) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 61) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 74) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasReferenceToFqsen (line 88) | public function testHasReferenceToFqsen(): void
method testHasDescription (line 103) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 118) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 131) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 160) | public function testFactoryMethod(): void
method testFactoryMethodWithoutSpaceBeforeClass (line 190) | public function testFactoryMethodWithoutSpaceBeforeClass(): void
method testFactoryMethodWithSpaceBeforeClass (line 219) | public function testFactoryMethodWithSpaceBeforeClass(): void
method testFactoryMethodFailsIfBodyIsNotEmpty (line 241) | public function testFactoryMethodFailsIfBodyIsNotEmpty(): void
method testFactoryMethodFailsIfResolverIsNull (line 250) | public function testFactoryMethodFailsIfResolverIsNull(): void
method testFactoryMethodFailsIfDescriptionFactoryIsNull (line 259) | public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
FILE: tests/unit/DocBlock/Tags/VarTest.php
class VarTest (line 25) | class VarTest extends TestCase
method tearDown (line 30) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 41) | public function testIfCorrectTagNameIsReturned(): void
method testIfVariableNameIsOmittedIfEmpty (line 53) | public function testIfVariableNameIsOmittedIfEmpty(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 69) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 86) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVariableName (line 100) | public function testHasVariableName(): void
method testHasType (line 113) | public function testHasType(): void
method testHasDescription (line 128) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 144) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 158) | public function testStringRepresentationIsReturnedWithoutDescription()...
FILE: tests/unit/DocBlock/Tags/VersionTest.php
class VersionTest (line 26) | class VersionTest extends TestCase
method tearDown (line 31) | public function tearDown(): void
method testIfCorrectTagNameIsReturned (line 42) | public function testIfCorrectTagNameIsReturned(): void
method testIfTagCanBeRenderedUsingDefaultFormatter (line 58) | public function testIfTagCanBeRenderedUsingDefaultFormatter(): void
method testIfTagCanBeRenderedUsingSpecificFormatter (line 71) | public function testIfTagCanBeRenderedUsingSpecificFormatter(): void
method testHasVersionNumber (line 85) | public function testHasVersionNumber(): void
method testHasDescription (line 100) | public function testHasDescription(): void
method testStringRepresentationIsReturned (line 115) | public function testStringRepresentationIsReturned(): void
method testStringRepresentationIsReturnedWithoutDescription (line 128) | public function testStringRepresentationIsReturnedWithoutDescription()...
method testFactoryMethod (line 149) | public function testFactoryMethod(): void
method testFactoryMethodCreatesEmptyVersionTag (line 175) | public function testFactoryMethodCreatesEmptyVersionTag(): void
method testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex (line 191) | public function testFactoryMethodReturnsNullIfBodyDoesNotMatchRegex():...
FILE: tests/unit/DocBlockFactoryTest.php
class DocBlockFactoryTest (line 37) | class DocBlockFactoryTest extends TestCase
method tearDown (line 42) | public function tearDown(): void
method testCreateFactoryUsingFactoryMethod (line 54) | public function testCreateFactoryUsingFactoryMethod(): void
method testCreateDocBlockFromReflection (line 67) | public function testCreateDocBlockFromReflection(): void
method testCreateDocBlockFromStringWithDocComment (line 90) | public function testCreateDocBlockFromStringWithDocComment(): void
method testCreateDocBlockFromStringWithoutDocComment (line 110) | public function testCreateDocBlockFromStringWithoutDocComment(): void
method testSummaryAndDescriptionAreSeparated (line 133) | public function testSummaryAndDescriptionAreSeparated(string $given, s...
method testDescriptionsRetainFormatting (line 151) | public function testDescriptionsRetainFormatting(): void
method testTagsAreInterpretedUsingFactory (line 180) | public function testTagsAreInterpretedUsingFactory(): void
method provideSummaryAndDescriptions (line 205) | public function provideSummaryAndDescriptions(): array
method testTagsWithContextNamespace (line 265) | public function testTagsWithContextNamespace(): void
FILE: tests/unit/DocBlockTest.php
class DocBlockTest (line 28) | class DocBlockTest extends TestCase
method tearDown (line 33) | public function tearDown(): void
method testDocBlockCanHaveASummary (line 44) | public function testDocBlockCanHaveASummary(): void
method testDocBlockCanHaveEllipsisInSummary (line 59) | public function testDocBlockCanHaveEllipsisInSummary(): void
method testDocBlockCanHaveADescription (line 74) | public function testDocBlockCanHaveADescription(): void
method testDocBlockCanHaveTags (line 90) | public function testDocBlockCanHaveTags(): void
method testDocBlockAllowsOnlyTags (line 108) | public function testDocBlockAllowsOnlyTags(): void
method testFindTagsInDocBlockByName (line 124) | public function testFindTagsInDocBlockByName(): void
method testFindTagsWithTypeInDocBlockByName (line 151) | public function testFindTagsWithTypeInDocBlockByName(): void
method testCheckIfThereAreTagsWithAGivenName (line 173) | public function testCheckIfThereAreTagsWithAGivenName(): void
method testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesThereAre (line 197) | public function testDocBlockKnowsInWhichNamespaceItIsAndWhichAliasesTh...
method testDocBlockKnowsAtWhichLineItIs (line 213) | public function testDocBlockKnowsAtWhichLineItIs(): void
method testDocBlockIsNotATemplateByDefault (line 229) | public function testDocBlockIsNotATemplateByDefault(): void
method testDocBlockKnowsIfItIsTheStartOfADocBlockTemplate (line 243) | public function testDocBlockKnowsIfItIsTheStartOfADocBlockTemplate(): ...
method testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate (line 256) | public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate(): void
method testRemoveTag (line 269) | public function testRemoveTag(): void
FILE: tests/unit/Exception/PcreExceptionTest.php
class PcreExceptionTest (line 20) | final class PcreExceptionTest extends TestCase
method testErrorConversion (line 26) | public function testErrorConversion(int $errorCode, string $message): ...
method errorCodeProvider (line 34) | public function errorCodeProvider(): array
FILE: tests/unit/PregSplitTest.php
class PregSplitTest (line 14) | final class PregSplitTest extends TestCase
method tearDown (line 19) | protected function tearDown(): void
method testSimplePregSplit (line 31) | public function testSimplePregSplit(): void
method testPregSplitThrowsOnError (line 41) | public function testPregSplitThrowsOnError(): void
Condensed preview — 165 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (494K chars).
[
{
"path": ".gitattributes",
"chars": 489,
"preview": "/.gitattributes export-ignore\n/.gitignore export-ignore\n/.yamllint.yaml export-ignore\n/composer-require-checker.json exp"
},
{
"path": ".github/dependabot.yml",
"chars": 243,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"composer\"\n directory: \"/\"\n schedule:\n interval: \"daily\"\n open-"
},
{
"path": ".github/workflows/documentation.yml",
"chars": 399,
"preview": "# https://docs.github.com/en/actions\n\nname: \"Documentation\"\n\non: # yamllint disable-line rule:truthy\n push:\n branche"
},
{
"path": ".github/workflows/integrate.yaml",
"chars": 1670,
"preview": "# https://docs.github.com/en/actions\n\nname: \"Integrate\"\n\non: # yamllint disable-line rule:truthy\n push:\n branches:\n "
},
{
"path": ".gitignore",
"chars": 450,
"preview": "# IDE Shizzle; it is recommended to use a global .gitignore for this but since this is an OSS project we want to make\n# "
},
{
"path": ".yamllint.yaml",
"chars": 1294,
"preview": "extends: \"default\"\n\nignore: |\n .build/\n .notes/\n vendor/\nrules:\n braces:\n max-spaces-inside-empty: 0\n max-spac"
},
{
"path": "LICENSE",
"chars": 1080,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2010 Mike van Riel\n\nPermission is hereby granted, free of charge, to any person obt"
},
{
"path": "Makefile",
"chars": 2081,
"preview": ".PHONY: help\nhelp: ## Displays this list of targets with descriptions\n\t@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_"
},
{
"path": "README.md",
"chars": 3057,
"preview": "[](https://opensource.org/licenses/MIT)\n[![Integrate"
},
{
"path": "composer-require-checker.json",
"chars": 360,
"preview": "{\n \"symbol-whitelist\" : [\n \"null\", \"true\", \"false\",\n \"static\", \"self\", \"parent\",\n \"array\", \"string\", \"int\", \"f"
},
{
"path": "composer.json",
"chars": 1667,
"preview": "{\n \"name\": \"phpdocumentor/reflection-docblock\",\n \"description\": \"With this component, a library can provide suppor"
},
{
"path": "docs/contributing.rst",
"chars": 423,
"preview": "Contributing\n============\n\nContributions are welcome! If you would like to contribute to ReflectionDocBlock, please foll"
},
{
"path": "docs/examples/01-interpreting-a-simple-docblock.php",
"chars": 896,
"preview": "<?php\nrequire_once(__DIR__ . '/../../vendor/autoload.php');\n\nuse phpDocumentor\\Reflection\\DocBlockFactory;\n\n$docComment "
},
{
"path": "docs/examples/02-interpreting-tags.php",
"chars": 632,
"preview": "<?php\nrequire_once(__DIR__ . '/../../vendor/autoload.php');\n\nuse phpDocumentor\\Reflection\\DocBlockFactory;\n\n$docComment "
},
{
"path": "docs/examples/03-reconstituting-a-docblock.php",
"chars": 779,
"preview": "<?php\n\nrequire_once(__DIR__ . '/../../vendor/autoload.php');\n\nuse phpDocumentor\\Reflection\\DocBlock\\Serializer;\nuse phpD"
},
{
"path": "docs/examples/04-adding-your-own-tag.php",
"chars": 5992,
"preview": "<?php\n/**\n * In this example we demonstrate how you can add your own Tag using a Static Factory method in your Tag class"
},
{
"path": "docs/examples/playing-with-descriptions/02-escaping.php",
"chars": 1740,
"preview": "<?php\n\nrequire_once(__DIR__ . '/../../../vendor/autoload.php');\n\nuse phpDocumentor\\Reflection\\DocBlockFactory;\n\n$docComm"
},
{
"path": "docs/how-to/adding-your-own-tag.rst",
"chars": 229,
"preview": "Add Your Own Tag\n=======================\n\nThis guide demonstrates how to add your own custom tag to a DocBlock using Ref"
},
{
"path": "docs/how-to/index.rst",
"chars": 220,
"preview": "How-to\n=============\n\nPractical guides for common tasks with ReflectionDocBlock:\n\n.. toctree::\n :maxdepth: 1\n\n inter"
},
{
"path": "docs/how-to/interpreting-a-simple-docblock.rst",
"chars": 288,
"preview": "Interpret a Simple DocBlock\n==================================\n\nThis guide demonstrates how to parse a simple DocBlock a"
},
{
"path": "docs/how-to/interpreting-tags.rst",
"chars": 246,
"preview": "Interpret Tags in a DocBlock\n===================================\n\nThis guide demonstrates how to interpret tags within a"
},
{
"path": "docs/how-to/reconstituting-a-docblock.rst",
"chars": 618,
"preview": "Reconstituting a DocBlock\n=========================\n\nReflectionDocBlock not only allows you to read and parse DocBlocks,"
},
{
"path": "docs/index.rst",
"chars": 2111,
"preview": "ReflectionDocBlock Documentation\n===========================================\n\nReflectionDocBlock is a PHP library that p"
},
{
"path": "docs/installation.rst",
"chars": 150,
"preview": "Installation\n============\n\nTo install ReflectionDocBlock, use Composer:\n\n.. code-block:: bash\n\n composer require phpdo"
},
{
"path": "docs/upgrade-to-v6.rst",
"chars": 2299,
"preview": "Upgrade Guide to v6\n===================\n\nThis guide helps you upgrade your project to ReflectionDocBlock v6. It covers b"
},
{
"path": "phive.xml",
"chars": 183,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phive xmlns=\"https://phar.io/phive\">\n <phar name=\"phpunit\" version=\"^9.5\" insta"
},
{
"path": "phpcs.xml.dist",
"chars": 876,
"preview": "<?xml version=\"1.0\"?>\n<ruleset name=\"ReflectionDocBlock\">\n <description>The coding standard for this library.</descripti"
},
{
"path": "phpdoc.dist.xml",
"chars": 1541,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<phpdocumentor\n configVersion=\"3\"\n xmlns:xsi=\"http://www.w3.org/20"
},
{
"path": "phpmd.xml.dist",
"chars": 845,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<ruleset\n name=\"ProxyManager rules\"\n xmlns=\"http://pmd.sf.net/ruleset/1.0."
},
{
"path": "phpstan-baseline.neon",
"chars": 726,
"preview": "parameters:\n\tignoreErrors:\n\t\t-\n\t\t\tmessage: \"#^Unused phpDocumentor\\\\\\\\Reflection\\\\\\\\DocBlock\\\\\\\\ExampleFinder\\\\:\\\\:getEx"
},
{
"path": "phpstan.neon",
"chars": 597,
"preview": "includes:\n\t- phpstan-baseline.neon\n\nparameters:\n level: max\n ignoreErrors:\n - '#Method phpDocumentor\\\\Refle"
},
{
"path": "phpunit.xml.dist",
"chars": 1028,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSch"
},
{
"path": "psalm.xml",
"chars": 3127,
"preview": "<?xml version=\"1.0\"?>\n<psalm\n errorLevel=\"2\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns=\"htt"
},
{
"path": "src/DocBlock/Description.php",
"chars": 3615,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/DescriptionFactory.php",
"chars": 6780,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/ExampleFinder.php",
"chars": 4718,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Serializer.php",
"chars": 4976,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/StandardTagFactory.php",
"chars": 15569,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tag.php",
"chars": 659,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/TagFactory.php",
"chars": 3330,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Author.php",
"chars": 2484,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/BaseTag.php",
"chars": 1171,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Covers.php",
"chars": 2618,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Deprecated.php",
"chars": 2852,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Example.php",
"chars": 5386,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Extends_.php",
"chars": 691,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php",
"chars": 4468,
"preview": "<?php\n/*\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license information, please view the L"
},
{
"path": "src/DocBlock/Tags/Factory/ExtendsFactory.php",
"chars": 1660,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/Factory.php",
"chars": 1054,
"preview": "<?php\n/*\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license information, please view the L"
},
{
"path": "src/DocBlock/Tags/Factory/ImplementsFactory.php",
"chars": 1681,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/MethodFactory.php",
"chars": 2843,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/MethodParameterFactory.php",
"chars": 2362,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Factory/MixinFactory.php",
"chars": 1616,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/PHPStanFactory.php",
"chars": 408,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/ParamFactory.php",
"chars": 2774,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/PropertyFactory.php",
"chars": 1732,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/PropertyReadFactory.php",
"chars": 1749,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/PropertyWriteFactory.php",
"chars": 1753,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/ReturnFactory.php",
"chars": 1624,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/TemplateCovariantFactory.php",
"chars": 1780,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/TemplateFactory.php",
"chars": 1794,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/ThrowsFactory.php",
"chars": 1622,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Factory/VarFactory.php",
"chars": 1673,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags\\Factory;\n\nuse phpDocumentor\\Reflection"
},
{
"path": "src/DocBlock/Tags/Formatter/AlignFormatter.php",
"chars": 1191,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Formatter/PassthroughFormatter.php",
"chars": 675,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Formatter.php",
"chars": 527,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Generic.php",
"chars": 2438,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Implements_.php",
"chars": 700,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/InvalidTag.php",
"chars": 4138,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse Closure;\nuse Exception;\nuse phpD"
},
{
"path": "src/DocBlock/Tags/Link.php",
"chars": 1851,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Method.php",
"chars": 3366,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/MethodParameter.php",
"chars": 2097,
"preview": "<?php\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license information, please view the "
},
{
"path": "src/DocBlock/Tags/Mixin.php",
"chars": 695,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Param.php",
"chars": 2449,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Property.php",
"chars": 1771,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/PropertyRead.php",
"chars": 1785,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/PropertyWrite.php",
"chars": 1732,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Reference/Fqsen.php",
"chars": 783,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license in"
},
{
"path": "src/DocBlock/Tags/Reference/Reference.php",
"chars": 460,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license in"
},
{
"path": "src/DocBlock/Tags/Reference/Url.php",
"chars": 688,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license in"
},
{
"path": "src/DocBlock/Tags/Return_.php",
"chars": 699,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/See.php",
"chars": 2976,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Since.php",
"chars": 2667,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Source.php",
"chars": 3280,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/TagWithType.php",
"chars": 1153,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Template.php",
"chars": 2157,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/TemplateCovariant.php",
"chars": 733,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/TemplateExtends.php",
"chars": 683,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/TemplateImplements.php",
"chars": 695,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Throws.php",
"chars": 698,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Uses.php",
"chars": 2577,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Var_.php",
"chars": 1755,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock/Tags/Version.php",
"chars": 2743,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlock.php",
"chars": 5910,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlockFactory.php",
"chars": 9441,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "src/DocBlockFactoryInterface.php",
"chars": 618,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tag;\n\n// php"
},
{
"path": "src/Exception/CannotCreateTag.php",
"chars": 156,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Exception;\n\nuse LogicException;\n\nfinal class CannotC"
},
{
"path": "src/Exception/ParserException.php",
"chars": 465,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Exception;\n\nuse InvalidArgumentException;\n\nfinal cla"
},
{
"path": "src/Exception/PcreException.php",
"chars": 1176,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Exception;\n\nuse InvalidArgumentException;\n\nuse const"
},
{
"path": "src/Exception/ReflectionDocblockException.php",
"chars": 156,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Exception;\n\nuse Throwable;\n\ninterface ReflectionDocb"
},
{
"path": "src/Utils.php",
"chars": 2473,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/coverage-checker.php",
"chars": 1026,
"preview": "<?php\n// based on https://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/\n$i"
},
{
"path": "tests/integration/DocblockSeeTagResolvingTest.php",
"chars": 1125,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tags\\See;\nus"
},
{
"path": "tests/integration/DocblocksWithAnnotationsTest.php",
"chars": 1289,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license in"
},
{
"path": "tests/integration/InterpretingDocBlocksTest.php",
"chars": 19285,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/integration/ModifyBackTraceSafeTest.php",
"chars": 1397,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection;\n\n\nuse PHPUnit\\Framework\\TestCase;\n\n/**\n * @coversNo"
},
{
"path": "tests/integration/ReconstitutingADocBlockTest.php",
"chars": 2365,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/integration/TypedTagsTest.php",
"chars": 5723,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace integration;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tags\\InvalidTag;\nuse phpD"
},
{
"path": "tests/integration/UsingTagsTest.php",
"chars": 1319,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/Assets/CustomParam.php",
"chars": 901,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Assets;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tag;\n"
},
{
"path": "tests/unit/Assets/CustomServiceClass.php",
"chars": 817,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Assets;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tag;\n"
},
{
"path": "tests/unit/Assets/CustomServiceInterface.php",
"chars": 844,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Assets;\n\nuse phpDocumentor\\Reflection\\DocBlock\\Tag;\n"
},
{
"path": "tests/unit/Assets/CustomTagFactory.php",
"chars": 792,
"preview": "<?php\n/*\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license information, please view the L"
},
{
"path": "tests/unit/DocBlock/DescriptionFactoryTest.php",
"chars": 8544,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/DescriptionTest.php",
"chars": 5500,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/ExampleFinderTest.php",
"chars": 1018,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock;\n\nuse Mockery as m;\nuse phpDocumentor\\Refle"
},
{
"path": "tests/unit/DocBlock/SerializerTest.php",
"chars": 5811,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/StandardTagFactoryTest.php",
"chars": 21808,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/AuthorTest.php",
"chars": 5572,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/CoversTest.php",
"chars": 7233,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/DeprecatedTest.php",
"chars": 6369,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/ExampleTest.php",
"chars": 7773,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse InvalidArgumentException;\nuse PH"
},
{
"path": "tests/unit/DocBlock/Tags/ExtendsTest.php",
"chars": 800,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse phpDocumentor\\Reflection\\Fqsen;\n"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/AbstractPHPStanFactoryTest.php",
"chars": 3359,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/ExtendsFactoryTest.php",
"chars": 1515,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/ImplementsFactoryTest.php",
"chars": 1542,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php",
"chars": 4820,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/MixinFactoryTest.php",
"chars": 1330,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php",
"chars": 3914,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/PropertyFactoryTest.php",
"chars": 1382,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/PropertyReadFactoryTest.php",
"chars": 1415,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/PropertyWriteFactoryTest.php",
"chars": 1423,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/ReturnFactoryTest.php",
"chars": 1340,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/TagFactoryTestCase.php",
"chars": 2117,
"preview": "<?php\n/*\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license information, please view the L"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/TemplateCovariantFactoryTest.php",
"chars": 2406,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/TemplateFactoryTest.php",
"chars": 2471,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/ThrowsFactoryTest.php",
"chars": 1339,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Factory/VarFactoryTest.php",
"chars": 1342,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Formatter/AlignFormatterTest.php",
"chars": 2056,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/Formatter/PassthroughFormatterTest.php",
"chars": 1849,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/GenericTest.php",
"chars": 5357,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/ImplementsTest.php",
"chars": 811,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse phpDocumentor\\Reflection\\Fqsen;\n"
},
{
"path": "tests/unit/DocBlock/Tags/InvalidTagTest.php",
"chars": 4445,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse Exception;\nuse InvalidArgumentEx"
},
{
"path": "tests/unit/DocBlock/Tags/LinkTest.php",
"chars": 7914,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/MethodParameterTest.php",
"chars": 3588,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/MethodTest.php",
"chars": 7023,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/ParamTest.php",
"chars": 5230,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/PropertyReadTest.php",
"chars": 4236,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/PropertyTest.php",
"chars": 4156,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/PropertyWriteTest.php",
"chars": 4255,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/ReturnTest.php",
"chars": 4017,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/SeeTest.php",
"chars": 11444,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/SinceTest.php",
"chars": 5989,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/SourceTest.php",
"chars": 6883,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/TemplateExtendsTest.php",
"chars": 847,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse phpDocumentor\\Reflection\\Fqsen;\n"
},
{
"path": "tests/unit/DocBlock/Tags/TemplateImplementsTest.php",
"chars": 858,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse phpDocumentor\\Reflection\\Fqsen;\n"
},
{
"path": "tests/unit/DocBlock/Tags/TemplateTest.php",
"chars": 1197,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\DocBlock\\Tags;\n\nuse phpDocumentor\\Reflection\\DocBloc"
},
{
"path": "tests/unit/DocBlock/Tags/ThrowsTest.php",
"chars": 4174,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/UsesTest.php",
"chars": 8601,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/VarTest.php",
"chars": 5124,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlock/Tags/VersionTest.php",
"chars": 6037,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlockFactoryTest.php",
"chars": 8709,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/DocBlockTest.php",
"chars": 8068,
"preview": "<?php\n\ndeclare(strict_types=1);\n\n/**\n * This file is part of phpDocumentor.\n *\n * For the full copyright and license inf"
},
{
"path": "tests/unit/Exception/PcreExceptionTest.php",
"chars": 1666,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection\\Exception;\n\nuse PHPUnit\\Framework\\TestCase;\n\nuse con"
},
{
"path": "tests/unit/PregSplitTest.php",
"chars": 1347,
"preview": "<?php\n\ndeclare(strict_types=1);\n\nnamespace phpDocumentor\\Reflection;\n\nuse phpDocumentor\\Reflection\\Exception\\PcreExcepti"
}
]
About this extraction
This page contains the full source code of the phpDocumentor/ReflectionDocBlock GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 165 files (450.4 KB), approximately 114.1k tokens, and a symbol index with 779 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.