Merge pull request #152 from ashnazg/strict

Strict Updates
This commit is contained in:
Chuck Burgess
2018-01-31 14:23:19 -06:00
committed by GitHub
22 changed files with 30 additions and 32 deletions
+2 -2
View File
@@ -133,7 +133,7 @@ final class DocBlock
* *
* @return Tag[] * @return Tag[]
*/ */
public function getTags() public function getTags(): array
{ {
return $this->tags; return $this->tags;
} }
@@ -146,7 +146,7 @@ final class DocBlock
* *
* @return Tag[] * @return Tag[]
*/ */
public function getTagsByName(string $name) public function getTagsByName(string $name): array
{ {
$result = []; $result = [];
+1 -1
View File
@@ -72,7 +72,7 @@ class Description
* *
* @return Tag[] * @return Tag[]
*/ */
public function getTags() public function getTags(): array
{ {
return $this->tags; return $this->tags;
} }
+1 -1
View File
@@ -61,7 +61,7 @@ class DescriptionFactory
* *
* @return string[] A series of tokens of which the description text is composed. * @return string[] A series of tokens of which the description text is composed.
*/ */
private function lex(string $contents) private function lex(string $contents): array
{ {
$contents = $this->removeSuperfluousStartingWhitespace($contents); $contents = $this->removeSuperfluousStartingWhitespace($contents);
+4 -4
View File
@@ -163,7 +163,7 @@ final class StandardTagFactory implements TagFactory
* *
* @return string[] * @return string[]
*/ */
private function extractTagParts(string $tagLine) private function extractTagParts(string $tagLine): array
{ {
$matches = []; $matches = [];
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) { if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
@@ -222,7 +222,7 @@ final class StandardTagFactory implements TagFactory
* @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters * @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters
* is provided with this method. * is provided with this method.
*/ */
private function getArgumentsForParametersFromWiring($parameters, $locator) private function getArgumentsForParametersFromWiring($parameters, $locator): array
{ {
$arguments = []; $arguments = [];
foreach ($parameters as $index => $parameter) { foreach ($parameters as $index => $parameter) {
@@ -251,7 +251,7 @@ final class StandardTagFactory implements TagFactory
* *
* @return \ReflectionParameter[] * @return \ReflectionParameter[]
*/ */
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName) private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
{ {
if (! isset($this->tagHandlerParameterCache[$handlerClassName])) { if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
$methodReflection = new \ReflectionMethod($handlerClassName, 'create'); $methodReflection = new \ReflectionMethod($handlerClassName, 'create');
@@ -271,7 +271,7 @@ final class StandardTagFactory implements TagFactory
* *
* @return mixed[] * @return mixed[]
*/ */
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody) private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody): array
{ {
$locator = array_merge( $locator = array_merge(
$this->serviceLocator, $this->serviceLocator,
+1 -1
View File
@@ -47,7 +47,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?FqsenResolver $resolver = null, ?FqsenResolver $resolver = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::notEmpty($body); Assert::notEmpty($body);
$parts = preg_split('/\s+/Su', $body, 2); $parts = preg_split('/\s+/Su', $body, 2);
+1 -1
View File
@@ -59,7 +59,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
?string $body, ?string $body,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
if (empty($body)) { if (empty($body)) {
return new static(); return new static();
} }
+1 -2
View File
@@ -13,7 +13,6 @@
namespace phpDocumentor\Reflection\DocBlock\Tags; namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tag;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
@@ -81,7 +80,7 @@ final class Example extends BaseTag
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(string $body) public static function create(string $body): ?Tag
{ {
// File component: File path in quotes or File URI / Source information // File component: File path in quotes or File URI / Source information
if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) { if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
+1 -1
View File
@@ -49,7 +49,7 @@ class Generic extends BaseTag implements Factory\StaticMethod
string $name = '', string $name = '',
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($name); Assert::stringNotEmpty($name);
Assert::notNull($descriptionFactory); Assert::notNull($descriptionFactory);
+3 -3
View File
@@ -170,7 +170,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
/** /**
* @return string[] * @return string[]
*/ */
public function getArguments() public function getArguments(): array
{ {
return $this->arguments; return $this->arguments;
} }
@@ -204,7 +204,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
. ($this->description ? ' ' . $this->description->render() : '')); . ($this->description ? ' ' . $this->description->render() : ''));
} }
private function filterArguments($arguments) private function filterArguments(array $arguments = []): array
{ {
foreach ($arguments as &$argument) { foreach ($arguments as &$argument) {
if (is_string($argument)) { if (is_string($argument)) {
@@ -227,7 +227,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
return $arguments; return $arguments;
} }
private static function stripRestArg($argument) private static function stripRestArg(string $argument): string
{ {
if (strpos($argument, '...') === 0) { if (strpos($argument, '...') === 0) {
$argument = trim(substr($argument, 3)); $argument = trim(substr($argument, 3));
+1 -1
View File
@@ -53,7 +53,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
+1 -1
View File
@@ -49,7 +49,7 @@ class Property extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
+1 -1
View File
@@ -49,7 +49,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
+1 -1
View File
@@ -49,7 +49,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
+1 -1
View File
@@ -28,7 +28,7 @@ final class Url implements Reference
/** /**
* Url constructor. * Url constructor.
*/ */
public function __construct($uri) public function __construct(string $uri)
{ {
Assert::stringNotEmpty($uri); Assert::stringNotEmpty($uri);
$this->uri = $uri; $this->uri = $uri;
+1 -1
View File
@@ -44,7 +44,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
$parts = preg_split('/\s+/Su', $body, 2); $parts = preg_split('/\s+/Su', $body, 2);
+1 -1
View File
@@ -49,7 +49,7 @@ class See extends BaseTag implements Factory\StaticMethod
?FqsenResolver $resolver = null, ?FqsenResolver $resolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::allNotNull([$resolver, $descriptionFactory]); Assert::allNotNull([$resolver, $descriptionFactory]);
$parts = preg_split('/\s+/Su', $body, 2); $parts = preg_split('/\s+/Su', $body, 2);
-1
View File
@@ -15,7 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Description; use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\Types\Context as TypeContext; use phpDocumentor\Reflection\Types\Context as TypeContext;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
+1 -1
View File
@@ -49,7 +49,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
string $body, string $body,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::notNull($descriptionFactory); Assert::notNull($descriptionFactory);
+1 -1
View File
@@ -44,7 +44,7 @@ final class Throws extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
$parts = preg_split('/\s+/Su', $body, 2); $parts = preg_split('/\s+/Su', $body, 2);
+1 -1
View File
@@ -47,7 +47,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
?FqsenResolver $resolver = null, ?FqsenResolver $resolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::allNotNull([$resolver, $descriptionFactory]); Assert::allNotNull([$resolver, $descriptionFactory]);
$parts = preg_split('/\s+/Su', $body, 2); $parts = preg_split('/\s+/Su', $body, 2);
+1 -1
View File
@@ -49,7 +49,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
?TypeResolver $typeResolver = null, ?TypeResolver $typeResolver = null,
?DescriptionFactory $descriptionFactory = null, ?DescriptionFactory $descriptionFactory = null,
?TypeContext $context = null ?TypeContext $context = null
) { ): self {
Assert::stringNotEmpty($body); Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]); Assert::allNotNull([$typeResolver, $descriptionFactory]);
+2 -2
View File
@@ -127,7 +127,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
* *
* @return string[] containing the template marker (if any), summary, description and a string containing the tags. * @return string[] containing the template marker (if any), summary, description and a string containing the tags.
*/ */
private function splitDocBlock(string $comment) private function splitDocBlock(string $comment): array
{ {
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This // 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 // method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
@@ -227,7 +227,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/** /**
* @return string[] * @return string[]
*/ */
private function splitTagBlockIntoTagLines(string $tags) private function splitTagBlockIntoTagLines(string $tags): array
{ {
$result = []; $result = [];
foreach (explode("\n", $tags) as $tag_line) { foreach (explode("\n", $tags) as $tag_line) {