mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
add strict_types and typehints
This commit is contained in:
committed by
Jaap van Otterdijk
parent
94fd000123
commit
d874c4d14a
+13
-15
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -40,7 +41,6 @@ final class DocBlock
|
||||
|
||||
/**
|
||||
* @param string $summary
|
||||
* @param DocBlock\Description $description
|
||||
* @param DocBlock\Tag[] $tags
|
||||
* @param Types\Context $context The context in which the DocBlock occurs.
|
||||
* @param Location $location The location within the file that this DocBlock occurs in.
|
||||
@@ -48,13 +48,13 @@ final class DocBlock
|
||||
* @param bool $isTemplateEnd
|
||||
*/
|
||||
public function __construct(
|
||||
$summary = '',
|
||||
string $summary = '',
|
||||
DocBlock\Description $description = null,
|
||||
array $tags = [],
|
||||
Types\Context $context = null,
|
||||
Location $location = null,
|
||||
$isTemplateStart = false,
|
||||
$isTemplateEnd = false
|
||||
bool $isTemplateStart = false,
|
||||
bool $isTemplateEnd = false
|
||||
) {
|
||||
Assert::string($summary);
|
||||
Assert::boolean($isTemplateStart);
|
||||
@@ -77,7 +77,7 @@ final class DocBlock
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSummary()
|
||||
public function getSummary(): string
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ final class DocBlock
|
||||
/**
|
||||
* @return DocBlock\Description
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): DocBlock\Description
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ final class DocBlock
|
||||
*
|
||||
* @return Types\Context
|
||||
*/
|
||||
public function getContext()
|
||||
public function getContext(): Types\Context
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ final class DocBlock
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public function getLocation()
|
||||
public function getLocation(): Location
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ final class DocBlock
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateStart()
|
||||
public function isTemplateStart(): bool
|
||||
{
|
||||
return $this->isTemplateStart;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ final class DocBlock
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplateEnd()
|
||||
public function isTemplateEnd(): bool
|
||||
{
|
||||
return $this->isTemplateEnd;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ final class DocBlock
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTagsByName($name)
|
||||
public function getTagsByName(string $name)
|
||||
{
|
||||
Assert::string($name);
|
||||
|
||||
@@ -191,7 +191,7 @@ final class DocBlock
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTag($name)
|
||||
public function hasTag(string $name): bool
|
||||
{
|
||||
Assert::string($name);
|
||||
|
||||
@@ -210,7 +210,6 @@ final class DocBlock
|
||||
*
|
||||
* @param Tag $tag The tag to remove.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeTag(Tag $tagToRemove)
|
||||
{
|
||||
@@ -227,7 +226,6 @@ final class DocBlock
|
||||
*
|
||||
* @param Tag $tag The tag to add.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function addTag(Tag $tag)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -62,10 +63,8 @@ class Description
|
||||
* @param string $bodyTemplate
|
||||
* @param Tag[] $tags
|
||||
*/
|
||||
public function __construct($bodyTemplate, array $tags = [])
|
||||
public function __construct(string $bodyTemplate, array $tags = [])
|
||||
{
|
||||
Assert::string($bodyTemplate);
|
||||
|
||||
$this->bodyTemplate = $bodyTemplate;
|
||||
$this->tags = $tags;
|
||||
}
|
||||
@@ -84,11 +83,10 @@ class Description
|
||||
* Renders this description as a string where the provided formatter will format the tags in the expected string
|
||||
* format.
|
||||
*
|
||||
* @param Formatter|null $formatter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(Formatter $formatter = null)
|
||||
public function render(Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new PassthroughFormatter();
|
||||
@@ -107,7 +105,7 @@ class Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -39,7 +40,6 @@ class DescriptionFactory
|
||||
/**
|
||||
* Initializes this factory with the means to construct (inline) tags.
|
||||
*
|
||||
* @param TagFactory $tagFactory
|
||||
*/
|
||||
public function __construct(TagFactory $tagFactory)
|
||||
{
|
||||
@@ -50,11 +50,10 @@ class DescriptionFactory
|
||||
* Returns the parsed text of this description.
|
||||
*
|
||||
* @param string $contents
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @return Description
|
||||
*/
|
||||
public function create($contents, TypeContext $context = null)
|
||||
public function create(string $contents, TypeContext $context = null): Description
|
||||
{
|
||||
list($text, $tags) = $this->parse($this->lex($contents), $context);
|
||||
|
||||
@@ -68,7 +67,7 @@ class DescriptionFactory
|
||||
*
|
||||
* @return string[] A series of tokens of which the description text is composed.
|
||||
*/
|
||||
private function lex($contents)
|
||||
private function lex(string $contents)
|
||||
{
|
||||
$contents = $this->removeSuperfluousStartingWhitespace($contents);
|
||||
|
||||
@@ -103,7 +102,7 @@ class DescriptionFactory
|
||||
)
|
||||
\}/Sux',
|
||||
$contents,
|
||||
null,
|
||||
0,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
}
|
||||
@@ -112,7 +111,6 @@ class DescriptionFactory
|
||||
* Parses the stream of tokens in to a new set of tokens containing Tags.
|
||||
*
|
||||
* @param string[] $tokens
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @return string[]|Tag[]
|
||||
*/
|
||||
@@ -156,7 +154,7 @@ class DescriptionFactory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function removeSuperfluousStartingWhitespace($contents)
|
||||
private function removeSuperfluousStartingWhitespace(string $contents): string
|
||||
{
|
||||
$lines = explode("\n", $contents);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -28,11 +29,10 @@ class ExampleFinder
|
||||
/**
|
||||
* Attempts to find the example contents for the given descriptor.
|
||||
*
|
||||
* @param Example $example
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function find(Example $example)
|
||||
public function find(Example $example): string
|
||||
{
|
||||
$filename = $example->getFilePath();
|
||||
|
||||
@@ -49,9 +49,8 @@ class ExampleFinder
|
||||
*
|
||||
* @param string $directory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceDirectory($directory = '')
|
||||
public function setSourceDirectory(string $directory = '')
|
||||
{
|
||||
$this->sourceDirectory = $directory;
|
||||
}
|
||||
@@ -61,7 +60,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSourceDirectory()
|
||||
public function getSourceDirectory(): string
|
||||
{
|
||||
return $this->sourceDirectory;
|
||||
}
|
||||
@@ -101,7 +100,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getExampleFileContents($filename)
|
||||
private function getExampleFileContents(string $filename)
|
||||
{
|
||||
$normalizedPath = null;
|
||||
|
||||
@@ -133,7 +132,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getExamplePathFromExampleDirectory($file)
|
||||
private function getExamplePathFromExampleDirectory(string $file): string
|
||||
{
|
||||
return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
@@ -146,7 +145,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function constructExamplePath($directory, $file)
|
||||
private function constructExamplePath(string $directory, string $file): string
|
||||
{
|
||||
return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
@@ -158,7 +157,7 @@ class ExampleFinder
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getExamplePathFromSource($file)
|
||||
private function getExamplePathFromSource(string $file): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s%s%s',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -44,7 +45,7 @@ class Serializer
|
||||
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
|
||||
* @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter.
|
||||
*/
|
||||
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null, $tagFormatter = null)
|
||||
public function __construct(int $indent = 0, string $indentString = ' ', bool $indentFirstLine = true, int $lineLength = null, DocBlock\Tags\Formatter $tagFormatter = null)
|
||||
{
|
||||
Assert::integer($indent);
|
||||
Assert::string($indentString);
|
||||
@@ -66,7 +67,7 @@ class Serializer
|
||||
*
|
||||
* @return string The serialized doc block.
|
||||
*/
|
||||
public function getDocComment(DocBlock $docblock)
|
||||
public function getDocComment(DocBlock $docblock): string
|
||||
{
|
||||
$indent = str_repeat($this->indentString, $this->indent);
|
||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||
@@ -114,11 +115,10 @@ class Serializer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocBlock $docblock
|
||||
* @param $wrapLength
|
||||
* @return string
|
||||
*/
|
||||
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength)
|
||||
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, $wrapLength): string
|
||||
{
|
||||
$text = $docblock->getSummary() . ((string)$docblock->getDescription() ? "\n\n" . $docblock->getDescription()
|
||||
: '');
|
||||
@@ -131,13 +131,12 @@ class Serializer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocBlock $docblock
|
||||
* @param $wrapLength
|
||||
* @param $indent
|
||||
* @param $comment
|
||||
* @return string
|
||||
*/
|
||||
private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment)
|
||||
private function addTagBlock(DocBlock $docblock, $wrapLength, $indent, $comment): string
|
||||
{
|
||||
foreach ($docblock->getTags() as $tag) {
|
||||
$tagText = $this->tagFormatter->format($tag);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -87,7 +88,6 @@ final class StandardTagFactory implements TagFactory
|
||||
* If no tag handlers are provided than the default list in the {@see self::$tagHandlerMappings} property
|
||||
* is used.
|
||||
*
|
||||
* @param FqsenResolver $fqsenResolver
|
||||
* @param string[] $tagHandlers
|
||||
*
|
||||
* @see self::registerTagHandler() to add a new tag handler to the existing default list.
|
||||
@@ -105,7 +105,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function create($tagLine, TypeContext $context = null)
|
||||
public function create(string $tagLine, TypeContext $context = null): Tag
|
||||
{
|
||||
if (! $context) {
|
||||
$context = new TypeContext('');
|
||||
@@ -125,7 +125,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function addParameter($name, $value)
|
||||
public function addParameter(string $name, $value)
|
||||
{
|
||||
$this->serviceLocator[$name] = $value;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function registerTagHandler($tagName, $handler)
|
||||
public function registerTagHandler(string $tagName, string $handler)
|
||||
{
|
||||
Assert::stringNotEmpty($tagName);
|
||||
Assert::stringNotEmpty($handler);
|
||||
@@ -164,7 +164,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function extractTagParts($tagLine)
|
||||
private function extractTagParts(string $tagLine)
|
||||
{
|
||||
$matches = [];
|
||||
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
|
||||
@@ -186,11 +186,10 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @param string $body
|
||||
* @param string $name
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @return Tag|null
|
||||
*/
|
||||
private function createTag($body, $name, TypeContext $context)
|
||||
private function createTag(string $body, string $name, TypeContext $context)
|
||||
{
|
||||
$handlerClassName = $this->findHandlerClassName($name, $context);
|
||||
$arguments = $this->getArgumentsForParametersFromWiring(
|
||||
@@ -205,11 +204,10 @@ final class StandardTagFactory implements TagFactory
|
||||
* Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).
|
||||
*
|
||||
* @param string $tagName
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function findHandlerClassName($tagName, TypeContext $context)
|
||||
private function findHandlerClassName(string $tagName, TypeContext $context): string
|
||||
{
|
||||
$handlerClassName = Generic::class;
|
||||
if (isset($this->tagHandlerMappings[$tagName])) {
|
||||
@@ -264,7 +262,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return \ReflectionParameter[]
|
||||
*/
|
||||
private function fetchParametersForHandlerFactoryMethod($handlerClassName)
|
||||
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName)
|
||||
{
|
||||
if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
|
||||
$methodReflection = new \ReflectionMethod($handlerClassName, 'create');
|
||||
@@ -284,7 +282,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function getServiceLocatorWithDynamicParameters(TypeContext $context, $tagName, $tagBody)
|
||||
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody)
|
||||
{
|
||||
$locator = array_merge(
|
||||
$this->serviceLocator,
|
||||
@@ -307,7 +305,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isAnnotation($tagContent)
|
||||
private function isAnnotation(string $tagContent): bool
|
||||
{
|
||||
// 1. Contains a namespace separator
|
||||
// 2. Contains parenthesis
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -18,7 +19,7 @@ interface Tag
|
||||
{
|
||||
public function getName();
|
||||
|
||||
public static function create($body);
|
||||
public static function create(string $body);
|
||||
|
||||
public function render(Formatter $formatter = null);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -39,7 +40,7 @@ interface TagFactory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addParameter($name, $value);
|
||||
public function addParameter(string $name, $value);
|
||||
|
||||
/**
|
||||
* Registers a service with the Service Locator using the FQCN of the class or the alias, if provided.
|
||||
@@ -61,13 +62,12 @@ interface TagFactory
|
||||
* Factory method responsible for instantiating the correct sub type.
|
||||
*
|
||||
* @param string $tagLine The text for this tag, including description.
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @throws \InvalidArgumentException if an invalid tag line was presented.
|
||||
*
|
||||
* @return Tag A new tag object.
|
||||
*/
|
||||
public function create($tagLine, TypeContext $context = null);
|
||||
public function create(string $tagLine, TypeContext $context = null): Tag;
|
||||
|
||||
/**
|
||||
* Registers a handler for tags.
|
||||
@@ -89,5 +89,5 @@ interface TagFactory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTagHandler($tagName, $handler);
|
||||
public function registerTagHandler(string $tagName, string $handler);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -34,7 +35,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
* @param string $authorName
|
||||
* @param string $authorEmail
|
||||
*/
|
||||
public function __construct($authorName, $authorEmail)
|
||||
public function __construct(string $authorName, string $authorEmail)
|
||||
{
|
||||
Assert::string($authorName);
|
||||
Assert::string($authorEmail);
|
||||
@@ -51,7 +52,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string The author's name.
|
||||
*/
|
||||
public function getAuthorName()
|
||||
public function getAuthorName(): string
|
||||
{
|
||||
return $this->authorName;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string The author's email.
|
||||
*/
|
||||
public function getEmail()
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->authorEmail;
|
||||
}
|
||||
@@ -71,7 +72,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : '');
|
||||
}
|
||||
@@ -83,7 +84,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($body)
|
||||
public static function create(string $body)
|
||||
{
|
||||
Assert::string($body);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -31,7 +32,7 @@ abstract class BaseTag implements DocBlock\Tag
|
||||
*
|
||||
* @return string The name of this tag.
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -32,7 +33,6 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*
|
||||
* @param Fqsen $refers
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct(Fqsen $refers, Description $description = null)
|
||||
@@ -45,7 +45,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
FqsenResolver $resolver = null,
|
||||
TypeContext $context = null
|
||||
@@ -57,7 +57,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return new static(
|
||||
$resolver->resolve($parts[0], $context),
|
||||
$descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context)
|
||||
$descriptionFactory->create($parts[1] ?? '', $context)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return Fqsen
|
||||
*/
|
||||
public function getReference()
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -54,8 +55,11 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
{
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
Assert::nullOrString($body);
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
@@ -71,7 +75,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return new static(
|
||||
$matches[1],
|
||||
$descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context)
|
||||
$descriptionFactory->create($matches[2] ?? '', $context)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +84,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -90,7 +94,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->version . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -42,10 +43,9 @@ final class Example extends BaseTag
|
||||
*/
|
||||
private $lineCount;
|
||||
|
||||
public function __construct($filePath, $isURI, $startingLine, $lineCount, $description)
|
||||
public function __construct(string $filePath, bool $isURI, int $startingLine, $lineCount, $description)
|
||||
{
|
||||
Assert::notEmpty($filePath);
|
||||
Assert::integer($startingLine);
|
||||
Assert::greaterThanEq($startingLine, 0);
|
||||
|
||||
$this->filePath = $filePath;
|
||||
@@ -53,7 +53,7 @@ final class Example extends BaseTag
|
||||
$this->lineCount = $lineCount;
|
||||
$this->name = 'example';
|
||||
if ($description !== null) {
|
||||
$this->description = trim($description);
|
||||
$this->description = trim((string) $description);
|
||||
}
|
||||
|
||||
$this->isURI = $isURI;
|
||||
@@ -81,7 +81,7 @@ final class Example extends BaseTag
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create($body)
|
||||
public static function create(string $body)
|
||||
{
|
||||
// File component: File path in quotes or File URI / Source information
|
||||
if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
|
||||
@@ -131,7 +131,7 @@ final class Example extends BaseTag
|
||||
* @return string Path to a file to use as an example.
|
||||
* May also be an absolute URI.
|
||||
*/
|
||||
public function getFilePath()
|
||||
public function getFilePath(): string
|
||||
{
|
||||
return $this->filePath;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ final class Example extends BaseTag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->filePath . ($this->description ? ' ' . $this->description : '');
|
||||
}
|
||||
@@ -153,7 +153,7 @@ final class Example extends BaseTag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isUriRelative($uri)
|
||||
private function isUriRelative(string $uri): bool
|
||||
{
|
||||
return false === strpos($uri, ':');
|
||||
}
|
||||
@@ -161,7 +161,7 @@ final class Example extends BaseTag
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStartingLine()
|
||||
public function getStartingLine(): int
|
||||
{
|
||||
return $this->startingLine;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ final class Example extends BaseTag
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLineCount()
|
||||
public function getLineCount(): int
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -14,5 +15,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
interface StaticMethod
|
||||
{
|
||||
public static function create($body);
|
||||
public static function create(string $body);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -19,9 +20,8 @@ interface Formatter
|
||||
/**
|
||||
* Formats a tag into a string representation according to a specific format, such as Markdown.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(Tag $tag);
|
||||
public function format(Tag $tag): string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -36,11 +37,10 @@ class AlignFormatter implements Formatter
|
||||
/**
|
||||
* Formats the given tag to return a simple plain text version.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(Tag $tag)
|
||||
public function format(Tag $tag): string
|
||||
{
|
||||
return '@' . $tag->getName() . str_repeat(' ', $this->maxLen - strlen($tag->getName()) + 1) . (string)$tag;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -20,11 +21,10 @@ class PassthroughFormatter implements Formatter
|
||||
/**
|
||||
* Formats the given tag to return a simple plain text version.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(Tag $tag)
|
||||
public function format(Tag $tag): string
|
||||
{
|
||||
return trim('@' . $tag->getName() . ' ' . (string)$tag);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -29,7 +30,7 @@ class Generic extends BaseTag implements Factory\StaticMethod
|
||||
* @param string $name Name of the tag.
|
||||
* @param Description $description The contents of the given tag.
|
||||
*/
|
||||
public function __construct($name, Description $description = null)
|
||||
public function __construct(string $name, Description $description = null)
|
||||
{
|
||||
$this->validateTagName($name);
|
||||
|
||||
@@ -42,14 +43,13 @@ class Generic extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @param string $body
|
||||
* @param string $name
|
||||
* @param DescriptionFactory $descriptionFactory
|
||||
* @param TypeContext $context
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
$name = '',
|
||||
string $body,
|
||||
string $name = '',
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
@@ -67,7 +67,7 @@ class Generic extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->description ? $this->description->render() : '');
|
||||
}
|
||||
@@ -77,9 +77,8 @@ class Generic extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function validateTagName($name)
|
||||
private function validateTagName(string $name)
|
||||
{
|
||||
if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) {
|
||||
throw new \InvalidArgumentException(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
@@ -31,9 +32,8 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
* Initializes a link to a URL.
|
||||
*
|
||||
* @param string $link
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($link, Description $description = null)
|
||||
public function __construct(string $link, Description $description = null)
|
||||
{
|
||||
Assert::string($link);
|
||||
|
||||
@@ -44,7 +44,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
public static function create(string $body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
{
|
||||
Assert::string($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -60,7 +60,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
public function getLink(): string
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->link . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -64,7 +65,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -163,7 +164,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMethodName()
|
||||
public function getMethodName(): string
|
||||
{
|
||||
return $this->methodName;
|
||||
}
|
||||
@@ -181,7 +182,7 @@ 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()
|
||||
public function isStatic(): bool
|
||||
{
|
||||
return $this->isStatic;
|
||||
}
|
||||
@@ -189,7 +190,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @return Type
|
||||
*/
|
||||
public function getReturnType()
|
||||
public function getReturnType(): Type
|
||||
{
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -38,11 +39,10 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
/**
|
||||
* @param string $variableName
|
||||
* @param Type $type
|
||||
* @param bool $isVariadic
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($variableName, Type $type = null, $isVariadic = false, Description $description = null)
|
||||
public function __construct(string $variableName, Type $type = null, bool $isVariadic = false, Description $description = null)
|
||||
{
|
||||
Assert::string($variableName);
|
||||
Assert::boolean($isVariadic);
|
||||
@@ -57,7 +57,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -101,7 +101,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
public function getVariableName(): string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVariadic()
|
||||
public function isVariadic(): bool
|
||||
{
|
||||
return $this->isVariadic;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. ($this->isVariadic() ? '...' : '')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -36,9 +37,8 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @param string $variableName
|
||||
* @param Type $type
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
{
|
||||
Assert::string($variableName);
|
||||
|
||||
@@ -51,7 +51,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -89,7 +89,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
public function getVariableName(): string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. '$' . $this->variableName
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -36,9 +37,8 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @param string $variableName
|
||||
* @param Type $type
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
{
|
||||
Assert::string($variableName);
|
||||
|
||||
@@ -51,7 +51,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -89,7 +89,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
public function getVariableName(): string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. '$' . $this->variableName
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -36,9 +37,8 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @param string $variableName
|
||||
* @param Type $type
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
{
|
||||
Assert::string($variableName);
|
||||
|
||||
@@ -51,7 +51,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -89,7 +89,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
public function getVariableName(): string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. '$' . $this->variableName
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -35,7 +36,7 @@ final class Fqsen implements Reference
|
||||
/**
|
||||
* @return string string representation of the referenced fqsen
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->fqsen;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -39,7 +40,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -49,8 +50,8 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
$parts = preg_split('/\s+/Su', $body, 2);
|
||||
|
||||
$type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context);
|
||||
$description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context);
|
||||
$type = $typeResolver->resolve($parts[0] ?? '', $context);
|
||||
$description = $descriptionFactory->create($parts[1] ?? '', $context);
|
||||
|
||||
return new static($type, $description);
|
||||
}
|
||||
@@ -60,7 +61,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return Type
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -34,7 +35,6 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*
|
||||
* @param Reference $refers
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct(Reference $refers, Description $description = null)
|
||||
@@ -47,7 +47,7 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
FqsenResolver $resolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -71,7 +71,7 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return Reference
|
||||
*/
|
||||
public function getReference()
|
||||
public function getReference(): Reference
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -54,8 +55,11 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
{
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
Assert::nullOrString($body);
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
@@ -68,7 +72,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return new static(
|
||||
$matches[1],
|
||||
$descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context)
|
||||
$descriptionFactory->create($matches[2] ?? '', $context)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +81,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -87,7 +91,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->version . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -44,8 +45,11 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
{
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -72,7 +76,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
* @return int The starting line, relative to the structural element's
|
||||
* location.
|
||||
*/
|
||||
public function getStartingLine()
|
||||
public function getStartingLine(): int
|
||||
{
|
||||
return $this->startingLine;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -39,7 +40,7 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -49,8 +50,8 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
$parts = preg_split('/\s+/Su', $body, 2);
|
||||
|
||||
$type = $typeResolver->resolve(isset($parts[0]) ? $parts[0] : '', $context);
|
||||
$description = $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context);
|
||||
$type = $typeResolver->resolve($parts[0] ?? '', $context);
|
||||
$description = $descriptionFactory->create($parts[1] ?? '', $context);
|
||||
|
||||
return new static($type, $description);
|
||||
}
|
||||
@@ -60,7 +61,7 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return Type
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -33,7 +34,6 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
* Initializes this tag.
|
||||
*
|
||||
* @param Fqsen $refers
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct(Fqsen $refers, Description $description = null)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
FqsenResolver $resolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -57,7 +57,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return new static(
|
||||
$resolver->resolve($parts[0], $context),
|
||||
$descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context)
|
||||
$descriptionFactory->create($parts[1] ?? '', $context)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return Fqsen
|
||||
*/
|
||||
public function getReference()
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->refers . ' ' . $this->description->render();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -36,9 +37,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @param string $variableName
|
||||
* @param Type $type
|
||||
* @param Description $description
|
||||
*/
|
||||
public function __construct($variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
{
|
||||
Assert::string($variableName);
|
||||
|
||||
@@ -51,7 +51,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(
|
||||
$body,
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
@@ -89,7 +89,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariableName()
|
||||
public function getVariableName(): string
|
||||
{
|
||||
return $this->variableName;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. (empty($this->variableName) ? null : ('$' . $this->variableName))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
@@ -54,8 +55,11 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
{
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
Assert::nullOrString($body);
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
@@ -68,7 +72,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
return new static(
|
||||
$matches[1],
|
||||
$descriptionFactory->create(isset($matches[2]) ? $matches[2] : '', $context)
|
||||
$descriptionFactory->create($matches[2] ?? '', $context)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -77,7 +81,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -87,7 +91,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->version . ($this->description ? ' ' . $this->description->render() : '');
|
||||
}
|
||||
|
||||
+9
-10
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of phpDocumentor.
|
||||
*
|
||||
@@ -29,7 +30,6 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
/**
|
||||
* Initializes this factory with the required subcontractors.
|
||||
*
|
||||
* @param DescriptionFactory $descriptionFactory
|
||||
* @param TagFactory $tagFactory
|
||||
*/
|
||||
public function __construct(DescriptionFactory $descriptionFactory, TagFactory $tagFactory)
|
||||
@@ -45,7 +45,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return DocBlockFactory
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = [])
|
||||
public static function createInstance(array $additionalTags = []): DocBlockFactory
|
||||
{
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
@@ -65,12 +65,11 @@ 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).
|
||||
* @param Types\Context $context
|
||||
* @param Location $location
|
||||
*
|
||||
* @return DocBlock
|
||||
*/
|
||||
public function create($docblock, Types\Context $context = null, Location $location = null)
|
||||
public function create($docblock, Types\Context $context = null, Location $location = null): DocBlock
|
||||
{
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
@@ -115,7 +114,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function stripDocComment($comment)
|
||||
private function stripDocComment(string $comment): string
|
||||
{
|
||||
$comment = trim(preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment));
|
||||
|
||||
@@ -137,7 +136,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
|
||||
*/
|
||||
private function splitDocBlock($comment)
|
||||
private function splitDocBlock(string $comment)
|
||||
{
|
||||
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
|
||||
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
|
||||
@@ -219,7 +218,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return DocBlock\Tag[]
|
||||
*/
|
||||
private function parseTagBlock($tags, Types\Context $context)
|
||||
private function parseTagBlock(string $tags, Types\Context $context)
|
||||
{
|
||||
$tags = $this->filterTagBlock($tags);
|
||||
if (!$tags) {
|
||||
@@ -239,7 +238,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function splitTagBlockIntoTagLines($tags)
|
||||
private function splitTagBlockIntoTagLines(string $tags)
|
||||
{
|
||||
$result = [];
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
@@ -257,7 +256,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
* @param $tags
|
||||
* @return string
|
||||
*/
|
||||
private function filterTagBlock($tags)
|
||||
private function filterTagBlock($tags): string
|
||||
{
|
||||
$tags = trim($tags);
|
||||
if (!$tags) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
interface DocBlockFactoryInterface
|
||||
@@ -10,14 +11,13 @@ interface DocBlockFactoryInterface
|
||||
*
|
||||
* @return DocBlockFactory
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []);
|
||||
public static function createInstance(array $additionalTags = []): DocBlockFactory;
|
||||
|
||||
/**
|
||||
* @param string $docblock
|
||||
* @param Types\Context $context
|
||||
* @param string|object $docblock
|
||||
* @param Location $location
|
||||
*
|
||||
* @return DocBlock
|
||||
*/
|
||||
public function create($docblock, Types\Context $context = null, Location $location = null);
|
||||
public function create($docblock, Types\Context $context = null, Location $location = null): DocBlock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user