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
+15
View File
@@ -0,0 +1,15 @@
{
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor"
],
"php-core-extensions" : [
"Core",
"pcre",
"Reflection",
"tokenizer",
"SPL",
"standard"
]
}
+9 -4
View File
@@ -7,13 +7,18 @@
{
"name": "Mike van Riel",
"email": "[email protected]"
},
{
"name": "Jaap van Otterdijk",
"email": "[email protected]"
}
],
"minimum-stability": "alpha",
"require": {
"php": ">=7.1",
"phpdocumentor/type-resolver": "^0",
"webmozart/assert": "^1"
"php": "^7.1",
"phpdocumentor/type-resolver": "^1.0",
"webmozart/assert": "^1",
"phpdocumentor/reflection-common": "^2.0",
"ext-filter": "^7.1"
},
"require-dev": {
"mockery/mockery": "^1",
Generated
+117 -48
View File
@@ -1,30 +1,30 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cb7ecdcb52e627755275cf273bcdd249",
"content-hash": "93c5a8174b30802326730535c6b1479f",
"packages": [
{
"name": "phpdocumentor/reflection-common",
"version": "2.0.0-alpha3",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "eedd98e8bc9cfd924f056b4b5847066d4a250d2f"
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/eedd98e8bc9cfd924f056b4b5847066d4a250d2f",
"reference": "eedd98e8bc9cfd924f056b4b5847066d4a250d2f",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a",
"reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^6"
"phpunit/phpunit": "~6"
},
"type": "library",
"extra": {
@@ -34,9 +34,7 @@
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": [
"src"
]
"phpDocumentor\\Reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -58,34 +56,35 @@
"reflection",
"static analysis"
],
"time": "2018-06-13T21:44:20+00:00"
"time": "2018-08-07T13:53:10+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.6.2",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e81ce9e82df06b49b2d0e0a2393a08955aeda05b"
"reference": "4dfca962ce4d6c11ae17efcc65621cc4b22004c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e81ce9e82df06b49b2d0e0a2393a08955aeda05b",
"reference": "e81ce9e82df06b49b2d0e0a2393a08955aeda05b",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/4dfca962ce4d6c11ae17efcc65621cc4b22004c7",
"reference": "4dfca962ce4d6c11ae17efcc65621cc4b22004c7",
"shasum": ""
},
"require": {
"php": ">=7.1",
"phpdocumentor/reflection-common": "^2"
"php": "^7.1",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^6.5"
"ext-tokenizer": "^7.1",
"mockery/mockery": "~1",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.x-dev"
"dev-master": "1.x-dev"
}
},
"autoload": {
@@ -93,7 +92,11 @@
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"autoload-dev": {
"psr-4": {
"phpDocumentor\\Reflection\\": "tests/unit"
}
},
"license": [
"MIT"
],
@@ -103,24 +106,88 @@
"email": "[email protected]"
}
],
"time": "2018-06-14T12:29:58+00:00"
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.0.0",
"issues": "https://github.com/phpDocumentor/TypeResolver/issues"
},
"time": "2019-07-08T19:35:58+00:00"
},
{
"name": "webmozart/assert",
"version": "1.3.0",
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "0df1908962e7a3071564e857d86874dad1ef204a"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a",
"reference": "0df1908962e7a3071564e857d86874dad1ef204a",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0"
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "[email protected]"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "webmozart/assert",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9",
"reference": "83e253c8e0be5b0257b881e1827274667c5c17a9",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
@@ -153,33 +220,35 @@
"check",
"validate"
],
"time": "2018-01-29T19:49:41+00:00"
"time": "2018-12-25T11:19:39+00:00"
}
],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.1.0",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
"reference": "a2c590166b2133a4633738648b6b064edae0814a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"doctrine/coding-standard": "^6.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2"
"phpbench/phpbench": "^0.13",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
@@ -204,12 +273,12 @@
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"time": "2017-07-22T11:58:36+00:00"
"time": "2019-03-17T17:37:11+00:00"
},
{
"name": "hamcrest/hamcrest-php",
@@ -261,16 +330,16 @@
},
{
"name": "mockery/mockery",
"version": "1.1.0",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "99e29d3596b16dabe4982548527d5ddf90232e99"
"reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/99e29d3596b16dabe4982548527d5ddf90232e99",
"reference": "99e29d3596b16dabe4982548527d5ddf90232e99",
"url": "https://api.github.com/repos/mockery/mockery/zipball/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"shasum": ""
},
"require": {
@@ -279,8 +348,7 @@
"php": ">=5.6.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "^2.9",
"phpunit/phpunit": "~5.7.10|~6.5"
"phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0"
},
"type": "library",
"extra": {
@@ -323,16 +391,17 @@
"test double",
"testing"
],
"time": "2018-05-08T08:54:48+00:00"
"time": "2019-02-13T09:37:52+00:00"
}
],
"aliases": [],
"minimum-stability": "alpha",
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.1"
"php": "^7.1",
"ext-filter": "^7.1"
},
"platform-dev": []
}
+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() : '');
}
}
+6 -10
View File
@@ -20,7 +20,6 @@ use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use Webmozart\Assert\Assert;
use function array_filter;
use function array_shift;
use function count;
use function explode;
@@ -100,12 +99,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
return new DocBlock(
$summary,
$description ? $this->descriptionFactory->create($description, $context) : null,
array_filter(
$this->parseTagBlock($tags, $context),
static function ($tag) {
return $tag instanceof Tag;
}
),
$this->parseTagBlock($tags, $context),
$context,
$location,
$templateMarker === '#@+',
@@ -240,12 +234,14 @@ final class DocBlockFactory implements DocBlockFactoryInterface
}
$result = [];
$lines = $this->splitTagBlockIntoTagLines($tags);
$lines = $this->splitTagBlockIntoTagLines($tags);
foreach ($lines as $key => $tagLine) {
$tag = $this->tagFactory->create(trim($tagLine), $context);
if ($tag instanceof Tag) {
$result[$key] = $tag;
if (!($tag instanceof Tag)) {
continue;
}
$result[$key] = $tag;
}
return $result;