add PHP 7.1 typehints

This commit is contained in:
TomasVotruba
2017-11-30 10:27:01 +01:00
committed by Jaap van Otterdijk
parent f9d1a0c177
commit 4a9675841b
64 changed files with 410 additions and 430 deletions
+5 -8
View File
@@ -46,10 +46,10 @@ final class DocBlock
*/
public function __construct(
string $summary = '',
DocBlock\Description $description = null,
?DocBlock\Description $description = null,
array $tags = [],
Types\Context $context = null,
Location $location = null,
?Types\Context $context = null,
?Location $location = null,
bool $isTemplateStart = false,
bool $isTemplateEnd = false
) {
@@ -84,7 +84,6 @@ final class DocBlock
/**
* Returns the current context.
*
* @return Types\Context
*/
public function getContext(): Types\Context
{
@@ -118,7 +117,6 @@ final class DocBlock
*
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
*
* @return boolean
*/
public function isTemplateStart(): bool
{
@@ -130,7 +128,6 @@ final class DocBlock
*
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
*
* @return boolean
*/
public function isTemplateEnd(): bool
{
@@ -193,7 +190,7 @@ final class DocBlock
*
* @param Tag $tag The tag to remove.
*/
public function removeTag(Tag $tagToRemove)
public function removeTag(Tag $tagToRemove): void
{
foreach ($this->tags as $key => $tag) {
if ($tag === $tagToRemove) {
@@ -208,7 +205,7 @@ final class DocBlock
*
* @param Tag $tag The tag to add.
*/
private function addTag(Tag $tag)
private function addTag(Tag $tag): void
{
$this->tags[] = $tag;
}
+1 -1
View File
@@ -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();
+2 -3
View File
@@ -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);
}
+3 -4
View File
@@ -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;
+8 -9
View File
@@ -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(
+6 -3
View File
@@ -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;
}
+4 -5
View File
@@ -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;
}
+1 -1
View File
@@ -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();
+4 -5
View File
@@ -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
{
+5 -6
View File
@@ -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);
}
+1 -1
View File
@@ -15,5 +15,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
interface Strategy
{
public function create($body);
public function create($body): void;
}
-1
View File
@@ -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;
}
+4 -4
View File
@@ -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(
+2 -2
View File
@@ -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);
+8 -8
View File
@@ -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) {
+5 -7
View File
@@ -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
{
+5 -6
View File
@@ -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;
}
+5 -6
View File
@@ -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;
}
+5 -6
View File
@@ -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;
}
+1 -1
View File
@@ -18,5 +18,5 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Reference;
*/
interface Reference
{
public function __toString();
public function __toString(): string;
}
+1 -1
View File
@@ -34,7 +34,7 @@ final class Url implements Reference
$this->uri = $uri;
}
public function __toString()
public function __toString(): string
{
return $this->uri;
}
+5 -7
View File
@@ -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;
}
+4 -5
View File
@@ -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
{
+4 -4
View File
@@ -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();
+5 -5
View File
@@ -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 : '')
+5 -6
View File
@@ -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;
}
+4 -5
View File
@@ -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
{
+5 -6
View File
@@ -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;
}
+4 -4
View File
@@ -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();
+2 -4
View File
@@ -41,7 +41,6 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*
* @param string[] $additionalTags
*
* @return DocBlockFactory
*/
public static function createInstance(array $additionalTags = []): DocBlockFactory
{
@@ -64,9 +63,8 @@ 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).
*
* @return 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
{
if (is_object($docblock)) {
if (!method_exists($docblock, 'getDocComment')) {
@@ -99,7 +97,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
);
}
public function registerTagHandler($tagName, $handler)
public function registerTagHandler($tagName, $handler): void
{
$this->tagFactory->registerTagHandler($tagName, $handler);
}
+1 -4
View File
@@ -9,15 +9,12 @@ interface DocBlockFactoryInterface
*
* @param string[] $additionalTags
*
* @return DocBlockFactory
*/
public static function createInstance(array $additionalTags = []): DocBlockFactory;
/**
* @param string|object $docblock
* @param Location $location
*
* @return 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;
}