Psalm fixes

This commit is contained in:
Jaapio
2019-09-26 21:09:37 +02:00
parent 19a1f3a91f
commit 50ec1362de
14 changed files with 187 additions and 99 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ class ExampleFinder
}
$lines = $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : false;
return $lines !== false ? $lines : null;
return $lines !== false ? $lines : null;
}
/**
+27 -24
View File
@@ -8,14 +8,31 @@ declare(strict_types=1);
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tags\Author;
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
use phpDocumentor\Reflection\DocBlock\Tags\Method;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\DocBlock\Tags\Property;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
use phpDocumentor\Reflection\DocBlock\Tags\Since;
use phpDocumentor\Reflection\DocBlock\Tags\Source;
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use phpDocumentor\Reflection\DocBlock\Tags\Version;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use ReflectionMethod;
@@ -28,23 +45,6 @@ use function count;
use function get_class;
use function preg_match;
use function strpos;
use phpDocumentor\Reflection\DocBlock\Tags\Author;
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
use phpDocumentor\Reflection\DocBlock\Tags\Link;
use phpDocumentor\Reflection\DocBlock\Tags\Method;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
use phpDocumentor\Reflection\DocBlock\Tags\Property;
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\DocBlock\Tags\See;
use phpDocumentor\Reflection\DocBlock\Tags\Since;
use phpDocumentor\Reflection\DocBlock\Tags\Source;
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use phpDocumentor\Reflection\DocBlock\Tags\Version;
/**
* Creates a Tag object given the contents of a tag.
@@ -77,14 +77,14 @@ final class StandardTagFactory implements TagFactory
'covers' => Covers::class,
'deprecated' => Deprecated::class,
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
'link' => Link::class,
'link' => LinkTag::class,
'method' => Method::class,
'param' => Param::class,
'property-read' => PropertyRead::class,
'property' => Property::class,
'property-write' => PropertyWrite::class,
'return' => Return_::class,
'see' => See::class,
'see' => SeeTag::class,
'since' => Since::class,
'source' => Source::class,
'throw' => Throws::class,
@@ -166,7 +166,7 @@ final class StandardTagFactory implements TagFactory
/**
* {@inheritDoc}
*/
public function addService(object $service, $alias = null) : void
public function addService(object $service, ?string $alias = null) : void
{
$this->serviceLocator[$alias ?: get_class($service)] = $service;
}
@@ -232,8 +232,6 @@ final class StandardTagFactory implements TagFactory
/**
* Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).
*
* @return
*/
private function findHandlerClassName(string $tagName, TypeContext $context) : string
{
@@ -264,7 +262,12 @@ final class StandardTagFactory implements TagFactory
{
$arguments = [];
foreach ($parameters as $parameter) {
$typeHint = $parameter->getClass() !== null ? $parameter->getClass()->getName() : null;
$class = $parameter->getClass();
$typeHint = null;
if ($class !== null) {
$typeHint = $class->getName();
}
if (isset($locator[$typeHint])) {
$arguments[] = $locator[$typeHint];
continue;
+1 -1
View File
@@ -49,7 +49,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
) : self {
Assert::notNull($descriptionFactory);
$parts = preg_split('/\s+/Su', $body, 2);
$parts = preg_split('/\s+/Su', $body, 2);
Assert::isArray($parts);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
+1 -1
View File
@@ -222,7 +222,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
}
/**
* @param array<string|mixed[]> $arguments
* @param mixed[][] $arguments
*
* @return mixed[][]
*/
+1 -2
View File
@@ -23,7 +23,6 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
@@ -69,7 +68,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
Assert::notNull($typeResolver);
Assert::notNull($descriptionFactory);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
Assert::isArray($parts);
$type = null;
$variableName = '';
+2 -2
View File
@@ -23,7 +23,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
/**
@@ -60,7 +60,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
Assert::notNull($typeResolver);
Assert::notNull($descriptionFactory);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
Assert::isArray($parts);
$type = null;
$variableName = '';
+1 -1
View File
@@ -61,7 +61,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
Assert::notNull($typeResolver);
Assert::notNull($descriptionFactory);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
Assert::isArray($parts);
$type = null;
$variableName = '';
+1 -1
View File
@@ -56,7 +56,7 @@ class See extends BaseTag implements Factory\StaticMethod
Assert::notNull($typeResolver);
Assert::notNull($descriptionFactory);
$parts = preg_split('/\s+/Su', $body, 2);
$parts = preg_split('/\s+/Su', $body, 2);
Assert::isArray($parts);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
+3 -3
View File
@@ -23,7 +23,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
/**
@@ -60,7 +60,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
Assert::notNull($typeResolver);
Assert::notNull($descriptionFactory);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
$parts = preg_split('/(\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
Assert::isArray($parts);
Assert::allString($parts);
$type = null;
@@ -111,7 +111,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
public function __toString() : string
{
return ($this->type ? $this->type . ' ' : '')
. (empty($this->variableName) ? null : ('$' . $this->variableName))
. (empty($this->variableName) ? '' : ('$' . $this->variableName))
. ($this->description ? ' ' . $this->description : '');
}
}
+2 -1
View File
@@ -92,6 +92,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
*/
public function __toString() : string
{
return $this->version . ($this->description ? ' ' . $this->description->render() : '');
return ((string) $this->version) .
($this->description instanceof Description ? ' ' . $this->description->render() : '');
}
}