dep: package update
This commit is contained in:
+35
-11
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class DocBlock
|
||||
@@ -68,12 +69,12 @@ final class DocBlock
|
||||
$this->isTemplateStart = $isTemplateStart;
|
||||
}
|
||||
|
||||
public function getSummary() : string
|
||||
public function getSummary(): string
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
||||
public function getDescription() : DocBlock\Description
|
||||
public function getDescription(): DocBlock\Description
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
@@ -81,7 +82,7 @@ final class DocBlock
|
||||
/**
|
||||
* Returns the current context.
|
||||
*/
|
||||
public function getContext() : ?Types\Context
|
||||
public function getContext(): ?Types\Context
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
@@ -89,7 +90,7 @@ final class DocBlock
|
||||
/**
|
||||
* Returns the current location.
|
||||
*/
|
||||
public function getLocation() : ?Location
|
||||
public function getLocation(): ?Location
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
@@ -113,7 +114,7 @@ final class DocBlock
|
||||
*
|
||||
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
|
||||
*/
|
||||
public function isTemplateStart() : bool
|
||||
public function isTemplateStart(): bool
|
||||
{
|
||||
return $this->isTemplateStart;
|
||||
}
|
||||
@@ -123,7 +124,7 @@ final class DocBlock
|
||||
*
|
||||
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
|
||||
*/
|
||||
public function isTemplateEnd() : bool
|
||||
public function isTemplateEnd(): bool
|
||||
{
|
||||
return $this->isTemplateEnd;
|
||||
}
|
||||
@@ -133,7 +134,7 @@ final class DocBlock
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTags() : array
|
||||
public function getTags(): array
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
@@ -146,7 +147,7 @@ final class DocBlock
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTagsByName(string $name) : array
|
||||
public function getTagsByName(string $name): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@@ -161,12 +162,35 @@ final class DocBlock
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of tags with type matching the given name. If no tags are found
|
||||
* an empty array is returned.
|
||||
*
|
||||
* @param string $name String to search by.
|
||||
*
|
||||
* @return TagWithType[]
|
||||
*/
|
||||
public function getTagsWithTypeByName(string $name): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($this->getTagsByName($name) as $tag) {
|
||||
if (!$tag instanceof TagWithType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $tag;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tag of a certain type is present in this DocBlock.
|
||||
*
|
||||
* @param string $name Tag name to check for.
|
||||
*/
|
||||
public function hasTag(string $name) : bool
|
||||
public function hasTag(string $name): bool
|
||||
{
|
||||
foreach ($this->getTags() as $tag) {
|
||||
if ($tag->getName() === $name) {
|
||||
@@ -182,7 +206,7 @@ final class DocBlock
|
||||
*
|
||||
* @param Tag $tagToRemove The tag to remove.
|
||||
*/
|
||||
public function removeTag(Tag $tagToRemove) : void
|
||||
public function removeTag(Tag $tagToRemove): void
|
||||
{
|
||||
foreach ($this->tags as $key => $tag) {
|
||||
if ($tag === $tagToRemove) {
|
||||
@@ -197,7 +221,7 @@ final class DocBlock
|
||||
*
|
||||
* @param Tag $tag The tag to add.
|
||||
*/
|
||||
private function addTag(Tag $tag) : void
|
||||
private function addTag(Tag $tag): void
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
|
||||
use function vsprintf;
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ class Description
|
||||
/**
|
||||
* Returns the body template.
|
||||
*/
|
||||
public function getBodyTemplate() : string
|
||||
public function getBodyTemplate(): string
|
||||
{
|
||||
return $this->bodyTemplate;
|
||||
}
|
||||
@@ -81,7 +82,7 @@ class Description
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTags() : array
|
||||
public function getTags(): array
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ class Description
|
||||
* Renders this description as a string where the provided formatter will format the tags in the expected string
|
||||
* format.
|
||||
*/
|
||||
public function render(?Formatter $formatter = null) : string
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new PassthroughFormatter();
|
||||
@@ -107,7 +108,7 @@ class Description
|
||||
/**
|
||||
* Returns a plain string representation of this description.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
+6
-5
@@ -15,8 +15,8 @@ namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
|
||||
use function count;
|
||||
use function explode;
|
||||
use function implode;
|
||||
use function ltrim;
|
||||
use function min;
|
||||
@@ -25,6 +25,7 @@ use function strlen;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
use function trim;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ class DescriptionFactory
|
||||
/**
|
||||
* Returns the parsed text of this description.
|
||||
*/
|
||||
public function create(string $contents, ?TypeContext $context = null) : Description
|
||||
public function create(string $contents, ?TypeContext $context = null): Description
|
||||
{
|
||||
$tokens = $this->lex($contents);
|
||||
$count = count($tokens);
|
||||
@@ -88,7 +89,7 @@ class DescriptionFactory
|
||||
*
|
||||
* @return string[] A series of tokens of which the description text is composed.
|
||||
*/
|
||||
private function lex(string $contents) : array
|
||||
private function lex(string $contents): array
|
||||
{
|
||||
$contents = $this->removeSuperfluousStartingWhitespace($contents);
|
||||
|
||||
@@ -142,9 +143,9 @@ class DescriptionFactory
|
||||
* If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent
|
||||
* lines and this may cause rendering issues when, for example, using a Markdown converter.
|
||||
*/
|
||||
private function removeSuperfluousStartingWhitespace(string $contents) : string
|
||||
private function removeSuperfluousStartingWhitespace(string $contents): string
|
||||
{
|
||||
$lines = explode("\n", $contents);
|
||||
$lines = Utils::pregSplit("/\r\n?|\n/", $contents);
|
||||
|
||||
// if there is only one line then we don't have lines with superfluous whitespace and
|
||||
// can use the contents as-is
|
||||
|
||||
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Example;
|
||||
|
||||
use function array_slice;
|
||||
use function file;
|
||||
use function getcwd;
|
||||
@@ -22,6 +23,7 @@ use function is_readable;
|
||||
use function rtrim;
|
||||
use function sprintf;
|
||||
use function trim;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
@@ -38,7 +40,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Attempts to find the example contents for the given descriptor.
|
||||
*/
|
||||
public function find(Example $example) : string
|
||||
public function find(Example $example): string
|
||||
{
|
||||
$filename = $example->getFilePath();
|
||||
|
||||
@@ -53,7 +55,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Registers the project's root directory where an 'examples' folder can be expected.
|
||||
*/
|
||||
public function setSourceDirectory(string $directory = '') : void
|
||||
public function setSourceDirectory(string $directory = ''): void
|
||||
{
|
||||
$this->sourceDirectory = $directory;
|
||||
}
|
||||
@@ -61,7 +63,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Returns the project's root directory where an 'examples' folder can be expected.
|
||||
*/
|
||||
public function getSourceDirectory() : string
|
||||
public function getSourceDirectory(): string
|
||||
{
|
||||
return $this->sourceDirectory;
|
||||
}
|
||||
@@ -71,7 +73,7 @@ class ExampleFinder
|
||||
*
|
||||
* @param string[] $directories
|
||||
*/
|
||||
public function setExampleDirectories(array $directories) : void
|
||||
public function setExampleDirectories(array $directories): void
|
||||
{
|
||||
$this->exampleDirectories = $directories;
|
||||
}
|
||||
@@ -81,7 +83,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getExampleDirectories() : array
|
||||
public function getExampleDirectories(): array
|
||||
{
|
||||
return $this->exampleDirectories;
|
||||
}
|
||||
@@ -99,7 +101,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string[] all lines of the example file
|
||||
*/
|
||||
private function getExampleFileContents(string $filename) : ?array
|
||||
private function getExampleFileContents(string $filename): ?array
|
||||
{
|
||||
$normalizedPath = null;
|
||||
|
||||
@@ -129,7 +131,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Get example filepath based on the example directory inside your project.
|
||||
*/
|
||||
private function getExamplePathFromExampleDirectory(string $file) : string
|
||||
private function getExamplePathFromExampleDirectory(string $file): string
|
||||
{
|
||||
return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
@@ -137,7 +139,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Returns a path to the example file in the given directory..
|
||||
*/
|
||||
private function constructExamplePath(string $directory, string $file) : string
|
||||
private function constructExamplePath(string $directory, string $file): string
|
||||
{
|
||||
return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
@@ -145,7 +147,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Get example filepath based on sourcecode.
|
||||
*/
|
||||
private function getExamplePathFromSource(string $file) : string
|
||||
private function getExamplePathFromSource(string $file): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s%s%s',
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
|
||||
|
||||
use function sprintf;
|
||||
use function str_repeat;
|
||||
use function str_replace;
|
||||
@@ -41,6 +42,8 @@ class Serializer
|
||||
|
||||
/** @var Formatter A custom tag formatter. */
|
||||
protected $tagFormatter;
|
||||
/** @var string */
|
||||
private $lineEnding;
|
||||
|
||||
/**
|
||||
* Create a Serializer instance.
|
||||
@@ -50,19 +53,22 @@ class Serializer
|
||||
* @param bool $indentFirstLine Whether to indent the first line.
|
||||
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
|
||||
* @param Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
|
||||
* @param string $lineEnding Line ending used in the output, by default \n is used.
|
||||
*/
|
||||
public function __construct(
|
||||
int $indent = 0,
|
||||
string $indentString = ' ',
|
||||
bool $indentFirstLine = true,
|
||||
?int $lineLength = null,
|
||||
?Formatter $tagFormatter = null
|
||||
?Formatter $tagFormatter = null,
|
||||
string $lineEnding = "\n"
|
||||
) {
|
||||
$this->indent = $indent;
|
||||
$this->indentString = $indentString;
|
||||
$this->isFirstLineIndented = $indentFirstLine;
|
||||
$this->lineLength = $lineLength;
|
||||
$this->tagFormatter = $tagFormatter ?: new PassthroughFormatter();
|
||||
$this->lineEnding = $lineEnding;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +78,7 @@ class Serializer
|
||||
*
|
||||
* @return string The serialized doc block.
|
||||
*/
|
||||
public function getDocComment(DocBlock $docblock) : string
|
||||
public function getDocComment(DocBlock $docblock): string
|
||||
{
|
||||
$indent = str_repeat($this->indentString, $this->indent);
|
||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||
@@ -95,10 +101,10 @@ class Serializer
|
||||
|
||||
$comment = $this->addTagBlock($docblock, $wrapLength, $indent, $comment);
|
||||
|
||||
return $comment . $indent . ' */';
|
||||
return str_replace("\n", $this->lineEnding, $comment . $indent . ' */');
|
||||
}
|
||||
|
||||
private function removeTrailingSpaces(string $indent, string $text) : string
|
||||
private function removeTrailingSpaces(string $indent, string $text): string
|
||||
{
|
||||
return str_replace(
|
||||
sprintf("\n%s * \n", $indent),
|
||||
@@ -107,7 +113,7 @@ class Serializer
|
||||
);
|
||||
}
|
||||
|
||||
private function addAsterisksForEachLine(string $indent, string $text) : string
|
||||
private function addAsterisksForEachLine(string $indent, string $text): string
|
||||
{
|
||||
return str_replace(
|
||||
"\n",
|
||||
@@ -116,7 +122,7 @@ class Serializer
|
||||
);
|
||||
}
|
||||
|
||||
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength) : string
|
||||
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength): string
|
||||
{
|
||||
$text = $docblock->getSummary() . ((string) $docblock->getDescription() ? "\n\n" . $docblock->getDescription()
|
||||
: '');
|
||||
@@ -129,7 +135,7 @@ class Serializer
|
||||
return $text;
|
||||
}
|
||||
|
||||
private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment) : string
|
||||
private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment): string
|
||||
{
|
||||
foreach ($docblock->getTags() as $tag) {
|
||||
$tagText = $this->tagFormatter->format($tag);
|
||||
|
||||
+12
-11
@@ -39,6 +39,7 @@ use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_merge;
|
||||
use function array_slice;
|
||||
use function call_user_func_array;
|
||||
@@ -137,7 +138,7 @@ final class StandardTagFactory implements TagFactory
|
||||
$this->addService($fqsenResolver, FqsenResolver::class);
|
||||
}
|
||||
|
||||
public function create(string $tagLine, ?TypeContext $context = null) : Tag
|
||||
public function create(string $tagLine, ?TypeContext $context = null): Tag
|
||||
{
|
||||
if (!$context) {
|
||||
$context = new TypeContext('');
|
||||
@@ -151,17 +152,17 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function addParameter(string $name, $value) : void
|
||||
public function addParameter(string $name, $value): void
|
||||
{
|
||||
$this->serviceLocator[$name] = $value;
|
||||
}
|
||||
|
||||
public function addService(object $service, ?string $alias = null) : void
|
||||
public function addService(object $service, ?string $alias = null): void
|
||||
{
|
||||
$this->serviceLocator[$alias ?: get_class($service)] = $service;
|
||||
}
|
||||
|
||||
public function registerTagHandler(string $tagName, string $handler) : void
|
||||
public function registerTagHandler(string $tagName, string $handler): void
|
||||
{
|
||||
Assert::stringNotEmpty($tagName);
|
||||
Assert::classExists($handler);
|
||||
@@ -181,7 +182,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function extractTagParts(string $tagLine) : array
|
||||
private function extractTagParts(string $tagLine): array
|
||||
{
|
||||
$matches = [];
|
||||
if (!preg_match('/^@(' . self::REGEX_TAGNAME . ')((?:[\s\(\{])\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||
@@ -201,7 +202,7 @@ final class StandardTagFactory implements TagFactory
|
||||
* Creates a new tag object with the given name and body or returns null if the tag name was recognized but the
|
||||
* body was invalid.
|
||||
*/
|
||||
private function createTag(string $body, string $name, TypeContext $context) : Tag
|
||||
private function createTag(string $body, string $name, TypeContext $context): Tag
|
||||
{
|
||||
$handlerClassName = $this->findHandlerClassName($name, $context);
|
||||
$arguments = $this->getArgumentsForParametersFromWiring(
|
||||
@@ -226,7 +227,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return class-string<Tag>
|
||||
*/
|
||||
private function findHandlerClassName(string $tagName, TypeContext $context) : string
|
||||
private function findHandlerClassName(string $tagName, TypeContext $context): string
|
||||
{
|
||||
$handlerClassName = Generic::class;
|
||||
if (isset($this->tagHandlerMappings[$tagName])) {
|
||||
@@ -251,7 +252,7 @@ final class StandardTagFactory implements TagFactory
|
||||
* @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters
|
||||
* is provided with this method.
|
||||
*/
|
||||
private function getArgumentsForParametersFromWiring(array $parameters, array $locator) : array
|
||||
private function getArgumentsForParametersFromWiring(array $parameters, array $locator): array
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($parameters as $parameter) {
|
||||
@@ -292,7 +293,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return ReflectionParameter[]
|
||||
*/
|
||||
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName) : array
|
||||
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
|
||||
{
|
||||
if (!isset($this->tagHandlerParameterCache[$handlerClassName])) {
|
||||
$methodReflection = new ReflectionMethod($handlerClassName, 'create');
|
||||
@@ -319,7 +320,7 @@ final class StandardTagFactory implements TagFactory
|
||||
TypeContext $context,
|
||||
string $tagName,
|
||||
string $tagBody
|
||||
) : array {
|
||||
): array {
|
||||
return array_merge(
|
||||
$this->serviceLocator,
|
||||
[
|
||||
@@ -335,7 +336,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @todo this method should be populated once we implement Annotation notation support.
|
||||
*/
|
||||
private function isAnnotation(string $tagContent) : bool
|
||||
private function isAnnotation(string $tagContent): bool
|
||||
{
|
||||
// 1. Contains a namespace separator
|
||||
// 2. Contains parenthesis
|
||||
|
||||
@@ -17,16 +17,15 @@ use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
interface Tag
|
||||
{
|
||||
public function getName() : string;
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* @return Tag|mixed Class that implements Tag
|
||||
*
|
||||
* @phpstan-return ?Tag
|
||||
*/
|
||||
public static function create(string $body);
|
||||
|
||||
public function render(?Formatter $formatter = null) : string;
|
||||
public function render(?Formatter $formatter = null): string;
|
||||
|
||||
public function __toString() : string;
|
||||
public function __toString(): string;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ interface TagFactory
|
||||
*
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function addParameter(string $name, $value) : void;
|
||||
public function addParameter(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* Factory method responsible for instantiating the correct sub type.
|
||||
@@ -49,7 +49,7 @@ interface TagFactory
|
||||
*
|
||||
* @throws InvalidArgumentException If an invalid tag line was presented.
|
||||
*/
|
||||
public function create(string $tagLine, ?TypeContext $context = null) : Tag;
|
||||
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.
|
||||
@@ -60,7 +60,7 @@ interface TagFactory
|
||||
* Because interfaces are regularly used as type-hints this method provides an alias parameter; if the FQCN of the
|
||||
* interface is passed as alias then every time that interface is requested the provided service will be returned.
|
||||
*/
|
||||
public function addService(object $service) : void;
|
||||
public function addService(object $service): void;
|
||||
|
||||
/**
|
||||
* Registers a handler for tags.
|
||||
@@ -80,5 +80,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, string $handler): void;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function filter_var;
|
||||
use function preg_match;
|
||||
use function trim;
|
||||
|
||||
use const FILTER_VALIDATE_EMAIL;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string The author's name.
|
||||
*/
|
||||
public function getAuthorName() : string
|
||||
public function getAuthorName(): string
|
||||
{
|
||||
return $this->authorName;
|
||||
}
|
||||
@@ -61,7 +63,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string The author's email.
|
||||
*/
|
||||
public function getEmail() : string
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->authorEmail;
|
||||
}
|
||||
@@ -69,7 +71,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns this tag in string form.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->authorEmail) {
|
||||
$authorEmail = '<' . $this->authorEmail . '>';
|
||||
@@ -77,15 +79,15 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
$authorEmail = '';
|
||||
}
|
||||
|
||||
$authorName = (string) $this->authorName;
|
||||
$authorName = $this->authorName;
|
||||
|
||||
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to create a new Author object based on †he tag body.
|
||||
* Attempts to create a new Author object based on the tag body.
|
||||
*/
|
||||
public static function create(string $body) : ?self
|
||||
public static function create(string $body): ?self
|
||||
{
|
||||
$splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches);
|
||||
if (!$splitTagContent) {
|
||||
|
||||
@@ -32,17 +32,17 @@ abstract class BaseTag implements DocBlock\Tag
|
||||
*
|
||||
* @return string The name of this tag.
|
||||
*/
|
||||
public function getName() : string
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDescription() : ?Description
|
||||
public function getDescription(): ?Description
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function render(?Formatter $formatter = null) : string
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new Formatter\PassthroughFormatter();
|
||||
|
||||
@@ -20,6 +20,7 @@ use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function explode;
|
||||
|
||||
@@ -48,7 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?FqsenResolver $resolver = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
Assert::notNull($resolver);
|
||||
@@ -61,7 +62,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
);
|
||||
}
|
||||
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context) : Fqsen
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
|
||||
{
|
||||
Assert::notNull($fqsenResolver);
|
||||
$fqsenParts = explode('::', $parts);
|
||||
@@ -77,7 +78,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the structural element this tag refers to.
|
||||
*/
|
||||
public function getReference() : Fqsen
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -85,7 +86,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation of this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -17,6 +17,7 @@ use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
?string $body,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
}
|
||||
@@ -85,7 +86,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Gets the version section of the tag.
|
||||
*/
|
||||
public function getVersion() : ?string
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function preg_match;
|
||||
use function rawurlencode;
|
||||
@@ -66,7 +67,7 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
$this->isURI = $isURI;
|
||||
}
|
||||
|
||||
public function getContent() : string
|
||||
public function getContent(): string
|
||||
{
|
||||
if ($this->content === null || $this->content === '') {
|
||||
$filePath = $this->filePath;
|
||||
@@ -82,12 +83,12 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function getDescription() : ?string
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public static function create(string $body) : ?Tag
|
||||
public static function create(string $body): ?Tag
|
||||
{
|
||||
// File component: File path in quotes or File URI / Source information
|
||||
if (!preg_match('/^\s*(?:(\"[^\"]+\")|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
|
||||
@@ -137,7 +138,7 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
* @return string Path to a file to use as an example.
|
||||
* May also be an absolute URI.
|
||||
*/
|
||||
public function getFilePath() : string
|
||||
public function getFilePath(): string
|
||||
{
|
||||
return trim($this->filePath, '"');
|
||||
}
|
||||
@@ -145,9 +146,9 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
$filePath = (string) $this->filePath;
|
||||
$filePath = $this->filePath;
|
||||
$isDefaultLine = $this->startingLine === 1 && $this->lineCount === 0;
|
||||
$startingLine = !$isDefaultLine ? (string) $this->startingLine : '';
|
||||
$lineCount = !$isDefaultLine ? (string) $this->lineCount : '';
|
||||
@@ -168,27 +169,27 @@ final class Example implements Tag, Factory\StaticMethod
|
||||
/**
|
||||
* Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute).
|
||||
*/
|
||||
private function isUriRelative(string $uri) : bool
|
||||
private function isUriRelative(string $uri): bool
|
||||
{
|
||||
return strpos($uri, ':') === false;
|
||||
}
|
||||
|
||||
public function getStartingLine() : int
|
||||
public function getStartingLine(): int
|
||||
{
|
||||
return $this->startingLine;
|
||||
}
|
||||
|
||||
public function getLineCount() : int
|
||||
public function getLineCount(): int
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
public function getName(): string
|
||||
{
|
||||
return 'example';
|
||||
}
|
||||
|
||||
public function render(?Formatter $formatter = null) : string
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new Formatter\PassthroughFormatter();
|
||||
|
||||
@@ -20,5 +20,5 @@ interface Formatter
|
||||
/**
|
||||
* Formats a tag into a string representation according to a specific format, such as Markdown.
|
||||
*/
|
||||
public function format(Tag $tag) : string;
|
||||
public function format(Tag $tag): string;
|
||||
}
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
use function max;
|
||||
use function str_repeat;
|
||||
use function strlen;
|
||||
@@ -37,7 +38,7 @@ class AlignFormatter implements Formatter
|
||||
/**
|
||||
* Formats the given tag to return a simple plain text version.
|
||||
*/
|
||||
public function format(Tag $tag) : string
|
||||
public function format(Tag $tag): string
|
||||
{
|
||||
return '@' . $tag->getName() .
|
||||
str_repeat(
|
||||
|
||||
Vendored
+2
-1
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
use function trim;
|
||||
|
||||
class PassthroughFormatter implements Formatter
|
||||
@@ -22,7 +23,7 @@ class PassthroughFormatter implements Formatter
|
||||
/**
|
||||
* Formats the given tag to return a simple plain text version.
|
||||
*/
|
||||
public function format(Tag $tag) : string
|
||||
public function format(Tag $tag): string
|
||||
{
|
||||
return trim('@' . $tag->getName() . ' ' . $tag);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ final class Generic extends BaseTag implements Factory\StaticMethod
|
||||
string $name = '',
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($name);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -62,7 +63,7 @@ final class Generic extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the tag as a serialized string
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
@@ -76,7 +77,7 @@ final class Generic extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Validates if the tag name matches the expected format, otherwise throws an exception.
|
||||
*/
|
||||
private function validateTagName(string $name) : void
|
||||
private function validateTagName(string $name): void
|
||||
{
|
||||
if (!preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) {
|
||||
throw new InvalidArgumentException(
|
||||
|
||||
@@ -11,6 +11,7 @@ use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionFunction;
|
||||
use Throwable;
|
||||
|
||||
use function array_map;
|
||||
use function get_class;
|
||||
use function get_resource_type;
|
||||
@@ -46,22 +47,22 @@ final class InvalidTag implements Tag
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function getException() : ?Throwable
|
||||
public function getException(): ?Throwable
|
||||
{
|
||||
return $this->throwable;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public static function create(string $body, string $name = '') : self
|
||||
public static function create(string $body, string $name = ''): self
|
||||
{
|
||||
return new self($name, $body);
|
||||
}
|
||||
|
||||
public function withError(Throwable $exception) : self
|
||||
public function withError(Throwable $exception): self
|
||||
{
|
||||
$this->flattenExceptionBacktrace($exception);
|
||||
$tag = new self($this->name, $this->body);
|
||||
@@ -76,7 +77,7 @@ final class InvalidTag implements Tag
|
||||
* Not all objects are serializable. So we need to remove them from the
|
||||
* stored exception to be sure that we do not break existing library usage.
|
||||
*/
|
||||
private function flattenExceptionBacktrace(Throwable $exception) : void
|
||||
private function flattenExceptionBacktrace(Throwable $exception): void
|
||||
{
|
||||
$traceProperty = (new ReflectionClass(Exception::class))->getProperty('trace');
|
||||
$traceProperty->setAccessible(true);
|
||||
@@ -85,8 +86,8 @@ final class InvalidTag implements Tag
|
||||
$trace = $exception->getTrace();
|
||||
if (isset($trace[0]['args'])) {
|
||||
$trace = array_map(
|
||||
function (array $call) : array {
|
||||
$call['args'] = array_map([$this, 'flattenArguments'], $call['args']);
|
||||
function (array $call): array {
|
||||
$call['args'] = array_map([$this, 'flattenArguments'], $call['args'] ?? []);
|
||||
|
||||
return $call;
|
||||
},
|
||||
@@ -128,7 +129,7 @@ final class InvalidTag implements Tag
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function render(?Formatter $formatter = null) : string
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new Formatter\PassthroughFormatter();
|
||||
@@ -137,7 +138,7 @@ final class InvalidTag implements Tag
|
||||
return $formatter->format($this);
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
string $body,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
|
||||
@@ -55,7 +55,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Gets the link
|
||||
*/
|
||||
public function getLink() : string
|
||||
public function getLink(): string
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
@@ -71,7 +71,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
$description = '';
|
||||
}
|
||||
|
||||
$link = (string) $this->link;
|
||||
$link = $this->link;
|
||||
|
||||
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
use phpDocumentor\Reflection\Types\Void_;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_keys;
|
||||
use function explode;
|
||||
use function implode;
|
||||
@@ -58,7 +59,6 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, Type|string>> $arguments
|
||||
*
|
||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -86,7 +86,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : ?self {
|
||||
): ?self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -100,8 +100,9 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
// 5. 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
|
||||
if (!preg_match(
|
||||
'/^
|
||||
if (
|
||||
!preg_match(
|
||||
'/^
|
||||
# Static keyword
|
||||
# Declares a static method ONLY if type is also present
|
||||
(?:
|
||||
@@ -131,9 +132,10 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
# Description
|
||||
(.*)
|
||||
$/sux',
|
||||
$body,
|
||||
$matches
|
||||
)) {
|
||||
$body,
|
||||
$matches
|
||||
)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -176,17 +178,16 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Retrieves the method name.
|
||||
*/
|
||||
public function getMethodName() : string
|
||||
public function getMethodName(): string
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<string, Type|string>>
|
||||
*
|
||||
* @phpstan-return array<int, array{name: string, type: Type}>
|
||||
*/
|
||||
public function getArguments() : array
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
@@ -196,17 +197,17 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return bool TRUE if the method declaration is for a static method, FALSE otherwise.
|
||||
*/
|
||||
public function isStatic() : bool
|
||||
public function isStatic(): bool
|
||||
{
|
||||
return $this->isStatic;
|
||||
}
|
||||
|
||||
public function getReturnType() : Type
|
||||
public function getReturnType(): Type
|
||||
{
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($this->arguments as $argument) {
|
||||
@@ -225,7 +226,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
$returnType = (string) $this->returnType;
|
||||
|
||||
$methodName = (string) $this->methodName;
|
||||
$methodName = $this->methodName;
|
||||
|
||||
return $static
|
||||
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')
|
||||
@@ -236,13 +237,12 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
/**
|
||||
* @param mixed[][]|string[] $arguments
|
||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||
*
|
||||
* @return mixed[][]
|
||||
*
|
||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||
* @phpstan-return array<int, array{name: string, type: Type}>
|
||||
*/
|
||||
private function filterArguments(array $arguments = []) : array
|
||||
private function filterArguments(array $arguments = []): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($arguments as $argument) {
|
||||
@@ -268,7 +268,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function stripRestArg(string $argument) : string
|
||||
private static function stripRestArg(string $argument): string
|
||||
{
|
||||
if (strpos($argument, '...') === 0) {
|
||||
$argument = trim(substr($argument, 3));
|
||||
|
||||
@@ -20,11 +20,13 @@ use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function array_unshift;
|
||||
use function implode;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -61,7 +63,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -114,7 +116,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*/
|
||||
public function getVariableName() : ?string
|
||||
public function getVariableName(): ?string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -122,7 +124,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns whether this tag is variadic.
|
||||
*/
|
||||
public function isVariadic() : bool
|
||||
public function isVariadic(): bool
|
||||
{
|
||||
return $this->isVariadic;
|
||||
}
|
||||
@@ -130,7 +132,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns whether this tag is passed by reference.
|
||||
*/
|
||||
public function isReference() : bool
|
||||
public function isReference(): bool
|
||||
{
|
||||
return $this->isReference;
|
||||
}
|
||||
@@ -138,7 +140,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
@@ -159,7 +161,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||
}
|
||||
|
||||
private static function strStartsWithVariable(string $str) : bool
|
||||
private static function strStartsWithVariable(string $str): bool
|
||||
{
|
||||
return strpos($str, '$') === 0
|
||||
||
|
||||
|
||||
@@ -20,11 +20,13 @@ use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function array_unshift;
|
||||
use function implode;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -88,7 +90,7 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*/
|
||||
public function getVariableName() : ?string
|
||||
public function getVariableName(): ?string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -96,7 +98,7 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
+5
-3
@@ -20,11 +20,13 @@ use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function array_unshift;
|
||||
use function implode;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -88,7 +90,7 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*/
|
||||
public function getVariableName() : ?string
|
||||
public function getVariableName(): ?string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -96,7 +98,7 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
+5
-3
@@ -20,11 +20,13 @@ use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function array_unshift;
|
||||
use function implode;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -88,7 +90,7 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*/
|
||||
public function getVariableName() : ?string
|
||||
public function getVariableName(): ?string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -96,7 +98,7 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ final class Fqsen implements Reference
|
||||
/**
|
||||
* @return string string representation of the referenced fqsen
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) $this->fqsen;
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,5 +18,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
|
||||
*/
|
||||
interface Reference
|
||||
{
|
||||
public function __toString() : string;
|
||||
public function __toString(): string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ final class Url implements Reference
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -49,7 +49,7 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
return new static($type, $description);
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
@@ -59,6 +59,6 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
|
||||
$type = $this->type ? '' . $this->type : 'mixed';
|
||||
|
||||
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
|
||||
return $type . ($description !== '' ? ' ' . $description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function explode;
|
||||
use function preg_match;
|
||||
@@ -52,21 +53,21 @@ final class See extends BaseTag implements Factory\StaticMethod
|
||||
?FqsenResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
$parts = Utils::pregSplit('/\s+/Su', $body, 2);
|
||||
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
|
||||
|
||||
// https://tools.ietf.org/html/rfc2396#section-3
|
||||
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
|
||||
if (preg_match('#\w://\w#', $parts[0])) {
|
||||
return new static(new Url($parts[0]), $description);
|
||||
}
|
||||
|
||||
return new static(new FqsenRef(self::resolveFqsen($parts[0], $typeResolver, $context)), $description);
|
||||
}
|
||||
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context) : Fqsen
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
|
||||
{
|
||||
Assert::notNull($fqsenResolver);
|
||||
$fqsenParts = explode('::', $parts);
|
||||
@@ -82,7 +83,7 @@ final class See extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the ref of this tag.
|
||||
*/
|
||||
public function getReference() : Reference
|
||||
public function getReference(): Reference
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ final class See extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation of this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -17,6 +17,7 @@ use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
@@ -58,7 +59,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
?string $body,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : ?self {
|
||||
): ?self {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
}
|
||||
@@ -79,7 +80,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Gets the version section of the tag.
|
||||
*/
|
||||
public function getVersion() : ?string
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -87,7 +88,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -17,6 +17,7 @@ use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
@@ -51,7 +52,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
string $body,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -69,7 +70,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
$description = $matches[3];
|
||||
}
|
||||
|
||||
return new static($startingLine, $lineCount, $descriptionFactory->create($description??'', $context));
|
||||
return new static($startingLine, $lineCount, $descriptionFactory->create($description ?? '', $context));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
* @return int The starting line, relative to the structural element's
|
||||
* location.
|
||||
*/
|
||||
public function getStartingLine() : int
|
||||
public function getStartingLine(): int
|
||||
{
|
||||
return $this->startingLine;
|
||||
}
|
||||
@@ -89,12 +90,12 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
* @return int|null The number of lines, relative to the starting line. NULL
|
||||
* means "to the end".
|
||||
*/
|
||||
public function getLineCount() : ?int
|
||||
public function getLineCount(): ?int
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
@@ -104,14 +105,12 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
$startingLine = (string) $this->startingLine;
|
||||
|
||||
$lineCount = $this->lineCount !== null ? '' . $this->lineCount : '';
|
||||
$lineCount = $this->lineCount !== null ? ' ' . $this->lineCount : '';
|
||||
|
||||
return $startingLine
|
||||
. ($lineCount !== ''
|
||||
? ($startingLine || $startingLine === '0' ? ' ' : '') . $lineCount
|
||||
: '')
|
||||
. $lineCount
|
||||
. ($description !== ''
|
||||
? ($startingLine || $startingLine === '0' || $lineCount !== '' ? ' ' : '') . $description
|
||||
? ' ' . $description
|
||||
: '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
@@ -27,7 +28,7 @@ abstract class TagWithType extends BaseTag
|
||||
/**
|
||||
* Returns the type section of the variable.
|
||||
*/
|
||||
public function getType() : ?Type
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ abstract class TagWithType extends BaseTag
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected static function extractTypeFromBody(string $body) : array
|
||||
protected static function extractTypeFromBody(string $body): array
|
||||
{
|
||||
$type = '';
|
||||
$nestingLevel = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ final class Throws extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -49,7 +49,7 @@ final class Throws extends TagWithType implements Factory\StaticMethod
|
||||
return new static($type, $description);
|
||||
}
|
||||
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -20,6 +20,7 @@ use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function explode;
|
||||
|
||||
@@ -48,7 +49,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
?FqsenResolver $resolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::notNull($resolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -60,7 +61,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
);
|
||||
}
|
||||
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context) : Fqsen
|
||||
private static function resolveFqsen(string $parts, ?FqsenResolver $fqsenResolver, ?TypeContext $context): Fqsen
|
||||
{
|
||||
Assert::notNull($fqsenResolver);
|
||||
$fqsenParts = explode('::', $parts);
|
||||
@@ -76,7 +77,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the structural element this tag refers to.
|
||||
*/
|
||||
public function getReference() : Fqsen
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -84,7 +85,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation of this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -20,11 +20,13 @@ use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\Utils;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function array_unshift;
|
||||
use function implode;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const PREG_SPLIT_DELIM_CAPTURE;
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : self {
|
||||
): self {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -89,7 +91,7 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's name.
|
||||
*/
|
||||
public function getVariableName() : ?string
|
||||
public function getVariableName(): ?string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -97,7 +99,7 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -17,6 +17,7 @@ use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/**
|
||||
@@ -58,7 +59,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
?string $body,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) : ?self {
|
||||
): ?self {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
}
|
||||
@@ -82,7 +83,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Gets the version section of the tag.
|
||||
*/
|
||||
public function getVersion() : ?string
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns a string representation for this tag.
|
||||
*/
|
||||
public function __toString() : string
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -20,6 +20,7 @@ use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_shift;
|
||||
use function count;
|
||||
use function explode;
|
||||
@@ -54,7 +55,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @param array<string, class-string<Tag>> $additionalTags
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []) : self
|
||||
public static function createInstance(array $additionalTags = []): self
|
||||
{
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
@@ -75,7 +76,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
* @param object|string $docblock A string containing the DocBlock to parse or an object supporting the
|
||||
* getDocComment method (such as a ReflectionClass object).
|
||||
*/
|
||||
public function create($docblock, ?Types\Context $context = null, ?Location $location = null) : DocBlock
|
||||
public function create($docblock, ?Types\Context $context = null, ?Location $location = null): DocBlock
|
||||
{
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
@@ -112,7 +113,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
/**
|
||||
* @param class-string<Tag> $handler
|
||||
*/
|
||||
public function registerTagHandler(string $tagName, string $handler) : void
|
||||
public function registerTagHandler(string $tagName, string $handler): void
|
||||
{
|
||||
$this->tagFactory->registerTagHandler($tagName, $handler);
|
||||
}
|
||||
@@ -122,7 +123,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @param string $comment String containing the comment text.
|
||||
*/
|
||||
private function stripDocComment(string $comment) : string
|
||||
private function stripDocComment(string $comment): string
|
||||
{
|
||||
$comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]?(.*)?#u', '$1', $comment);
|
||||
Assert::string($comment);
|
||||
@@ -231,7 +232,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return DocBlock\Tag[]
|
||||
*/
|
||||
private function parseTagBlock(string $tags, Types\Context $context) : array
|
||||
private function parseTagBlock(string $tags, Types\Context $context): array
|
||||
{
|
||||
$tags = $this->filterTagBlock($tags);
|
||||
if ($tags === null) {
|
||||
@@ -250,7 +251,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function splitTagBlockIntoTagLines(string $tags) : array
|
||||
private function splitTagBlockIntoTagLines(string $tags): array
|
||||
{
|
||||
$result = [];
|
||||
foreach (explode("\n", $tags) as $tagLine) {
|
||||
@@ -264,7 +265,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function filterTagBlock(string $tags) : ?string
|
||||
private function filterTagBlock(string $tags): ?string
|
||||
{
|
||||
$tags = trim($tags);
|
||||
if (!$tags) {
|
||||
|
||||
@@ -14,10 +14,10 @@ interface DocBlockFactoryInterface
|
||||
*
|
||||
* @param array<string, class-string<Tag>> $additionalTags
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []) : DocBlockFactory;
|
||||
public static function createInstance(array $additionalTags = []): DocBlockFactory;
|
||||
|
||||
/**
|
||||
* @param string|object $docblock
|
||||
*/
|
||||
public function create($docblock, ?Types\Context $context = null, ?Location $location = null) : DocBlock;
|
||||
public function create($docblock, ?Types\Context $context = null, ?Location $location = null): DocBlock;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use const PREG_BACKTRACK_LIMIT_ERROR;
|
||||
use const PREG_BAD_UTF8_ERROR;
|
||||
use const PREG_BAD_UTF8_OFFSET_ERROR;
|
||||
@@ -15,19 +16,24 @@ use const PREG_RECURSION_LIMIT_ERROR;
|
||||
|
||||
final class PcreException extends InvalidArgumentException
|
||||
{
|
||||
public static function createFromPhpError(int $errorCode) : self
|
||||
public static function createFromPhpError(int $errorCode): self
|
||||
{
|
||||
switch ($errorCode) {
|
||||
case PREG_BACKTRACK_LIMIT_ERROR:
|
||||
return new self('Backtrack limit error');
|
||||
|
||||
case PREG_RECURSION_LIMIT_ERROR:
|
||||
return new self('Recursion limit error');
|
||||
|
||||
case PREG_BAD_UTF8_ERROR:
|
||||
return new self('Bad UTF8 error');
|
||||
|
||||
case PREG_BAD_UTF8_OFFSET_ERROR:
|
||||
return new self('Bad UTF8 offset error');
|
||||
|
||||
case PREG_JIT_STACKLIMIT_ERROR:
|
||||
return new self('Jit stacklimit error');
|
||||
|
||||
case PREG_NO_ERROR:
|
||||
case PREG_INTERNAL_ERROR:
|
||||
default:
|
||||
|
||||
+8
-3
@@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\Exception\PcreException;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function preg_last_error;
|
||||
use function preg_split as php_preg_split;
|
||||
|
||||
@@ -28,7 +30,7 @@ abstract class Utils
|
||||
*
|
||||
* @param string $pattern The pattern to search for, as a string.
|
||||
* @param string $subject The input string.
|
||||
* @param int|null $limit If specified, then only substrings up to limit are returned with the
|
||||
* @param int $limit If specified, then only substrings up to limit are returned with the
|
||||
* rest of the string being placed in the last substring. A limit of -1 or 0 means "no limit".
|
||||
* @param int $flags flags can be any combination of the following flags (combined with the | bitwise operator):
|
||||
* *PREG_SPLIT_NO_EMPTY*
|
||||
@@ -41,17 +43,20 @@ abstract class Utils
|
||||
* Note that this changes the return value in an array where every element is an array consisting of the
|
||||
* matched string at offset 0 and its string offset into subject at offset 1.
|
||||
*
|
||||
* @return string[] Returns an array containing substrings of subject split along boundaries matched by pattern
|
||||
* @return string[] Returns an array containing substrings of subject
|
||||
* split along boundaries matched by pattern
|
||||
*
|
||||
* @throws PcreException
|
||||
*/
|
||||
public static function pregSplit(string $pattern, string $subject, ?int $limit = -1, int $flags = 0) : array
|
||||
public static function pregSplit(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
|
||||
{
|
||||
$parts = php_preg_split($pattern, $subject, $limit, $flags);
|
||||
if ($parts === false) {
|
||||
throw PcreException::createFromPhpError(preg_last_error());
|
||||
}
|
||||
|
||||
Assert::allString($parts);
|
||||
|
||||
return $parts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user