changes for filter and print
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
[](https://opensource.org/licenses/MIT)
|
||||

|
||||
[](https://coveralls.io/github/phpDocumentor/ReflectionDocBlock?branch=master)
|
||||
[](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)
|
||||
|
@@ -10,19 +10,26 @@
|
||||
},
|
||||
{
|
||||
"name": "Jaap van Otterdijk",
|
||||
"email": "account@ijaap.nl"
|
||||
"email": "opensource@ijaap.nl"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpdocumentor/type-resolver": "^1.3",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"phpdocumentor/type-resolver": "^1.7",
|
||||
"webmozart/assert": "^1.9.1",
|
||||
"phpdocumentor/reflection-common": "^2.2",
|
||||
"ext-filter": "*"
|
||||
"ext-filter": "*",
|
||||
"phpstan/phpdoc-parser": "^1.7",
|
||||
"doctrine/deprecations": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~1.3.2",
|
||||
"psalm/phar": "^4.8"
|
||||
"mockery/mockery": "~1.3.5",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"phpstan/phpstan": "^1.8",
|
||||
"phpstan/phpstan-mockery": "^1.1",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"phpstan/phpstan-webmozart-assert": "^1.2",
|
||||
"vimeo/psalm": "^5.13"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -34,6 +41,14 @@
|
||||
"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"
|
||||
|
@@ -20,25 +20,25 @@ use Webmozart\Assert\Assert;
|
||||
final class DocBlock
|
||||
{
|
||||
/** @var string The opening line for this docblock. */
|
||||
private $summary;
|
||||
private string $summary;
|
||||
|
||||
/** @var DocBlock\Description The actual description for this docblock. */
|
||||
private $description;
|
||||
private DocBlock\Description $description;
|
||||
|
||||
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
|
||||
private $tags = [];
|
||||
private array $tags = [];
|
||||
|
||||
/** @var Types\Context|null Information about the context of this DocBlock. */
|
||||
private $context;
|
||||
private ?Types\Context $context = null;
|
||||
|
||||
/** @var Location|null Information about the location of this DocBlock. */
|
||||
private $location;
|
||||
private ?Location $location = null;
|
||||
|
||||
/** @var bool Is this DocBlock (the start of) a template? */
|
||||
private $isTemplateStart;
|
||||
private bool $isTemplateStart;
|
||||
|
||||
/** @var bool Does this DocBlock signify the end of a DocBlock template? */
|
||||
private $isTemplateEnd;
|
||||
private bool $isTemplateEnd;
|
||||
|
||||
/**
|
||||
* @param DocBlock\Tag[] $tags
|
||||
|
@@ -48,15 +48,14 @@ use function vsprintf;
|
||||
* is mainly responsible for rendering.
|
||||
*
|
||||
* @see DescriptionFactory to create a new Description.
|
||||
* @see Description\Formatter for the formatting of the body and tags.
|
||||
* @see Tags\Formatter for the formatting of the body and tags.
|
||||
*/
|
||||
class Description
|
||||
{
|
||||
/** @var string */
|
||||
private $bodyTemplate;
|
||||
private string $bodyTemplate;
|
||||
|
||||
/** @var Tag[] */
|
||||
private $tags;
|
||||
private array $tags;
|
||||
|
||||
/**
|
||||
* Initializes a Description with its body (template) and a listing of the tags used in the body template.
|
||||
@@ -93,6 +92,10 @@ class Description
|
||||
*/
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($this->tags === []) {
|
||||
return vsprintf($this->bodyTemplate, []);
|
||||
}
|
||||
|
||||
if ($formatter === null) {
|
||||
$formatter = new PassthroughFormatter();
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
|
||||
@@ -47,13 +48,12 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
class DescriptionFactory
|
||||
{
|
||||
/** @var TagFactory */
|
||||
private $tagFactory;
|
||||
private Factory $tagFactory;
|
||||
|
||||
/**
|
||||
* Initializes this factory with the means to construct (inline) tags.
|
||||
*/
|
||||
public function __construct(TagFactory $tagFactory)
|
||||
public function __construct(Factory $tagFactory)
|
||||
{
|
||||
$this->tagFactory = $tagFactory;
|
||||
}
|
||||
|
@@ -31,11 +31,10 @@ use const DIRECTORY_SEPARATOR;
|
||||
*/
|
||||
class ExampleFinder
|
||||
{
|
||||
/** @var string */
|
||||
private $sourceDirectory = '';
|
||||
private string $sourceDirectory = '';
|
||||
|
||||
/** @var string[] */
|
||||
private $exampleDirectories = [];
|
||||
private array $exampleDirectories = [];
|
||||
|
||||
/**
|
||||
* Attempts to find the example contents for the given descriptor.
|
||||
|
@@ -29,21 +29,20 @@ use function wordwrap;
|
||||
class Serializer
|
||||
{
|
||||
/** @var string The string to indent the comment with. */
|
||||
protected $indentString = ' ';
|
||||
protected string $indentString = ' ';
|
||||
|
||||
/** @var int The number of times the indent string is repeated. */
|
||||
protected $indent = 0;
|
||||
protected int $indent = 0;
|
||||
|
||||
/** @var bool Whether to indent the first line with the given indent amount and string. */
|
||||
protected $isFirstLineIndented = true;
|
||||
protected bool $isFirstLineIndented = true;
|
||||
|
||||
/** @var int|null The max length of a line. */
|
||||
protected $lineLength;
|
||||
protected ?int $lineLength = null;
|
||||
|
||||
/** @var Formatter A custom tag formatter. */
|
||||
protected $tagFormatter;
|
||||
/** @var string */
|
||||
private $lineEnding;
|
||||
protected Formatter $tagFormatter;
|
||||
private string $lineEnding;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
|
@@ -17,6 +17,7 @@ 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\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
|
||||
@@ -40,12 +41,15 @@ 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 count;
|
||||
use function get_class;
|
||||
use function is_object;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function trim;
|
||||
|
||||
@@ -72,10 +76,10 @@ final class StandardTagFactory implements TagFactory
|
||||
public const REGEX_TAGNAME = '[\w\-\_\\\\:]+';
|
||||
|
||||
/**
|
||||
* @var array<class-string<Tag>> An array with a tag as a key, and an
|
||||
* @var array<class-string<Tag>|Factory> An array with a tag as a key, and an
|
||||
* FQCN to a class that handles it as an array value.
|
||||
*/
|
||||
private $tagHandlerMappings = [
|
||||
private array $tagHandlerMappings = [
|
||||
'author' => Author::class,
|
||||
'covers' => Covers::class,
|
||||
'deprecated' => Deprecated::class,
|
||||
@@ -101,22 +105,21 @@ final class StandardTagFactory implements TagFactory
|
||||
* @var array<class-string<Tag>> An array with a anotation s a key, and an
|
||||
* FQCN to a class that handles it as an array value.
|
||||
*/
|
||||
private $annotationMappings = [];
|
||||
private array $annotationMappings = [];
|
||||
|
||||
/**
|
||||
* @var ReflectionParameter[][] a lazy-loading cache containing parameters
|
||||
* for each tagHandler that has been used.
|
||||
*/
|
||||
private $tagHandlerParameterCache = [];
|
||||
private array $tagHandlerParameterCache = [];
|
||||
|
||||
/** @var FqsenResolver */
|
||||
private $fqsenResolver;
|
||||
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 $serviceLocator = [];
|
||||
private array $serviceLocator = [];
|
||||
|
||||
/**
|
||||
* Initialize this tag factory with the means to resolve an FQSEN and optionally a list of tag handlers.
|
||||
@@ -162,18 +165,25 @@ final class StandardTagFactory implements TagFactory
|
||||
$this->serviceLocator[$alias ?: get_class($service)] = $service;
|
||||
}
|
||||
|
||||
public function registerTagHandler(string $tagName, string $handler): void
|
||||
/** {@inheritDoc} */
|
||||
public function registerTagHandler(string $tagName, $handler): void
|
||||
{
|
||||
Assert::stringNotEmpty($tagName);
|
||||
Assert::classExists($handler);
|
||||
Assert::implementsInterface($handler, Tag::class);
|
||||
|
||||
if (strpos($tagName, '\\') && $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;
|
||||
}
|
||||
|
||||
@@ -210,6 +220,10 @@ final class StandardTagFactory implements TagFactory
|
||||
$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);
|
||||
@@ -225,9 +239,9 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).
|
||||
*
|
||||
* @return class-string<Tag>
|
||||
* @return class-string<Tag>|Factory
|
||||
*/
|
||||
private function findHandlerClassName(string $tagName, TypeContext $context): string
|
||||
private function findHandlerClassName(string $tagName, TypeContext $context)
|
||||
{
|
||||
$handlerClassName = Generic::class;
|
||||
if (isset($this->tagHandlerMappings[$tagName])) {
|
||||
@@ -268,18 +282,18 @@ final class StandardTagFactory implements TagFactory
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($locator[$typeHint])) {
|
||||
$arguments[] = $locator[$typeHint];
|
||||
continue;
|
||||
}
|
||||
|
||||
$parameterName = $parameter->getName();
|
||||
if (isset($locator[$parameterName])) {
|
||||
$arguments[] = $locator[$parameterName];
|
||||
if (isset($locator[$typeHint])) {
|
||||
$arguments[$parameterName] = $locator[$typeHint];
|
||||
continue;
|
||||
}
|
||||
|
||||
$arguments[] = null;
|
||||
if (isset($locator[$parameterName])) {
|
||||
$arguments[$parameterName] = $locator[$parameterName];
|
||||
continue;
|
||||
}
|
||||
|
||||
$arguments[$parameterName] = null;
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
@@ -289,12 +303,14 @@ final class StandardTagFactory implements TagFactory
|
||||
* Retrieves a series of ReflectionParameter objects for the static 'create' method of the given
|
||||
* tag handler class name.
|
||||
*
|
||||
* @param class-string $handlerClassName
|
||||
* @param class-string|Factory $handler
|
||||
*
|
||||
* @return ReflectionParameter[]
|
||||
*/
|
||||
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
|
||||
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();
|
||||
|
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
|
||||
interface TagFactory
|
||||
interface TagFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Adds a parameter to the service locator that can be injected in a tag's factory method.
|
||||
@@ -40,17 +40,6 @@ interface TagFactory
|
||||
*/
|
||||
public function addParameter(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Registers a service with the Service Locator using the FQCN of the class or the alias, if provided.
|
||||
*
|
||||
@@ -71,7 +60,7 @@ interface TagFactory
|
||||
*
|
||||
* @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> $handler FQCN of handler.
|
||||
* @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
|
||||
@@ -80,5 +69,5 @@ interface TagFactory
|
||||
* @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, string $handler): void;
|
||||
public function registerTagHandler(string $tagName, $handler): void;
|
||||
}
|
||||
|
@@ -27,13 +27,13 @@ use const FILTER_VALIDATE_EMAIL;
|
||||
final class Author extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string register that this is the author tag. */
|
||||
protected $name = 'author';
|
||||
protected string $name = 'author';
|
||||
|
||||
/** @var string The name of the author */
|
||||
private $authorName;
|
||||
private string $authorName;
|
||||
|
||||
/** @var string The email of the author */
|
||||
private $authorEmail;
|
||||
private string $authorEmail;
|
||||
|
||||
/**
|
||||
* Initializes this tag with the author name and e-mail.
|
||||
|
@@ -22,10 +22,10 @@ use phpDocumentor\Reflection\DocBlock\Description;
|
||||
abstract class BaseTag implements DocBlock\Tag
|
||||
{
|
||||
/** @var string Name of the tag */
|
||||
protected $name = '';
|
||||
protected string $name = '';
|
||||
|
||||
/** @var Description|null Description of the tag. */
|
||||
protected $description;
|
||||
protected ?Description $description = null;
|
||||
|
||||
/**
|
||||
* Gets the name of this tag.
|
||||
|
@@ -29,11 +29,9 @@ use function explode;
|
||||
*/
|
||||
final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'covers';
|
||||
protected string $name = 'covers';
|
||||
|
||||
/** @var Fqsen */
|
||||
private $refers;
|
||||
private Fqsen $refers;
|
||||
|
||||
/**
|
||||
* Initializes this tag.
|
||||
|
@@ -25,8 +25,7 @@ use function preg_match;
|
||||
*/
|
||||
final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'deprecated';
|
||||
protected string $name = 'deprecated';
|
||||
|
||||
/**
|
||||
* PCRE regular expression matching a version vector.
|
||||
@@ -45,7 +44,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
)';
|
||||
|
||||
/** @var string|null The version vector. */
|
||||
private $version;
|
||||
private ?string $version = null;
|
||||
|
||||
public function __construct(?string $version = null, ?Description $description = null)
|
||||
{
|
||||
|
@@ -29,22 +29,19 @@ use function trim;
|
||||
final class Example implements Tag, Factory\StaticMethod
|
||||
{
|
||||
/** @var string Path to a file to use as an example. May also be an absolute URI. */
|
||||
private $filePath;
|
||||
private string $filePath;
|
||||
|
||||
/**
|
||||
* @var bool Whether the file path component represents an URI. This determines how the file portion
|
||||
* appears at {@link getContent()}.
|
||||
*/
|
||||
private $isURI;
|
||||
private bool $isURI;
|
||||
|
||||
/** @var int */
|
||||
private $startingLine;
|
||||
private int $startingLine;
|
||||
|
||||
/** @var int */
|
||||
private $lineCount;
|
||||
private int $lineCount;
|
||||
|
||||
/** @var string|null */
|
||||
private $content;
|
||||
private ?string $content = null;
|
||||
|
||||
public function __construct(
|
||||
string $filePath,
|
||||
|
122
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php
vendored
Normal file
122
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
<?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\PhpDocParser;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use RuntimeException;
|
||||
|
||||
use function ltrim;
|
||||
use function property_exists;
|
||||
use function rtrim;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$this->lexer = new Lexer(true);
|
||||
$constParser = new ConstExprParser(true, true, ['lines' => true, 'indexes' => true]);
|
||||
$this->parser = new PhpDocParser(
|
||||
new TypeParser($constParser, true, ['lines' => true, 'indexes' => true]),
|
||||
$constParser,
|
||||
true,
|
||||
true,
|
||||
['lines' => true, 'indexes' => true],
|
||||
true
|
||||
);
|
||||
$this->factories = $factories;
|
||||
}
|
||||
|
||||
public function create(string $tagLine, ?TypeContext $context = null): Tag
|
||||
{
|
||||
$tokens = $this->tokenizeLine($tagLine);
|
||||
$ast = $this->parser->parseTag($tokens);
|
||||
if (property_exists($ast->value, 'description') === true) {
|
||||
$ast->value->setAttribute(
|
||||
'description',
|
||||
$ast->value->description . $tokens->joinUntil(Lexer::TOKEN_END)
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
$tokens = $this->lexer->tokenize($tagLine);
|
||||
$fixed = [];
|
||||
foreach ($tokens as $token) {
|
||||
if (($token[1] === Lexer::TOKEN_PHPDOC_EOL) && rtrim($token[0], " \t") !== $token[0]) {
|
||||
$fixed[] = [
|
||||
rtrim($token[Lexer::VALUE_OFFSET], " \t"),
|
||||
Lexer::TOKEN_PHPDOC_EOL,
|
||||
$token[2] ?? null,
|
||||
];
|
||||
$fixed[] = [
|
||||
ltrim($token[Lexer::VALUE_OFFSET], "\n\r"),
|
||||
Lexer::TOKEN_HORIZONTAL_WS,
|
||||
($token[2] ?? null) + 1,
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$fixed[] = $token;
|
||||
}
|
||||
|
||||
return new TokenIterator($fixed);
|
||||
}
|
||||
}
|
41
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/Factory.php
vendored
Normal file
41
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/Factory.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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;
|
||||
}
|
81
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/MethodFactory.php
vendored
Normal file
81
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/MethodFactory.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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,
|
||||
[],
|
||||
$this->createReturnType($tagValue, $context),
|
||||
$tagValue->isStatic,
|
||||
$this->descriptionFactory->create($tagValue->description, $context),
|
||||
false,
|
||||
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,
|
||||
(string) $param->defaultValue
|
||||
);
|
||||
},
|
||||
$tagValue->parameters
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
16
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PHPStanFactory.php
vendored
Normal file
16
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PHPStanFactory.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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;
|
||||
}
|
92
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/ParamFactory.php
vendored
Normal file
92
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/ParamFactory.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
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\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 sprintf;
|
||||
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) {
|
||||
Deprecation::trigger(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/362',
|
||||
sprintf(
|
||||
'Param tag value "%s" is invalid, falling back to legacy parsing. Please update your docblocks.',
|
||||
$tagValue->value
|
||||
)
|
||||
);
|
||||
|
||||
return Param::create($tagValue->value, $this->typeResolver, $this->descriptionFactory, $context);
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyFactory.php
vendored
Normal file
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyFactory.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyReadFactory.php
vendored
Normal file
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyReadFactory.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyWriteFactory.php
vendored
Normal file
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/PropertyWriteFactory.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
52
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/ReturnFactory.php
vendored
Normal file
52
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/ReturnFactory.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/VarFactory.php
vendored
Normal file
54
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/VarFactory.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
@@ -23,7 +23,7 @@ use function strlen;
|
||||
class AlignFormatter implements Formatter
|
||||
{
|
||||
/** @var int The maximum tag name length. */
|
||||
protected $maxLen = 0;
|
||||
protected int $maxLen = 0;
|
||||
|
||||
/**
|
||||
* @param Tag[] $tags All tags that should later be aligned with the formatter.
|
||||
|
@@ -32,14 +32,11 @@ use function sprintf;
|
||||
*/
|
||||
final class InvalidTag implements Tag
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
private string $name;
|
||||
|
||||
/** @var string */
|
||||
private $body;
|
||||
private string $body;
|
||||
|
||||
/** @var Throwable|null */
|
||||
private $throwable;
|
||||
private ?Throwable $throwable = null;
|
||||
|
||||
private function __construct(string $name, string $body)
|
||||
{
|
||||
|
@@ -24,11 +24,9 @@ use Webmozart\Assert\Assert;
|
||||
*/
|
||||
final class Link extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'link';
|
||||
protected string $name = 'link';
|
||||
|
||||
/** @var string */
|
||||
private $link;
|
||||
private string $link;
|
||||
|
||||
/**
|
||||
* Initializes a link to a URL.
|
||||
|
@@ -24,6 +24,7 @@ use phpDocumentor\Reflection\Types\Void_;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function explode;
|
||||
use function implode;
|
||||
use function is_string;
|
||||
@@ -31,34 +32,33 @@ use function preg_match;
|
||||
use function sort;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
use function trigger_error;
|
||||
use function trim;
|
||||
use function var_export;
|
||||
|
||||
use const E_USER_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Reflection class for an {@}method in a Docblock.
|
||||
*/
|
||||
final class Method extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'method';
|
||||
protected string $name = 'method';
|
||||
|
||||
/** @var string */
|
||||
private $methodName;
|
||||
private string $methodName;
|
||||
|
||||
/**
|
||||
* @phpstan-var array<int, array{name: string, type: Type}>
|
||||
* @var array<int, array<string, Type|string>>
|
||||
*/
|
||||
private $arguments;
|
||||
private bool $isStatic;
|
||||
|
||||
/** @var bool */
|
||||
private $isStatic;
|
||||
private Type $returnType;
|
||||
|
||||
/** @var Type */
|
||||
private $returnType;
|
||||
private bool $returnsReference;
|
||||
|
||||
/** @var MethodParameter[] */
|
||||
private array $parameters;
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, Type|string>> $arguments
|
||||
* @param MethodParameter[] $parameters
|
||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -66,7 +66,9 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
array $arguments = [],
|
||||
?Type $returnType = null,
|
||||
bool $static = false,
|
||||
?Description $description = null
|
||||
?Description $description = null,
|
||||
bool $returnsReference = false,
|
||||
?array $parameters = null
|
||||
) {
|
||||
Assert::stringNotEmpty($methodName);
|
||||
|
||||
@@ -74,19 +76,31 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
$returnType = new Void_();
|
||||
}
|
||||
|
||||
$this->methodName = $methodName;
|
||||
$this->arguments = $this->filterArguments($arguments);
|
||||
$this->returnType = $returnType;
|
||||
$this->isStatic = $static;
|
||||
$this->description = $description;
|
||||
$arguments = $this->filterArguments($arguments);
|
||||
|
||||
$this->methodName = $methodName;
|
||||
$this->returnType = $returnType;
|
||||
$this->isStatic = $static;
|
||||
$this->description = $description;
|
||||
$this->returnsReference = $returnsReference;
|
||||
$this->parameters = $parameters ?? $this->fromLegacyArguments($arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): ?self {
|
||||
trigger_error(
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -95,11 +109,13 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
// 2. optionally the keyword "static" followed by whitespace
|
||||
// 3. optionally a word with underscores followed by whitespace : as
|
||||
// type for the return value
|
||||
// 4. then optionally a word with underscores followed by () and
|
||||
// 4. optionally an ampersand followed or not by whitespace : as
|
||||
// a reference
|
||||
// 5. then optionally a word with underscores followed by () and
|
||||
// whitespace : as method name as used by phpDocumentor
|
||||
// 5. then a word with underscores, followed by ( and any character
|
||||
// 6. then a word with underscores, followed by ( and any character
|
||||
// until a ) and whitespace : as method name with signature
|
||||
// 6. any remaining text : as description
|
||||
// 7. any remaining text : as description
|
||||
if (
|
||||
!preg_match(
|
||||
'/^
|
||||
@@ -122,6 +138,11 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
)
|
||||
\s+
|
||||
)?
|
||||
# Returns reference
|
||||
(?:
|
||||
(&)
|
||||
\s*
|
||||
)?
|
||||
# Method name
|
||||
([\w_]+)
|
||||
# Arguments
|
||||
@@ -139,7 +160,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
return null;
|
||||
}
|
||||
|
||||
[, $static, $returnType, $methodName, $argumentLines, $description] = $matches;
|
||||
[, $static, $returnType, $returnsReference, $methodName, $argumentLines, $description] = $matches;
|
||||
|
||||
$static = $static === 'static';
|
||||
|
||||
@@ -147,6 +168,8 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
$returnType = 'void';
|
||||
}
|
||||
|
||||
$returnsReference = $returnsReference === '&';
|
||||
|
||||
$returnType = $typeResolver->resolve($returnType, $context);
|
||||
$description = $descriptionFactory->create($description, $context);
|
||||
|
||||
@@ -172,7 +195,14 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
}
|
||||
|
||||
return new static($methodName, $arguments, $returnType, $static, $description);
|
||||
return new static(
|
||||
$methodName,
|
||||
$arguments,
|
||||
$returnType,
|
||||
$static,
|
||||
$description,
|
||||
$returnsReference
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,12 +214,27 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Method deprecated, use {@see self::getParameters()}
|
||||
*
|
||||
* @return array<int, array<string, Type|string>>
|
||||
* @phpstan-return array<int, array{name: string, type: Type}>
|
||||
*/
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->arguments;
|
||||
trigger_error('Method deprecated, use ::getParameters()', E_USER_DEPRECATED);
|
||||
|
||||
return array_map(
|
||||
static function (MethodParameter $methodParameter) {
|
||||
return ['name' => $methodParameter->getName(), 'type' => $methodParameter->getType()];
|
||||
},
|
||||
$this->parameters
|
||||
);
|
||||
}
|
||||
|
||||
/** @return MethodParameter[] */
|
||||
public function getParameters(): array
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,11 +252,19 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
public function returnsReference(): bool
|
||||
{
|
||||
return $this->returnsReference;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($this->arguments as $argument) {
|
||||
$arguments[] = $argument['type'] . ' $' . $argument['name'];
|
||||
foreach ($this->parameters as $parameter) {
|
||||
$arguments[] = $parameter->getType() . ' ' .
|
||||
($parameter->isReference() ? '&' : '') .
|
||||
($parameter->isVariadic() ? '...' : '') .
|
||||
'$' . $parameter->getName();
|
||||
}
|
||||
|
||||
$argumentStr = '(' . implode(', ', $arguments) . ')';
|
||||
@@ -228,9 +281,11 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
$methodName = $this->methodName;
|
||||
|
||||
$reference = $this->returnsReference ? '&' : '';
|
||||
|
||||
return $static
|
||||
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')
|
||||
. ($methodName !== '' ? ($static !== '' || $returnType !== '' ? ' ' : '') . $methodName : '')
|
||||
. ($methodName !== '' ? ($static !== '' || $returnType !== '' ? ' ' : '') . $reference . $methodName : '')
|
||||
. $argumentStr
|
||||
. ($description !== '' ? ' ' . $description : '');
|
||||
}
|
||||
@@ -276,4 +331,28 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return $argument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{name: string, type: Type} $arguments
|
||||
* @phpstan-param array<int, array{name: string, type: Type}> $arguments
|
||||
*
|
||||
* @return MethodParameter[]
|
||||
*/
|
||||
private function fromLegacyArguments(array $arguments): array
|
||||
{
|
||||
trigger_error(
|
||||
'Create method parameters via legacy format is deprecated add parameters via the constructor',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
return array_map(
|
||||
static function ($arg) {
|
||||
return new MethodParameter(
|
||||
$arg['name'],
|
||||
$arg['type']
|
||||
);
|
||||
},
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
}
|
||||
|
67
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/MethodParameter.php
vendored
Normal file
67
vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/MethodParameter.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\Type;
|
||||
|
||||
final class MethodParameter
|
||||
{
|
||||
private Type $type;
|
||||
|
||||
private bool $isReference;
|
||||
|
||||
private bool $isVariadic;
|
||||
|
||||
private string $name;
|
||||
|
||||
private ?string $defaultValue = null;
|
||||
|
||||
public function __construct(
|
||||
string $name,
|
||||
Type $type,
|
||||
bool $isReference = false,
|
||||
bool $isVariadic = false,
|
||||
?string $defaultValue = null
|
||||
) {
|
||||
$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
|
||||
{
|
||||
return $this->defaultValue;
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -34,14 +35,13 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
final class Param extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string|null */
|
||||
private $variableName;
|
||||
private ?string $variableName = null;
|
||||
|
||||
/** @var bool determines whether this is a variadic argument */
|
||||
private $isVariadic;
|
||||
private bool $isVariadic;
|
||||
|
||||
/** @var bool determines whether this is passed by reference */
|
||||
private $isReference;
|
||||
private bool $isReference;
|
||||
|
||||
public function __construct(
|
||||
?string $variableName,
|
||||
@@ -58,12 +58,23 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
$this->isReference = $isReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -34,8 +35,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
final class Property extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string|null */
|
||||
protected $variableName;
|
||||
protected ?string $variableName = null;
|
||||
|
||||
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
@@ -47,12 +47,23 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
$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,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -34,8 +35,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string|null */
|
||||
protected $variableName;
|
||||
protected ?string $variableName = null;
|
||||
|
||||
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
@@ -47,12 +47,23 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
$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,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -34,8 +35,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $variableName;
|
||||
protected string $variableName;
|
||||
|
||||
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
@@ -47,12 +47,23 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
$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,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
@@ -20,8 +20,7 @@ use phpDocumentor\Reflection\Fqsen as RealFqsen;
|
||||
*/
|
||||
final class Fqsen implements Reference
|
||||
{
|
||||
/** @var RealFqsen */
|
||||
private $fqsen;
|
||||
private RealFqsen $fqsen;
|
||||
|
||||
public function __construct(RealFqsen $fqsen)
|
||||
{
|
||||
|
@@ -20,8 +20,7 @@ use Webmozart\Assert\Assert;
|
||||
*/
|
||||
final class Url implements Reference
|
||||
{
|
||||
/** @var string */
|
||||
private $uri;
|
||||
private string $uri;
|
||||
|
||||
public function __construct(string $uri)
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -32,12 +33,23 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
$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,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
|
@@ -33,11 +33,9 @@ use function preg_match;
|
||||
*/
|
||||
final class See extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'see';
|
||||
protected string $name = 'see';
|
||||
|
||||
/** @var Reference */
|
||||
protected $refers;
|
||||
protected Reference $refers;
|
||||
|
||||
/**
|
||||
* Initializes this tag.
|
||||
|
@@ -25,8 +25,7 @@ use function preg_match;
|
||||
*/
|
||||
final class Since extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'since';
|
||||
protected string $name = 'since';
|
||||
|
||||
/**
|
||||
* PCRE regular expression matching a version vector.
|
||||
@@ -45,7 +44,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
)';
|
||||
|
||||
/** @var string|null The version vector. */
|
||||
private $version;
|
||||
private ?string $version = null;
|
||||
|
||||
public function __construct(?string $version = null, ?Description $description = null)
|
||||
{
|
||||
|
@@ -25,14 +25,13 @@ use function preg_match;
|
||||
*/
|
||||
final class Source extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'source';
|
||||
protected string $name = 'source';
|
||||
|
||||
/** @var int The starting line, relative to the structural element's location. */
|
||||
private $startingLine;
|
||||
private int $startingLine;
|
||||
|
||||
/** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */
|
||||
private $lineCount;
|
||||
private ?int $lineCount = null;
|
||||
|
||||
/**
|
||||
* @param int|string $startingLine should be a to int convertible value
|
||||
|
@@ -13,9 +13,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
use function in_array;
|
||||
use function sprintf;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function trim;
|
||||
@@ -23,7 +25,7 @@ use function trim;
|
||||
abstract class TagWithType extends BaseTag
|
||||
{
|
||||
/** @var ?Type */
|
||||
protected $type;
|
||||
protected ?Type $type = null;
|
||||
|
||||
/**
|
||||
* Returns the type section of the variable.
|
||||
@@ -59,6 +61,12 @@ abstract class TagWithType extends BaseTag
|
||||
}
|
||||
}
|
||||
|
||||
if ($nestingLevel < 0 || $nestingLevel > 0) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('Could not find type in %s, please check for malformed notations', $body)
|
||||
);
|
||||
}
|
||||
|
||||
$description = trim(substr($body, strlen($type)));
|
||||
|
||||
return [$type, $description];
|
||||
|
@@ -29,11 +29,9 @@ use function explode;
|
||||
*/
|
||||
final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'uses';
|
||||
protected string $name = 'uses';
|
||||
|
||||
/** @var Fqsen */
|
||||
protected $refers;
|
||||
protected Fqsen $refers;
|
||||
|
||||
/**
|
||||
* Initializes this tag.
|
||||
|
@@ -13,6 +13,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
@@ -34,8 +35,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
*/
|
||||
final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string|null */
|
||||
protected $variableName = '';
|
||||
protected ?string $variableName = '';
|
||||
|
||||
public function __construct(?string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
@@ -47,12 +47,22 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
$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,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
@@ -25,8 +25,7 @@ use function preg_match;
|
||||
*/
|
||||
final class Version extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
/** @var string */
|
||||
protected $name = 'version';
|
||||
protected string $name = 'version';
|
||||
|
||||
/**
|
||||
* PCRE regular expression matching a version vector.
|
||||
@@ -45,7 +44,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
)';
|
||||
|
||||
/** @var string|null The version vector. */
|
||||
private $version;
|
||||
private ?string $version = null;
|
||||
|
||||
public function __construct(?string $version = null, ?Description $description = null)
|
||||
{
|
||||
|
@@ -19,6 +19,15 @@ 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\AbstractPHPStanFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
|
||||
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\VarFactory;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
@@ -35,11 +44,9 @@ use function trim;
|
||||
|
||||
final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
{
|
||||
/** @var DocBlock\DescriptionFactory */
|
||||
private $descriptionFactory;
|
||||
private DocBlock\DescriptionFactory $descriptionFactory;
|
||||
|
||||
/** @var DocBlock\TagFactory */
|
||||
private $tagFactory;
|
||||
private TagFactory $tagFactory;
|
||||
|
||||
/**
|
||||
* Initializes this factory with the required subcontractors.
|
||||
@@ -47,22 +54,40 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory)
|
||||
{
|
||||
$this->descriptionFactory = $descriptionFactory;
|
||||
$this->tagFactory = $tagFactory;
|
||||
$this->tagFactory = $tagFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for easy instantiation.
|
||||
*
|
||||
* @param array<string, class-string<Tag>> $additionalTags
|
||||
* @param array<string, class-string<Tag>|Factory> $additionalTags
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []): self
|
||||
public static function createInstance(array $additionalTags = []): DocBlockFactoryInterface
|
||||
{
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($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)
|
||||
);
|
||||
|
||||
$tagFactory->addService($descriptionFactory);
|
||||
$tagFactory->addService(new TypeResolver($fqsenResolver));
|
||||
$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);
|
||||
|
||||
$docBlockFactory = new self($descriptionFactory, $tagFactory);
|
||||
foreach ($additionalTags as $tagName => $tagHandler) {
|
||||
@@ -111,9 +136,9 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Tag> $handler
|
||||
* @param class-string<Tag>|Factory $handler
|
||||
*/
|
||||
public function registerTagHandler(string $tagName, string $handler): void
|
||||
public function registerTagHandler(string $tagName, $handler): void
|
||||
{
|
||||
$this->tagFactory->registerTagHandler($tagName, $handler);
|
||||
}
|
||||
@@ -138,6 +163,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
}
|
||||
|
||||
// phpcs:disable
|
||||
|
||||
/**
|
||||
* Splits the DocBlock into a template marker, summary, description and block of tags.
|
||||
*
|
||||
@@ -149,7 +175,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @author Richard van Velzen (@_richardJ) Special thanks to Richard for the regex responsible for the split.
|
||||
*/
|
||||
private function splitDocBlock(string $comment) : array
|
||||
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
|
||||
@@ -227,7 +253,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
/**
|
||||
* Creates the tag objects.
|
||||
*
|
||||
* @param string $tags Tag block to parse.
|
||||
* @param string $tags Tag block to parse.
|
||||
* @param Types\Context $context Context of the parsed Tag
|
||||
*
|
||||
* @return DocBlock\Tag[]
|
||||
@@ -240,7 +266,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$lines = $this->splitTagBlockIntoTagLines($tags);
|
||||
$lines = $this->splitTagBlockIntoTagLines($tags);
|
||||
foreach ($lines as $key => $tagLine) {
|
||||
$result[$key] = $this->tagFactory->create(trim($tagLine), $context);
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ interface DocBlockFactoryInterface
|
||||
*
|
||||
* @param array<string, class-string<Tag>> $additionalTags
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []): DocBlockFactory;
|
||||
public static function createInstance(array $additionalTags = []): self;
|
||||
|
||||
/**
|
||||
* @param string|object $docblock
|
||||
|
@@ -1,65 +0,0 @@
|
||||
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"
|
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"symbol-whitelist" : [
|
||||
"null", "true", "false",
|
||||
"static", "self", "parent",
|
||||
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor",
|
||||
"T_NAME_QUALIFIED", "T_NAME_FULLY_QUALIFIED"
|
||||
],
|
||||
"php-core-extensions" : [
|
||||
"Core",
|
||||
"pcre",
|
||||
"Reflection",
|
||||
"tokenizer",
|
||||
"SPL",
|
||||
"standard"
|
||||
]
|
||||
}
|
11
vendor/phpdocumentor/type-resolver/composer.json
vendored
11
vendor/phpdocumentor/type-resolver/composer.json
vendored
@@ -10,8 +10,10 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"phpdocumentor/reflection-common": "^2.0"
|
||||
"php": "^7.3 || ^8.0",
|
||||
"phpdocumentor/reflection-common": "^2.0",
|
||||
"phpstan/phpdoc-parser": "^1.13",
|
||||
"doctrine/deprecations": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-tokenizer": "*",
|
||||
@@ -20,7 +22,8 @@
|
||||
"phpstan/phpstan-phpunit": "^1.1",
|
||||
"phpstan/extension-installer": "^1.1",
|
||||
"vimeo/psalm": "^4.25",
|
||||
"rector/rector": "^0.13.9"
|
||||
"rector/rector": "^0.13.9",
|
||||
"phpbench/phpbench": "^1.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -39,7 +42,7 @@
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.4.0"
|
||||
"php": "7.3.0"
|
||||
},
|
||||
"allow-plugins": {
|
||||
"phpstan/extension-installer": true
|
||||
|
26
vendor/phpdocumentor/type-resolver/rector.php
vendored
26
vendor/phpdocumentor/type-resolver/rector.php
vendored
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Set\ValueObject\LevelSetList;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->paths([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/tests/unit'
|
||||
]);
|
||||
|
||||
// register a single rule
|
||||
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
|
||||
$rectorConfig->rule(Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class);
|
||||
$rectorConfig->rule(Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$rectorConfig->rule(Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector::class);
|
||||
$rectorConfig->importNames();
|
||||
|
||||
// define sets of rules
|
||||
$rectorConfig->sets([
|
||||
LevelSetList::UP_TO_PHP_74
|
||||
]);
|
||||
};
|
52
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ArrayShape.php
vendored
Normal file
52
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ArrayShape.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\ArrayKey;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
|
||||
use function implode;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class ArrayShape implements PseudoType
|
||||
{
|
||||
/** @var ArrayShapeItem[] */
|
||||
private $items;
|
||||
|
||||
public function __construct(ArrayShapeItem ...$items)
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayShapeItem[]
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Array_(new Mixed_(), new ArrayKey());
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'array{' . implode(', ', $this->items) . '}';
|
||||
}
|
||||
}
|
65
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ArrayShapeItem.php
vendored
Normal file
65
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ArrayShapeItem.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
final class ArrayShapeItem
|
||||
{
|
||||
/** @var string|null */
|
||||
private $key;
|
||||
/** @var Type */
|
||||
private $value;
|
||||
/** @var bool */
|
||||
private $optional;
|
||||
|
||||
public function __construct(?string $key, ?Type $value, bool $optional)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value ?? new Mixed_();
|
||||
$this->optional = $optional;
|
||||
}
|
||||
|
||||
public function getKey(): ?string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function getValue(): Type
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return $this->optional;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->key !== null) {
|
||||
return sprintf(
|
||||
'%s%s: %s',
|
||||
$this->key,
|
||||
$this->optional ? '?' : '',
|
||||
(string) $this->value
|
||||
);
|
||||
}
|
||||
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
55
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ConstExpression.php
vendored
Normal file
55
vendor/phpdocumentor/type-resolver/src/PseudoTypes/ConstExpression.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @psalm-immutable */
|
||||
final class ConstExpression implements PseudoType
|
||||
{
|
||||
/** @var Type */
|
||||
private $owner;
|
||||
/** @var string */
|
||||
private $expression;
|
||||
|
||||
public function __construct(Type $owner, string $expression)
|
||||
{
|
||||
$this->owner = $owner;
|
||||
$this->expression = $expression;
|
||||
}
|
||||
|
||||
public function getOwner(): Type
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function getExpression(): string
|
||||
{
|
||||
return $this->expression;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Mixed_();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return sprintf('%s::%s', (string) $this->owner, $this->expression);
|
||||
}
|
||||
}
|
45
vendor/phpdocumentor/type-resolver/src/PseudoTypes/FloatValue.php
vendored
Normal file
45
vendor/phpdocumentor/type-resolver/src/PseudoTypes/FloatValue.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Float_;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class FloatValue implements PseudoType
|
||||
{
|
||||
/** @var float */
|
||||
private $value;
|
||||
|
||||
public function __construct(float $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getValue(): float
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Float_();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
@@ -24,9 +24,11 @@ use phpDocumentor\Reflection\Types\Integer;
|
||||
*/
|
||||
final class IntegerRange extends Integer implements PseudoType
|
||||
{
|
||||
private string $minValue;
|
||||
/** @var string */
|
||||
private $minValue;
|
||||
|
||||
private string $maxValue;
|
||||
/** @var string */
|
||||
private $maxValue;
|
||||
|
||||
public function __construct(string $minValue, string $maxValue)
|
||||
{
|
||||
|
45
vendor/phpdocumentor/type-resolver/src/PseudoTypes/IntegerValue.php
vendored
Normal file
45
vendor/phpdocumentor/type-resolver/src/PseudoTypes/IntegerValue.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
|
||||
/** @psalm-immutable */
|
||||
final class IntegerValue implements PseudoType
|
||||
{
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
public function __construct(int $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getValue(): int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Integer();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) $this->value;
|
||||
}
|
||||
}
|
50
vendor/phpdocumentor/type-resolver/src/PseudoTypes/NonEmptyList.php
vendored
Normal file
50
vendor/phpdocumentor/type-resolver/src/PseudoTypes/NonEmptyList.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
|
||||
/**
|
||||
* Value Object representing the type 'non-empty-list'.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class NonEmptyList extends Array_ implements PseudoType
|
||||
{
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new Array_();
|
||||
}
|
||||
|
||||
public function __construct(?Type $valueType = null)
|
||||
{
|
||||
parent::__construct($valueType, new Integer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->valueType instanceof Mixed_) {
|
||||
return 'non-empty-list';
|
||||
}
|
||||
|
||||
return 'non-empty-list<' . $this->valueType . '>';
|
||||
}
|
||||
}
|
47
vendor/phpdocumentor/type-resolver/src/PseudoTypes/StringValue.php
vendored
Normal file
47
vendor/phpdocumentor/type-resolver/src/PseudoTypes/StringValue.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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\PseudoTypes;
|
||||
|
||||
use phpDocumentor\Reflection\PseudoType;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class StringValue implements PseudoType
|
||||
{
|
||||
/** @var string */
|
||||
private $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getValue(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function underlyingType(): Type
|
||||
{
|
||||
return new String_();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return sprintf('"%s"', $this->value);
|
||||
}
|
||||
}
|
@@ -13,27 +13,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use ArrayIterator;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\PseudoTypes\ArrayShape;
|
||||
use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem;
|
||||
use phpDocumentor\Reflection\PseudoTypes\CallableString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\ConstExpression;
|
||||
use phpDocumentor\Reflection\PseudoTypes\False_;
|
||||
use phpDocumentor\Reflection\PseudoTypes\FloatValue;
|
||||
use phpDocumentor\Reflection\PseudoTypes\HtmlEscapedString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\IntegerRange;
|
||||
use phpDocumentor\Reflection\PseudoTypes\IntegerValue;
|
||||
use phpDocumentor\Reflection\PseudoTypes\List_;
|
||||
use phpDocumentor\Reflection\PseudoTypes\LiteralString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\LowercaseString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\NegativeInteger;
|
||||
use phpDocumentor\Reflection\PseudoTypes\NonEmptyList;
|
||||
use phpDocumentor\Reflection\PseudoTypes\NonEmptyLowercaseString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\NonEmptyString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\Numeric_;
|
||||
use phpDocumentor\Reflection\PseudoTypes\NumericString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\PositiveInteger;
|
||||
use phpDocumentor\Reflection\PseudoTypes\StringValue;
|
||||
use phpDocumentor\Reflection\PseudoTypes\TraitString;
|
||||
use phpDocumentor\Reflection\PseudoTypes\True_;
|
||||
use phpDocumentor\Reflection\Types\AggregatedType;
|
||||
use phpDocumentor\Reflection\Types\Array_;
|
||||
use phpDocumentor\Reflection\Types\ArrayKey;
|
||||
use phpDocumentor\Reflection\Types\Boolean;
|
||||
use phpDocumentor\Reflection\Types\Callable_;
|
||||
use phpDocumentor\Reflection\Types\CallableParameter;
|
||||
use phpDocumentor\Reflection\Types\ClassString;
|
||||
use phpDocumentor\Reflection\Types\Collection;
|
||||
use phpDocumentor\Reflection\Types\Compound;
|
||||
@@ -57,51 +66,56 @@ use phpDocumentor\Reflection\Types\Static_;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use phpDocumentor\Reflection\Types\This;
|
||||
use phpDocumentor\Reflection\Types\Void_;
|
||||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFloatNode;
|
||||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
|
||||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
|
||||
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ConditionalTypeForParameterNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ConditionalTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ConstTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\NullableTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\OffsetAccessTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
|
||||
use PHPStan\PhpDocParser\Lexer\Lexer;
|
||||
use PHPStan\PhpDocParser\Parser\ConstExprParser;
|
||||
use PHPStan\PhpDocParser\Parser\ParserException;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_filter;
|
||||
use function array_key_exists;
|
||||
use function array_key_last;
|
||||
use function array_pop;
|
||||
use function array_values;
|
||||
use function array_map;
|
||||
use function array_reverse;
|
||||
use function class_exists;
|
||||
use function class_implements;
|
||||
use function count;
|
||||
use function current;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function is_numeric;
|
||||
use function preg_split;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function trim;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
use const PREG_SPLIT_NO_EMPTY;
|
||||
|
||||
final class TypeResolver
|
||||
{
|
||||
/** @var string Definition of the ARRAY operator for types */
|
||||
private const OPERATOR_ARRAY = '[]';
|
||||
|
||||
/** @var string Definition of the NAMESPACE operator in PHP */
|
||||
private const OPERATOR_NAMESPACE = '\\';
|
||||
|
||||
/** @var int the iterator parser is inside a compound context */
|
||||
private const PARSER_IN_COMPOUND = 0;
|
||||
|
||||
/** @var int the iterator parser is inside a nullable expression context */
|
||||
private const PARSER_IN_NULLABLE = 1;
|
||||
|
||||
/** @var int the iterator parser is inside an array expression context */
|
||||
private const PARSER_IN_ARRAY_EXPRESSION = 2;
|
||||
|
||||
/** @var int the iterator parser is inside a collection expression context */
|
||||
private const PARSER_IN_COLLECTION_EXPRESSION = 3;
|
||||
|
||||
/**
|
||||
* @var array<string, string> List of recognized keywords and unto which Value Object they map
|
||||
* @psalm-var array<string, class-string<Type>>
|
||||
*/
|
||||
private array $keywords = [
|
||||
private $keywords = [
|
||||
'string' => String_::class,
|
||||
'class-string' => ClassString::class,
|
||||
'interface-string' => InterfaceString::class,
|
||||
@@ -142,10 +156,24 @@ final class TypeResolver
|
||||
'iterable' => Iterable_::class,
|
||||
'never' => Never_::class,
|
||||
'list' => List_::class,
|
||||
'non-empty-list' => NonEmptyList::class,
|
||||
];
|
||||
|
||||
/** @psalm-readonly */
|
||||
private FqsenResolver $fqsenResolver;
|
||||
/**
|
||||
* @psalm-readonly
|
||||
* @var FqsenResolver
|
||||
*/
|
||||
private $fqsenResolver;
|
||||
/**
|
||||
* @psalm-readonly
|
||||
* @var TypeParser
|
||||
*/
|
||||
private $typeParser;
|
||||
/**
|
||||
* @psalm-readonly
|
||||
* @var Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
|
||||
/**
|
||||
* Initializes this TypeResolver with the means to create and resolve Fqsen objects.
|
||||
@@ -153,6 +181,8 @@ final class TypeResolver
|
||||
public function __construct(?FqsenResolver $fqsenResolver = null)
|
||||
{
|
||||
$this->fqsenResolver = $fqsenResolver ?: new FqsenResolver();
|
||||
$this->typeParser = new TypeParser(new ConstExprParser());
|
||||
$this->lexer = new Lexer();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,9 +195,9 @@ final class TypeResolver
|
||||
* This method only works as expected if the namespace and aliases are set;
|
||||
* no dynamic reflection is being performed here.
|
||||
*
|
||||
* @uses Context::getNamespace() to determine with what to prefix the type name.
|
||||
* @uses Context::getNamespaceAliases() to check whether the first part of the relative type name should not be
|
||||
* replaced with another namespace.
|
||||
* @uses Context::getNamespace() to determine with what to prefix the type name.
|
||||
*
|
||||
* @param string $type The relative or absolute type.
|
||||
*/
|
||||
@@ -182,178 +212,219 @@ final class TypeResolver
|
||||
$context = new Context('');
|
||||
}
|
||||
|
||||
// split the type string into tokens `|`, `?`, `<`, `>`, `,`, `(`, `)`, `[]`, '<', '>' and type names
|
||||
$tokens = preg_split(
|
||||
'/(\\||\\?|<|>|&|, ?|\\(|\\)|\\[\\]+)/',
|
||||
$type,
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
$tokens = $this->lexer->tokenize($type);
|
||||
$tokenIterator = new TokenIterator($tokens);
|
||||
|
||||
if ($tokens === false) {
|
||||
throw new InvalidArgumentException('Unable to split the type string "' . $type . '" into tokens');
|
||||
}
|
||||
$ast = $this->parse($tokenIterator);
|
||||
$type = $this->createType($ast, $context);
|
||||
|
||||
/** @var ArrayIterator<int, string|null> $tokenIterator */
|
||||
$tokenIterator = new ArrayIterator($tokens);
|
||||
|
||||
return $this->parseTypes($tokenIterator, $context, self::PARSER_IN_COMPOUND);
|
||||
return $this->tryParseRemainingCompoundTypes($tokenIterator, $context, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analyse each tokens and creates types
|
||||
*
|
||||
* @param ArrayIterator<int, string|null> $tokens the iterator on tokens
|
||||
* @param int $parserContext on of self::PARSER_* constants, indicating
|
||||
* the context where we are in the parsing
|
||||
*/
|
||||
private function parseTypes(ArrayIterator $tokens, Context $context, int $parserContext): Type
|
||||
public function createType(?TypeNode $type, Context $context): Type
|
||||
{
|
||||
$types = [];
|
||||
$token = '';
|
||||
$compoundToken = '|';
|
||||
while ($tokens->valid()) {
|
||||
$token = $tokens->current();
|
||||
if ($token === null) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected nullable character'
|
||||
);
|
||||
}
|
||||
if ($type === null) {
|
||||
return new Mixed_();
|
||||
}
|
||||
|
||||
if ($token === '|' || $token === '&') {
|
||||
if (count($types) === 0) {
|
||||
switch (get_class($type)) {
|
||||
case ArrayTypeNode::class:
|
||||
return new Array_(
|
||||
$this->createType($type->type, $context)
|
||||
);
|
||||
|
||||
case ArrayShapeNode::class:
|
||||
return new ArrayShape(
|
||||
...array_map(
|
||||
function (ArrayShapeItemNode $item) use ($context): ArrayShapeItem {
|
||||
return new ArrayShapeItem(
|
||||
(string) $item->keyName,
|
||||
$this->createType($item->valueType, $context),
|
||||
$item->optional
|
||||
);
|
||||
},
|
||||
$type->items
|
||||
)
|
||||
);
|
||||
|
||||
case CallableTypeNode::class:
|
||||
return $this->createFromCallable($type, $context);
|
||||
|
||||
case ConstTypeNode::class:
|
||||
return $this->createFromConst($type, $context);
|
||||
|
||||
case GenericTypeNode::class:
|
||||
return $this->createFromGeneric($type, $context);
|
||||
|
||||
case IdentifierTypeNode::class:
|
||||
return $this->resolveSingleType($type->name, $context);
|
||||
|
||||
case IntersectionTypeNode::class:
|
||||
return new Intersection(
|
||||
array_filter(
|
||||
array_map(
|
||||
function (TypeNode $nestedType) use ($context): Type {
|
||||
$type = $this->createType($nestedType, $context);
|
||||
if ($type instanceof AggregatedType) {
|
||||
return new Expression($type);
|
||||
}
|
||||
|
||||
return $type;
|
||||
},
|
||||
$type->types
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
case NullableTypeNode::class:
|
||||
$nestedType = $this->createType($type->type, $context);
|
||||
|
||||
return new Nullable($nestedType);
|
||||
|
||||
case UnionTypeNode::class:
|
||||
return new Compound(
|
||||
array_filter(
|
||||
array_map(
|
||||
function (TypeNode $nestedType) use ($context): Type {
|
||||
$type = $this->createType($nestedType, $context);
|
||||
if ($type instanceof AggregatedType) {
|
||||
return new Expression($type);
|
||||
}
|
||||
|
||||
return $type;
|
||||
},
|
||||
$type->types
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
case ThisTypeNode::class:
|
||||
return new This();
|
||||
|
||||
case ConditionalTypeNode::class:
|
||||
case ConditionalTypeForParameterNode::class:
|
||||
case OffsetAccessTypeNode::class:
|
||||
default:
|
||||
return new Mixed_();
|
||||
}
|
||||
}
|
||||
|
||||
private function createFromGeneric(GenericTypeNode $type, Context $context): Type
|
||||
{
|
||||
switch (strtolower($type->type->name)) {
|
||||
case 'array':
|
||||
return $this->createArray($type->genericTypes, $context);
|
||||
|
||||
case 'class-string':
|
||||
$subType = $this->createType($type->genericTypes[0], $context);
|
||||
if (!$subType instanceof Object_ || $subType->getFqsen() === null) {
|
||||
throw new RuntimeException(
|
||||
'A type is missing before a type separator'
|
||||
$subType . ' is not a class string'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!in_array($parserContext, [
|
||||
self::PARSER_IN_COMPOUND,
|
||||
self::PARSER_IN_ARRAY_EXPRESSION,
|
||||
self::PARSER_IN_COLLECTION_EXPRESSION,
|
||||
self::PARSER_IN_NULLABLE,
|
||||
], true)
|
||||
) {
|
||||
return new ClassString(
|
||||
$subType->getFqsen()
|
||||
);
|
||||
|
||||
case 'interface-string':
|
||||
$subType = $this->createType($type->genericTypes[0], $context);
|
||||
if (!$subType instanceof Object_ || $subType->getFqsen() === null) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected type separator'
|
||||
$subType . ' is not a class string'
|
||||
);
|
||||
}
|
||||
|
||||
$compoundToken = $token;
|
||||
$tokens->next();
|
||||
} elseif ($token === '?') {
|
||||
if (
|
||||
!in_array($parserContext, [
|
||||
self::PARSER_IN_COMPOUND,
|
||||
self::PARSER_IN_ARRAY_EXPRESSION,
|
||||
self::PARSER_IN_COLLECTION_EXPRESSION,
|
||||
self::PARSER_IN_NULLABLE,
|
||||
], true)
|
||||
) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected nullable character'
|
||||
);
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
$type = $this->parseTypes($tokens, $context, self::PARSER_IN_NULLABLE);
|
||||
$types[] = new Nullable($type);
|
||||
} elseif ($token === '(') {
|
||||
$tokens->next();
|
||||
$type = $this->parseTypes($tokens, $context, self::PARSER_IN_ARRAY_EXPRESSION);
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token === null) { // Someone did not properly close their array expression ..
|
||||
break;
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
|
||||
$resolvedType = new Expression($type);
|
||||
|
||||
$types[] = $resolvedType;
|
||||
} elseif ($parserContext === self::PARSER_IN_ARRAY_EXPRESSION && isset($token[0]) && $token[0] === ')') {
|
||||
break;
|
||||
} elseif ($token === '<') {
|
||||
if (count($types) === 0) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected collection operator "<", class name is missing'
|
||||
);
|
||||
}
|
||||
|
||||
$classType = array_pop($types);
|
||||
if ($classType !== null) {
|
||||
if ((string) $classType === 'class-string') {
|
||||
$types[] = $this->resolveClassString($tokens, $context);
|
||||
} elseif ((string) $classType === 'int') {
|
||||
$types[] = $this->resolveIntRange($tokens);
|
||||
} elseif ((string) $classType === 'interface-string') {
|
||||
$types[] = $this->resolveInterfaceString($tokens, $context);
|
||||
} else {
|
||||
$types[] = $this->resolveCollection($tokens, $classType, $context);
|
||||
}
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
} elseif (
|
||||
$parserContext === self::PARSER_IN_COLLECTION_EXPRESSION
|
||||
&& ($token === '>' || trim($token) === ',')
|
||||
) {
|
||||
break;
|
||||
} elseif ($token === self::OPERATOR_ARRAY) {
|
||||
$last = array_key_last($types);
|
||||
if ($last === null) {
|
||||
throw new InvalidArgumentException('Unexpected array operator');
|
||||
}
|
||||
|
||||
$lastItem = $types[$last];
|
||||
if ($lastItem instanceof Expression) {
|
||||
$lastItem = $lastItem->getValueType();
|
||||
}
|
||||
|
||||
$types[$last] = new Array_($lastItem);
|
||||
|
||||
$tokens->next();
|
||||
} else {
|
||||
$types[] = $this->resolveSingleType($token, $context);
|
||||
$tokens->next();
|
||||
}
|
||||
}
|
||||
|
||||
if ($token === '|' || $token === '&') {
|
||||
throw new RuntimeException(
|
||||
'A type is missing after a type separator'
|
||||
);
|
||||
}
|
||||
|
||||
if (count($types) === 0) {
|
||||
if ($parserContext === self::PARSER_IN_NULLABLE) {
|
||||
throw new RuntimeException(
|
||||
'A type is missing after a nullable character'
|
||||
return new InterfaceString(
|
||||
$subType->getFqsen()
|
||||
);
|
||||
}
|
||||
|
||||
if ($parserContext === self::PARSER_IN_ARRAY_EXPRESSION) {
|
||||
throw new RuntimeException(
|
||||
'A type is missing in an array expression'
|
||||
case 'list':
|
||||
return new List_(
|
||||
$this->createType($type->genericTypes[0], $context)
|
||||
);
|
||||
}
|
||||
|
||||
if ($parserContext === self::PARSER_IN_COLLECTION_EXPRESSION) {
|
||||
throw new RuntimeException(
|
||||
'A type is missing in a collection expression'
|
||||
case 'non-empty-list':
|
||||
return new NonEmptyList(
|
||||
$this->createType($type->genericTypes[0], $context)
|
||||
);
|
||||
}
|
||||
} elseif (count($types) === 1) {
|
||||
return current($types);
|
||||
}
|
||||
|
||||
if ($compoundToken === '|') {
|
||||
return new Compound(array_values($types));
|
||||
}
|
||||
case 'int':
|
||||
if (isset($type->genericTypes[1]) === false) {
|
||||
throw new RuntimeException('int<min,max> has not the correct format');
|
||||
}
|
||||
|
||||
return new Intersection(array_values($types));
|
||||
return new IntegerRange((string) $type->genericTypes[0], (string) $type->genericTypes[1]);
|
||||
|
||||
case 'iterable':
|
||||
return new Iterable_(
|
||||
...array_reverse(
|
||||
array_map(
|
||||
function (TypeNode $genericType) use ($context): Type {
|
||||
return $this->createType($genericType, $context);
|
||||
},
|
||||
$type->genericTypes
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
default:
|
||||
$collectionType = $this->createType($type->type, $context);
|
||||
if ($collectionType instanceof Object_ === false) {
|
||||
throw new RuntimeException(sprintf('%s is not a collection', (string) $collectionType));
|
||||
}
|
||||
|
||||
return new Collection(
|
||||
$collectionType->getFqsen(),
|
||||
...array_reverse(
|
||||
array_map(
|
||||
function (TypeNode $genericType) use ($context): Type {
|
||||
return $this->createType($genericType, $context);
|
||||
},
|
||||
$type->genericTypes
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function createFromCallable(CallableTypeNode $type, Context $context): Callable_
|
||||
{
|
||||
return new Callable_(array_map(
|
||||
function (CallableTypeParameterNode $param) use ($context): CallableParameter {
|
||||
return new CallableParameter(
|
||||
$this->createType($param->type, $context),
|
||||
$param->parameterName !== '' ? trim($param->parameterName, '$') : null,
|
||||
$param->isReference,
|
||||
$param->isVariadic,
|
||||
$param->isOptional
|
||||
);
|
||||
},
|
||||
$type->parameters
|
||||
), $this->createType($type->returnType, $context));
|
||||
}
|
||||
|
||||
private function createFromConst(ConstTypeNode $type, Context $context): Type
|
||||
{
|
||||
switch (true) {
|
||||
case $type->constExpr instanceof ConstExprIntegerNode:
|
||||
return new IntegerValue((int) $type->constExpr->value);
|
||||
|
||||
case $type->constExpr instanceof ConstExprFloatNode:
|
||||
return new FloatValue((float) $type->constExpr->value);
|
||||
|
||||
case $type->constExpr instanceof ConstExprStringNode:
|
||||
return new StringValue($type->constExpr->value);
|
||||
|
||||
case $type->constExpr instanceof ConstFetchNode:
|
||||
return new ConstExpression(
|
||||
$this->resolve($type->constExpr->className, $context),
|
||||
$type->constExpr->name
|
||||
);
|
||||
|
||||
default:
|
||||
throw new RuntimeException(sprintf('Unsupported constant type %s', get_class($type)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,244 +546,89 @@ final class TypeResolver
|
||||
return new Object_($this->fqsenResolver->resolve($type, $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves class string
|
||||
*
|
||||
* @param ArrayIterator<int, (string|null)> $tokens
|
||||
*/
|
||||
private function resolveClassString(ArrayIterator $tokens, Context $context): Type
|
||||
/** @param TypeNode[] $typeNodes */
|
||||
private function createArray(array $typeNodes, Context $context): Array_
|
||||
{
|
||||
$tokens->next();
|
||||
$types = array_reverse(
|
||||
array_map(
|
||||
function (TypeNode $node) use ($context): Type {
|
||||
return $this->createType($node, $context);
|
||||
},
|
||||
$typeNodes
|
||||
)
|
||||
);
|
||||
|
||||
$classType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
|
||||
|
||||
if (!$classType instanceof Object_ || $classType->getFqsen() === null) {
|
||||
throw new RuntimeException(
|
||||
$classType . ' is not a class string'
|
||||
);
|
||||
if (isset($types[1]) === false) {
|
||||
return new Array_(...$types);
|
||||
}
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token !== '>') {
|
||||
if (empty($token)) {
|
||||
throw new RuntimeException(
|
||||
'class-string: ">" is missing'
|
||||
);
|
||||
if ($this->validArrayKeyType($types[1]) || $types[1] instanceof ArrayKey) {
|
||||
return new Array_(...$types);
|
||||
}
|
||||
|
||||
if ($types[1] instanceof Compound && $types[1]->getIterator()->count() === 2) {
|
||||
if ($this->validArrayKeyType($types[1]->get(0)) && $this->validArrayKeyType($types[1]->get(1))) {
|
||||
return new Array_(...$types);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Unexpected character "' . $token . '", ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
return new ClassString($classType->getFqsen());
|
||||
throw new RuntimeException('An array can have only integers or strings as keys');
|
||||
}
|
||||
|
||||
private function validArrayKeyType(?Type $type): bool
|
||||
{
|
||||
return $type instanceof String_ || $type instanceof Integer;
|
||||
}
|
||||
|
||||
private function parse(TokenIterator $tokenIterator): TypeNode
|
||||
{
|
||||
try {
|
||||
$ast = $this->typeParser->parse($tokenIterator);
|
||||
} catch (ParserException $e) {
|
||||
throw new RuntimeException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
return $ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves integer ranges
|
||||
* Will try to parse unsupported type notations by phpstan
|
||||
*
|
||||
* @param ArrayIterator<int, (string|null)> $tokens
|
||||
* The phpstan parser doesn't support the illegal nullable combinations like this library does.
|
||||
* This method will warn the user about those notations but for bc purposes we will still have it here.
|
||||
*/
|
||||
private function resolveIntRange(ArrayIterator $tokens): Type
|
||||
private function tryParseRemainingCompoundTypes(TokenIterator $tokenIterator, Context $context, Type $type): Type
|
||||
{
|
||||
$tokens->next();
|
||||
|
||||
$token = '';
|
||||
$minValue = null;
|
||||
$maxValue = null;
|
||||
$commaFound = false;
|
||||
$tokenCounter = 0;
|
||||
while ($tokens->valid()) {
|
||||
$tokenCounter++;
|
||||
$token = $tokens->current();
|
||||
if ($token === null) {
|
||||
throw new RuntimeException(
|
||||
'Unexpected nullable character'
|
||||
);
|
||||
}
|
||||
|
||||
$token = trim($token);
|
||||
|
||||
if ($token === '>') {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($token === ',') {
|
||||
$commaFound = true;
|
||||
}
|
||||
|
||||
if ($commaFound === false && $minValue === null) {
|
||||
if (is_numeric($token) || $token === 'max' || $token === 'min') {
|
||||
$minValue = $token;
|
||||
}
|
||||
}
|
||||
|
||||
if ($commaFound === true && $maxValue === null) {
|
||||
if (is_numeric($token) || $token === 'max' || $token === 'min') {
|
||||
$maxValue = $token;
|
||||
}
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
}
|
||||
|
||||
if ($token !== '>') {
|
||||
if (empty($token)) {
|
||||
throw new RuntimeException(
|
||||
'interface-string: ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Unexpected character "' . $token . '", ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
if ($minValue === null || $maxValue === null || $tokenCounter > 4) {
|
||||
throw new RuntimeException(
|
||||
'int<min,max> has not the correct format'
|
||||
);
|
||||
}
|
||||
|
||||
return new IntegerRange($minValue, $maxValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves class string
|
||||
*
|
||||
* @param ArrayIterator<int, (string|null)> $tokens
|
||||
*/
|
||||
private function resolveInterfaceString(ArrayIterator $tokens, Context $context): Type
|
||||
{
|
||||
$tokens->next();
|
||||
|
||||
$classType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
|
||||
|
||||
if (!$classType instanceof Object_ || $classType->getFqsen() === null) {
|
||||
throw new RuntimeException(
|
||||
$classType . ' is not a interface string'
|
||||
);
|
||||
}
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token !== '>') {
|
||||
if (empty($token)) {
|
||||
throw new RuntimeException(
|
||||
'interface-string: ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Unexpected character "' . $token . '", ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
return new InterfaceString($classType->getFqsen());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the collection values and keys
|
||||
*
|
||||
* @param ArrayIterator<int, (string|null)> $tokens
|
||||
*
|
||||
* @return Array_|Iterable_|Collection
|
||||
*/
|
||||
private function resolveCollection(ArrayIterator $tokens, Type $classType, Context $context): Type
|
||||
{
|
||||
$isArray = ((string) $classType === 'array');
|
||||
$isIterable = ((string) $classType === 'iterable');
|
||||
$isList = ((string) $classType === 'list');
|
||||
|
||||
// allow only "array", "iterable" or class name before "<"
|
||||
if (
|
||||
!$isArray && !$isIterable && !$isList
|
||||
&& (!$classType instanceof Object_ || $classType->getFqsen() === null)
|
||||
$tokenIterator->isCurrentTokenType(Lexer::TOKEN_UNION) ||
|
||||
$tokenIterator->isCurrentTokenType(Lexer::TOKEN_INTERSECTION)
|
||||
) {
|
||||
throw new RuntimeException(
|
||||
$classType . ' is not a collection'
|
||||
Deprecation::trigger(
|
||||
'phpdocumentor/type-resolver',
|
||||
'https://github.com/phpDocumentor/TypeResolver/issues/184',
|
||||
'Legacy nullable type detected, please update your code as
|
||||
you are using nullable types in a docblock. support will be removed in v2.0.0'
|
||||
);
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
|
||||
$valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
|
||||
$keyType = null;
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token !== null && trim($token) === ',' && !$isList) {
|
||||
// if we have a comma, then we just parsed the key type, not the value type
|
||||
$keyType = $valueType;
|
||||
if ($isArray) {
|
||||
// check the key type for an "array" collection. We allow only
|
||||
// strings or integers.
|
||||
if (
|
||||
!$keyType instanceof ArrayKey &&
|
||||
!$keyType instanceof String_ &&
|
||||
!$keyType instanceof Integer &&
|
||||
!$keyType instanceof Compound
|
||||
) {
|
||||
throw new RuntimeException(
|
||||
'An array can have only integers or strings as keys'
|
||||
);
|
||||
}
|
||||
|
||||
if ($keyType instanceof Compound) {
|
||||
foreach ($keyType->getIterator() as $item) {
|
||||
if (
|
||||
!$item instanceof ArrayKey &&
|
||||
!$item instanceof String_ &&
|
||||
!$item instanceof Integer
|
||||
) {
|
||||
throw new RuntimeException(
|
||||
'An array can have only integers or strings as keys'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$continue = true;
|
||||
while ($continue) {
|
||||
$continue = false;
|
||||
while ($tokenIterator->tryConsumeTokenType(Lexer::TOKEN_UNION)) {
|
||||
$ast = $this->parse($tokenIterator);
|
||||
$type2 = $this->createType($ast, $context);
|
||||
$type = new Compound([$type, $type2]);
|
||||
$continue = true;
|
||||
}
|
||||
|
||||
$tokens->next();
|
||||
// now let's parse the value type
|
||||
$valueType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION);
|
||||
}
|
||||
|
||||
$token = $tokens->current();
|
||||
if ($token !== '>') {
|
||||
if (empty($token)) {
|
||||
throw new RuntimeException(
|
||||
'Collection: ">" is missing'
|
||||
);
|
||||
while ($tokenIterator->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION)) {
|
||||
$ast = $this->typeParser->parse($tokenIterator);
|
||||
$type2 = $this->createType($ast, $context);
|
||||
$type = new Intersection([$type, $type2]);
|
||||
$continue = true;
|
||||
}
|
||||
|
||||
throw new RuntimeException(
|
||||
'Unexpected character "' . $token . '", ">" is missing'
|
||||
);
|
||||
}
|
||||
|
||||
if ($isArray) {
|
||||
return new Array_($valueType, $keyType);
|
||||
}
|
||||
|
||||
if ($isIterable) {
|
||||
return new Iterable_($valueType, $keyType);
|
||||
}
|
||||
|
||||
if ($isList) {
|
||||
return new List_($valueType);
|
||||
}
|
||||
|
||||
if ($classType instanceof Object_) {
|
||||
return $this->makeCollectionFromObject($classType, $valueType, $keyType);
|
||||
}
|
||||
|
||||
throw new RuntimeException('Invalid $classType provided');
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
private function makeCollectionFromObject(Object_ $object, Type $valueType, ?Type $keyType = null): Collection
|
||||
{
|
||||
return new Collection($object->getFqsen(), $valueType, $keyType);
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
@@ -34,9 +34,10 @@ abstract class AggregatedType implements Type, IteratorAggregate
|
||||
* @psalm-allow-private-mutation
|
||||
* @var array<int, Type>
|
||||
*/
|
||||
private array $types = [];
|
||||
private $types = [];
|
||||
|
||||
private string $token;
|
||||
/** @var string */
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* @param array<Type> $types
|
||||
@@ -106,7 +107,7 @@ abstract class AggregatedType implements Type, IteratorAggregate
|
||||
*/
|
||||
private function add(Type $type): void
|
||||
{
|
||||
if ($type instanceof self) {
|
||||
if ($type instanceof static) {
|
||||
foreach ($type->getIterator() as $subType) {
|
||||
$this->add($subType);
|
||||
}
|
||||
|
77
vendor/phpdocumentor/type-resolver/src/Types/CallableParameter.php
vendored
Normal file
77
vendor/phpdocumentor/type-resolver/src/Types/CallableParameter.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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\Types;
|
||||
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Value Object representing a Callable parameters.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class CallableParameter
|
||||
{
|
||||
/** @var Type */
|
||||
private $type;
|
||||
|
||||
/** @var bool */
|
||||
private $isReference;
|
||||
|
||||
/** @var bool */
|
||||
private $isVariadic;
|
||||
|
||||
/** @var bool */
|
||||
private $isOptional;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
public function __construct(
|
||||
Type $type,
|
||||
?string $name = null,
|
||||
bool $isReference = false,
|
||||
bool $isVariadic = false,
|
||||
bool $isOptional = false
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->isReference = $isReference;
|
||||
$this->isVariadic = $isVariadic;
|
||||
$this->isOptional = $isOptional;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
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 isOptional(): bool
|
||||
{
|
||||
return $this->isOptional;
|
||||
}
|
||||
}
|
@@ -22,6 +22,31 @@ use phpDocumentor\Reflection\Type;
|
||||
*/
|
||||
final class Callable_ implements Type
|
||||
{
|
||||
/** @var Type|null */
|
||||
private $returnType;
|
||||
/** @var CallableParameter[] */
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* @param CallableParameter[] $parameters
|
||||
*/
|
||||
public function __construct(array $parameters = [], ?Type $returnType = null)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
$this->returnType = $returnType;
|
||||
}
|
||||
|
||||
/** @return CallableParameter[] */
|
||||
public function getParameters(): array
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function getReturnType(): ?Type
|
||||
{
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
*/
|
||||
|
@@ -24,7 +24,8 @@ use phpDocumentor\Reflection\Type;
|
||||
*/
|
||||
final class ClassString extends String_ implements PseudoType
|
||||
{
|
||||
private ?Fqsen $fqsen;
|
||||
/** @var Fqsen|null */
|
||||
private $fqsen;
|
||||
|
||||
/**
|
||||
* Initializes this representation of a class string with the given Fqsen.
|
||||
|
@@ -31,7 +31,8 @@ use phpDocumentor\Reflection\Type;
|
||||
*/
|
||||
final class Collection extends AbstractList
|
||||
{
|
||||
private ?Fqsen $fqsen;
|
||||
/** @var Fqsen|null */
|
||||
private $fqsen;
|
||||
|
||||
/**
|
||||
* Initializes this representation of an array with the given Type or Fqsen.
|
||||
|
@@ -36,13 +36,13 @@ use function trim;
|
||||
final class Context
|
||||
{
|
||||
/** @var string The current namespace. */
|
||||
private string $namespace;
|
||||
private $namespace;
|
||||
|
||||
/**
|
||||
* @var string[] List of namespace aliases => Fully Qualified Namespace.
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private array $namespaceAliases;
|
||||
private $namespaceAliases;
|
||||
|
||||
/**
|
||||
* Initializes the new context and normalizes all passed namespaces to be in Qualified Namespace Name (QNN)
|
||||
|
@@ -45,14 +45,15 @@ use const T_NAME_QUALIFIED;
|
||||
use const T_NAMESPACE;
|
||||
use const T_NS_SEPARATOR;
|
||||
use const T_STRING;
|
||||
use const T_TRAIT;
|
||||
use const T_USE;
|
||||
|
||||
if (!defined('T_NAME_QUALIFIED')) {
|
||||
define('T_NAME_QUALIFIED', 'T_NAME_QUALIFIED');
|
||||
define('T_NAME_QUALIFIED', 10001);
|
||||
}
|
||||
|
||||
if (!defined('T_NAME_FULLY_QUALIFIED')) {
|
||||
define('T_NAME_FULLY_QUALIFIED', 'T_NAME_FULLY_QUALIFIED');
|
||||
define('T_NAME_FULLY_QUALIFIED', 10002);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +182,7 @@ final class ContextFactory
|
||||
$currentNamespace = $this->parseNamespace($tokens);
|
||||
break;
|
||||
case T_CLASS:
|
||||
case T_TRAIT:
|
||||
// Fast-forward the iterator through the class so that any
|
||||
// T_USE tokens found within are skipped - these are not
|
||||
// valid namespace use statements so should be ignored.
|
||||
|
@@ -22,7 +22,8 @@ use phpDocumentor\Reflection\Type;
|
||||
*/
|
||||
final class Expression implements Type
|
||||
{
|
||||
protected Type $valueType;
|
||||
/** @var Type */
|
||||
protected $valueType;
|
||||
|
||||
/**
|
||||
* Initializes this representation of an array with the given Type.
|
||||
|
@@ -20,7 +20,7 @@ use phpDocumentor\Reflection\Type;
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Float_ implements Type
|
||||
class Float_ implements Type
|
||||
{
|
||||
/**
|
||||
* Returns a rendered output of the Type as it would be used in a DocBlock.
|
||||
|
@@ -23,7 +23,8 @@ use phpDocumentor\Reflection\Type;
|
||||
*/
|
||||
final class InterfaceString implements Type
|
||||
{
|
||||
private ?Fqsen $fqsen;
|
||||
/** @var Fqsen|null */
|
||||
private $fqsen;
|
||||
|
||||
/**
|
||||
* Initializes this representation of a class string with the given Fqsen.
|
||||
|
@@ -23,7 +23,7 @@ use phpDocumentor\Reflection\Type;
|
||||
final class Nullable implements Type
|
||||
{
|
||||
/** @var Type The actual type that is wrapped */
|
||||
private Type $realType;
|
||||
private $realType;
|
||||
|
||||
/**
|
||||
* Initialises this nullable type using the real type embedded
|
||||
|
@@ -30,7 +30,8 @@ use function strpos;
|
||||
*/
|
||||
final class Object_ implements Type
|
||||
{
|
||||
private ?Fqsen $fqsen;
|
||||
/** @var Fqsen|null */
|
||||
private $fqsen;
|
||||
|
||||
/**
|
||||
* Initializes this object with an optional FQSEN, if not provided this object is considered 'untyped'.
|
||||
|
Reference in New Issue
Block a user