mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
add PHP 7.1 typehints
This commit is contained in:
committed by
Jaap van Otterdijk
parent
f9d1a0c177
commit
4a9675841b
@@ -81,7 +81,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();
|
||||
|
||||
@@ -49,11 +49,10 @@ class DescriptionFactory
|
||||
* Returns the parsed text of this description.
|
||||
*
|
||||
*
|
||||
* @return Description
|
||||
*/
|
||||
public function create(string $contents, TypeContext $context = null): Description
|
||||
public function create(string $contents, ?TypeContext $context = null): Description
|
||||
{
|
||||
list($text, $tags) = $this->parse($this->lex($contents), $context);
|
||||
[$text, $tags] = $this->parse($this->lex($contents), $context);
|
||||
|
||||
return new Description($text, $tags);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class ExampleFinder
|
||||
/**
|
||||
* Registers the project's root directory where an 'examples' folder can be expected.
|
||||
*/
|
||||
public function setSourceDirectory(string $directory = '')
|
||||
public function setSourceDirectory(string $directory = ''): void
|
||||
{
|
||||
$this->sourceDirectory = $directory;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class ExampleFinder
|
||||
*
|
||||
* @param string[] $directories
|
||||
*/
|
||||
public function setExampleDirectories(array $directories)
|
||||
public function setExampleDirectories(array $directories): void
|
||||
{
|
||||
$this->exampleDirectories = $directories;
|
||||
}
|
||||
@@ -89,9 +89,8 @@ class ExampleFinder
|
||||
* 4. Checks the path relative to the current working directory for the given filename
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getExampleFileContents(string $filename)
|
||||
private function getExampleFileContents(string $filename): ?string
|
||||
{
|
||||
$normalizedPath = null;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ use Webmozart\Assert\Assert;
|
||||
final class StandardTagFactory implements TagFactory
|
||||
{
|
||||
/** PCRE regular expression matching a tag name. */
|
||||
const REGEX_TAGNAME = '[\w\-\_\\\\]+';
|
||||
public const REGEX_TAGNAME = '[\w\-\_\\\\]+';
|
||||
|
||||
/**
|
||||
* @var string[] An array with a tag as a key, and an FQCN to a class that handles it as an array value.
|
||||
@@ -92,7 +92,7 @@ final class StandardTagFactory implements TagFactory
|
||||
*
|
||||
* @see self::registerTagHandler() to add a new tag handler to the existing default list.
|
||||
*/
|
||||
public function __construct(FqsenResolver $fqsenResolver, array $tagHandlers = null)
|
||||
public function __construct(FqsenResolver $fqsenResolver, ?array $tagHandlers = null)
|
||||
{
|
||||
$this->fqsenResolver = $fqsenResolver;
|
||||
if ($tagHandlers !== null) {
|
||||
@@ -105,13 +105,13 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function create(string $tagLine, TypeContext $context = null): Tag
|
||||
public function create(string $tagLine, ?TypeContext $context = null): Tag
|
||||
{
|
||||
if (! $context) {
|
||||
$context = new TypeContext('');
|
||||
}
|
||||
|
||||
list($tagName, $tagBody) = $this->extractTagParts($tagLine);
|
||||
[$tagName, $tagBody] = $this->extractTagParts($tagLine);
|
||||
|
||||
if ($tagBody !== '' && $tagBody[0] === '[') {
|
||||
throw new \InvalidArgumentException(
|
||||
@@ -125,7 +125,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function addParameter(string $name, $value)
|
||||
public function addParameter(string $name, $value): void
|
||||
{
|
||||
$this->serviceLocator[$name] = $value;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function addService($service, $alias = null)
|
||||
public function addService($service, $alias = null): void
|
||||
{
|
||||
$this->serviceLocator[$alias ?: get_class($service)] = $service;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ final class StandardTagFactory implements TagFactory
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function registerTagHandler(string $tagName, string $handler)
|
||||
public function registerTagHandler(string $tagName, string $handler): void
|
||||
{
|
||||
Assert::stringNotEmpty($tagName);
|
||||
Assert::stringNotEmpty($handler);
|
||||
@@ -184,9 +184,8 @@ final class StandardTagFactory implements TagFactory
|
||||
* body was invalid.
|
||||
*
|
||||
*
|
||||
* @return Tag|null
|
||||
*/
|
||||
private function createTag(string $body, string $name, TypeContext $context)
|
||||
private function createTag(string $body, string $name, TypeContext $context): ?Tag
|
||||
{
|
||||
$handlerClassName = $this->findHandlerClassName($name, $context);
|
||||
$arguments = $this->getArgumentsForParametersFromWiring(
|
||||
|
||||
@@ -17,11 +17,14 @@ use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
|
||||
|
||||
interface Tag
|
||||
{
|
||||
public function getName();
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* @return Tag Class that implements Tag
|
||||
*/
|
||||
public static function create(string $body);
|
||||
|
||||
public function render(Formatter $formatter = null);
|
||||
public function render(?Formatter $formatter = null): string;
|
||||
|
||||
public function __toString();
|
||||
public function __toString(): string;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,9 @@ interface TagFactory
|
||||
*
|
||||
* These parameters are injected at the last moment and will override any existing parameter with those names.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function addParameter(string $name, $value);
|
||||
public function addParameter(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* Registers a service with the Service Locator using the FQCN of the class or the alias, if provided.
|
||||
@@ -51,7 +50,7 @@ interface TagFactory
|
||||
*
|
||||
* @param object $service
|
||||
*/
|
||||
public function addService($service);
|
||||
public function addService($service): void;
|
||||
|
||||
/**
|
||||
* Factory method responsible for instantiating the correct sub type.
|
||||
@@ -62,7 +61,7 @@ interface TagFactory
|
||||
*
|
||||
* @return Tag A new tag object.
|
||||
*/
|
||||
public function create(string $tagLine, TypeContext $context = null): ?Tag;
|
||||
public function create(string $tagLine, ?TypeContext $context = null): ?Tag;
|
||||
|
||||
/**
|
||||
* Registers a handler for tags.
|
||||
@@ -82,5 +81,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);
|
||||
public function registerTagHandler(string $tagName, string $handler): void;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ abstract class BaseTag implements DocBlock\Tag
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function render(Formatter $formatter = null)
|
||||
public function render(?Formatter $formatter = null): string
|
||||
{
|
||||
if ($formatter === null) {
|
||||
$formatter = new Formatter\PassthroughFormatter();
|
||||
|
||||
@@ -33,7 +33,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*/
|
||||
public function __construct(Fqsen $refers, Description $description = null)
|
||||
public function __construct(Fqsen $refers, ?Description $description = null)
|
||||
{
|
||||
$this->refers = $refers;
|
||||
$this->description = $description;
|
||||
@@ -44,9 +44,9 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
FqsenResolver $resolver = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?FqsenResolver $resolver = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::notEmpty($body);
|
||||
|
||||
@@ -61,7 +61,6 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the structural element this tag refers to.
|
||||
*
|
||||
* @return Fqsen
|
||||
*/
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
* PCRE regular expression matching a version vector.
|
||||
* Assumes the "x" modifier.
|
||||
*/
|
||||
const REGEX_VECTOR = '(?:
|
||||
public const REGEX_VECTOR = '(?:
|
||||
# Normal release vectors.
|
||||
\d\S*
|
||||
|
|
||||
@@ -44,7 +44,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string The version vector. */
|
||||
private $version = '';
|
||||
|
||||
public function __construct($version = null, Description $description = null)
|
||||
public function __construct($version = null, ?Description $description = null)
|
||||
{
|
||||
Assert::nullOrStringNotEmpty($version);
|
||||
|
||||
@@ -57,8 +57,8 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
?string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
@@ -81,9 +81,8 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Gets the version section of the tag.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,8 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
interface StaticMethod
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function create(string $body);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
interface Strategy
|
||||
{
|
||||
public function create($body);
|
||||
public function create($body): void;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ interface Formatter
|
||||
* Formats a tag into a string representation according to a specific format, such as Markdown.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function format(Tag $tag): string;
|
||||
}
|
||||
|
||||
@@ -30,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(string $name, Description $description = null)
|
||||
public function __construct(string $name, ?Description $description = null)
|
||||
{
|
||||
$this->validateTagName($name);
|
||||
|
||||
@@ -47,8 +47,8 @@ class Generic extends BaseTag implements Factory\StaticMethod
|
||||
public static function create(
|
||||
string $body,
|
||||
string $name = '',
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($name);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -69,7 +69,7 @@ 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)
|
||||
private function validateTagName(string $name): void
|
||||
{
|
||||
if (! preg_match('/^' . StandardTagFactory::REGEX_TAGNAME . '$/u', $name)) {
|
||||
throw new \InvalidArgumentException(
|
||||
|
||||
@@ -31,7 +31,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes a link to a URL.
|
||||
*/
|
||||
public function __construct(string $link, Description $description = null)
|
||||
public function __construct(string $link, ?Description $description = null)
|
||||
{
|
||||
$this->link = $link;
|
||||
$this->description = $description;
|
||||
@@ -40,7 +40,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(string $body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
|
||||
public static function create(string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null): Link
|
||||
{
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
public function __construct(
|
||||
$methodName,
|
||||
array $arguments = [],
|
||||
Type $returnType = null,
|
||||
?Type $returnType = null,
|
||||
$static = false,
|
||||
Description $description = null
|
||||
?Description $description = null
|
||||
) {
|
||||
Assert::stringNotEmpty($methodName);
|
||||
Assert::boolean($static);
|
||||
@@ -66,10 +66,10 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
) {
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): Method {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([ $typeResolver, $descriptionFactory ]);
|
||||
|
||||
@@ -123,7 +123,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
return null;
|
||||
}
|
||||
|
||||
list(, $static, $returnType, $methodName, $arguments, $description) = $matches;
|
||||
[, $static, $returnType, $methodName, $arguments, $description] = $matches;
|
||||
|
||||
$static = $static === 'static';
|
||||
|
||||
@@ -193,7 +193,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
return $this->returnType;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($this->arguments as $argument) {
|
||||
|
||||
@@ -37,7 +37,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
/** @var bool determines whether this is a variadic argument */
|
||||
private $isVariadic = false;
|
||||
|
||||
public function __construct(string $variableName, Type $type = null, bool $isVariadic = false, Description $description = null)
|
||||
public function __construct(string $variableName, ?Type $type = null, bool $isVariadic = false, ?Description $description = null)
|
||||
{
|
||||
$this->variableName = $variableName;
|
||||
$this->type = $type;
|
||||
@@ -50,9 +50,9 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
@@ -99,9 +99,8 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's type or null if unknown.
|
||||
*
|
||||
* @return Type|null
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
@@ -109,7 +108,6 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns whether this tag is variadic.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isVariadic(): bool
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
$this->variableName = $variableName;
|
||||
$this->type = $type;
|
||||
@@ -46,9 +46,9 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
@@ -89,9 +89,8 @@ class Property extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's type or null if unknown.
|
||||
*
|
||||
* @return Type|null
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
$this->variableName = $variableName;
|
||||
$this->type = $type;
|
||||
@@ -46,9 +46,9 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
@@ -89,9 +89,8 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's type or null if unknown.
|
||||
*
|
||||
* @return Type|null
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
$this->variableName = $variableName;
|
||||
$this->type = $type;
|
||||
@@ -46,9 +46,9 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
@@ -89,9 +89,8 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's type or null if unknown.
|
||||
*
|
||||
* @return Type|null
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
|
||||
*/
|
||||
interface Reference
|
||||
{
|
||||
public function __toString();
|
||||
public function __toString(): string;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ final class Url implements Reference
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
/** @var Type */
|
||||
private $type;
|
||||
|
||||
public function __construct(Type $type, Description $description = null)
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
@@ -41,9 +41,9 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
|
||||
@@ -57,15 +57,13 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
/**
|
||||
* Returns the type section of the variable.
|
||||
*
|
||||
* @return Type
|
||||
*/
|
||||
public function getType(): Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->type . ' ' . $this->description;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*/
|
||||
public function __construct(Reference $refers, Description $description = null)
|
||||
public function __construct(Reference $refers, ?Description $description = null)
|
||||
{
|
||||
$this->refers = $refers;
|
||||
$this->description = $description;
|
||||
@@ -46,9 +46,9 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
FqsenResolver $resolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?FqsenResolver $resolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::allNotNull([$resolver, $descriptionFactory]);
|
||||
|
||||
@@ -66,7 +66,6 @@ class See extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the ref of this tag.
|
||||
*
|
||||
* @return Reference
|
||||
*/
|
||||
public function getReference(): Reference
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
* PCRE regular expression matching a version vector.
|
||||
* Assumes the "x" modifier.
|
||||
*/
|
||||
const REGEX_VECTOR = '(?:
|
||||
public const REGEX_VECTOR = '(?:
|
||||
# Normal release vectors.
|
||||
\d\S*
|
||||
|
|
||||
@@ -44,7 +44,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string The version vector. */
|
||||
private $version = '';
|
||||
|
||||
public function __construct($version = null, Description $description = null)
|
||||
public function __construct($version = null, ?Description $description = null)
|
||||
{
|
||||
Assert::nullOrStringNotEmpty($version);
|
||||
|
||||
@@ -57,8 +57,8 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
?string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
|
||||
@@ -32,7 +32,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
/** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */
|
||||
private $lineCount = null;
|
||||
|
||||
public function __construct($startingLine, $lineCount = null, Description $description = null)
|
||||
public function __construct($startingLine, $lineCount = null, ?Description $description = null)
|
||||
{
|
||||
Assert::integerish($startingLine);
|
||||
Assert::nullOrIntegerish($lineCount);
|
||||
@@ -47,8 +47,8 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::notNull($descriptionFactory);
|
||||
@@ -87,12 +87,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()
|
||||
public function getLineCount(): ?int
|
||||
{
|
||||
return $this->lineCount;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->startingLine
|
||||
. ($this->lineCount !== null ? ' ' . $this->lineCount : '')
|
||||
|
||||
@@ -30,7 +30,7 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
/** @var Type */
|
||||
private $type;
|
||||
|
||||
public function __construct(Type $type, Description $description = null)
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->description = $description;
|
||||
@@ -41,9 +41,9 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
|
||||
@@ -58,14 +58,13 @@ final class Throws extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the type section of the variable.
|
||||
*
|
||||
* @return Type
|
||||
*/
|
||||
public function getType(): Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->type . ' ' . $this->description;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Initializes this tag.
|
||||
*/
|
||||
public function __construct(Fqsen $refers, Description $description = null)
|
||||
public function __construct(Fqsen $refers, ?Description $description = null)
|
||||
{
|
||||
$this->refers = $refers;
|
||||
$this->description = $description;
|
||||
@@ -44,9 +44,9 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
FqsenResolver $resolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?FqsenResolver $resolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::allNotNull([$resolver, $descriptionFactory]);
|
||||
|
||||
@@ -61,7 +61,6 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the structural element this tag refers to.
|
||||
*
|
||||
* @return Fqsen
|
||||
*/
|
||||
public function getReference(): Fqsen
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string */
|
||||
protected $variableName = '';
|
||||
|
||||
public function __construct(string $variableName, Type $type = null, Description $description = null)
|
||||
public function __construct(string $variableName, ?Type $type = null, ?Description $description = null)
|
||||
{
|
||||
$this->variableName = $variableName;
|
||||
$this->type = $type;
|
||||
@@ -46,9 +46,9 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
Assert::stringNotEmpty($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
@@ -89,9 +89,8 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
||||
/**
|
||||
* Returns the variable's type or null if unknown.
|
||||
*
|
||||
* @return Type|null
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?Type
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
* PCRE regular expression matching a version vector.
|
||||
* Assumes the "x" modifier.
|
||||
*/
|
||||
const REGEX_VECTOR = '(?:
|
||||
public const REGEX_VECTOR = '(?:
|
||||
# Normal release vectors.
|
||||
\d\S*
|
||||
|
|
||||
@@ -44,7 +44,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
/** @var string The version vector. */
|
||||
private $version = '';
|
||||
|
||||
public function __construct($version = null, Description $description = null)
|
||||
public function __construct($version = null, ?Description $description = null)
|
||||
{
|
||||
Assert::nullOrStringNotEmpty($version);
|
||||
|
||||
@@ -57,8 +57,8 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public static function create(
|
||||
?string $body,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
) {
|
||||
if (empty($body)) {
|
||||
return new static();
|
||||
|
||||
Reference in New Issue
Block a user