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", "name": "Mike van Riel",
"email": "[email protected]" "email": "[email protected]"
},
{
"name": "Jaap van Otterdijk",
"email": "[email protected]"
} }
], ],
"minimum-stability": "alpha",
"require": { "require": {
"php": ">=7.1", "php": "^7.1",
"phpdocumentor/type-resolver": "^0", "phpdocumentor/type-resolver": "^1.0",
"webmozart/assert": "^1" "webmozart/assert": "^1",
"phpdocumentor/reflection-common": "^2.0",
"ext-filter": "^7.1"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1", "mockery/mockery": "^1",
Generated
+117 -48
View File
@@ -1,30 +1,30 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "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" "This file is @generated automatically"
], ],
"content-hash": "cb7ecdcb52e627755275cf273bcdd249", "content-hash": "93c5a8174b30802326730535c6b1479f",
"packages": [ "packages": [
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
"version": "2.0.0-alpha3", "version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "eedd98e8bc9cfd924f056b4b5847066d4a250d2f" "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/eedd98e8bc9cfd924f056b4b5847066d4a250d2f", "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a",
"reference": "eedd98e8bc9cfd924f056b4b5847066d4a250d2f", "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1" "php": ">=7.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6" "phpunit/phpunit": "~6"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@@ -34,9 +34,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"phpDocumentor\\Reflection\\": [ "phpDocumentor\\Reflection\\": "src/"
"src"
]
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@@ -58,34 +56,35 @@
"reflection", "reflection",
"static analysis" "static analysis"
], ],
"time": "2018-06-13T21:44:20+00:00" "time": "2018-08-07T13:53:10+00:00"
}, },
{ {
"name": "phpdocumentor/type-resolver", "name": "phpdocumentor/type-resolver",
"version": "0.6.2", "version": "1.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git", "url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e81ce9e82df06b49b2d0e0a2393a08955aeda05b" "reference": "4dfca962ce4d6c11ae17efcc65621cc4b22004c7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e81ce9e82df06b49b2d0e0a2393a08955aeda05b", "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/4dfca962ce4d6c11ae17efcc65621cc4b22004c7",
"reference": "e81ce9e82df06b49b2d0e0a2393a08955aeda05b", "reference": "4dfca962ce4d6c11ae17efcc65621cc4b22004c7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1", "php": "^7.1",
"phpdocumentor/reflection-common": "^2" "phpdocumentor/reflection-common": "^2.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.0", "ext-tokenizer": "^7.1",
"phpunit/phpunit": "^6.5" "mockery/mockery": "~1",
"phpunit/phpunit": "^7.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.x-dev" "dev-master": "1.x-dev"
} }
}, },
"autoload": { "autoload": {
@@ -93,7 +92,11 @@
"phpDocumentor\\Reflection\\": "src" "phpDocumentor\\Reflection\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "autoload-dev": {
"psr-4": {
"phpDocumentor\\Reflection\\": "tests/unit"
}
},
"license": [ "license": [
"MIT" "MIT"
], ],
@@ -103,24 +106,88 @@
"email": "[email protected]" "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", "name": "symfony/polyfill-ctype",
"version": "1.3.0", "version": "v1.11.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/webmozart/assert.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "0df1908962e7a3071564e857d86874dad1ef204a" "reference": "82ebae02209c21113908c229e9883c419720738a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "0df1908962e7a3071564e857d86874dad1ef204a", "reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": "" "shasum": ""
}, },
"require": { "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": { "require-dev": {
"phpunit/phpunit": "^4.6", "phpunit/phpunit": "^4.6",
@@ -153,33 +220,35 @@
"check", "check",
"validate" "validate"
], ],
"time": "2018-01-29T19:49:41+00:00" "time": "2018-12-25T11:19:39+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
"version": "1.1.0", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/instantiator.git", "url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" "reference": "a2c590166b2133a4633738648b6b064edae0814a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"athletic/athletic": "~0.1.8", "doctrine/coding-standard": "^6.0",
"ext-pdo": "*", "ext-pdo": "*",
"ext-phar": "*", "ext-phar": "*",
"phpunit/phpunit": "^6.2.3", "phpbench/phpbench": "^0.13",
"squizlabs/php_codesniffer": "^3.0.2" "phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@@ -204,12 +273,12 @@
} }
], ],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", "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": [ "keywords": [
"constructor", "constructor",
"instantiate" "instantiate"
], ],
"time": "2017-07-22T11:58:36+00:00" "time": "2019-03-17T17:37:11+00:00"
}, },
{ {
"name": "hamcrest/hamcrest-php", "name": "hamcrest/hamcrest-php",
@@ -261,16 +330,16 @@
}, },
{ {
"name": "mockery/mockery", "name": "mockery/mockery",
"version": "1.1.0", "version": "1.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mockery/mockery.git", "url": "https://github.com/mockery/mockery.git",
"reference": "99e29d3596b16dabe4982548527d5ddf90232e99" "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/99e29d3596b16dabe4982548527d5ddf90232e99", "url": "https://api.github.com/repos/mockery/mockery/zipball/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"reference": "99e29d3596b16dabe4982548527d5ddf90232e99", "reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -279,8 +348,7 @@
"php": ">=5.6.0" "php": ">=5.6.0"
}, },
"require-dev": { "require-dev": {
"phpdocumentor/phpdocumentor": "^2.9", "phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0"
"phpunit/phpunit": "~5.7.10|~6.5"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@@ -323,16 +391,17 @@
"test double", "test double",
"testing" "testing"
], ],
"time": "2018-05-08T08:54:48+00:00" "time": "2019-02-13T09:37:52+00:00"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "alpha", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": [],
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=7.1" "php": "^7.1",
"ext-filter": "^7.1"
}, },
"platform-dev": [] "platform-dev": []
} }
+26 -23
View File
@@ -14,8 +14,25 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock; namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException; 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\Factory\StaticMethod;
use phpDocumentor\Reflection\DocBlock\Tags\Generic; 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\FqsenResolver;
use phpDocumentor\Reflection\Types\Context as TypeContext; use phpDocumentor\Reflection\Types\Context as TypeContext;
use ReflectionMethod; use ReflectionMethod;
@@ -28,23 +45,6 @@ use function count;
use function get_class; use function get_class;
use function preg_match; use function preg_match;
use function strpos; 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. * Creates a Tag object given the contents of a tag.
@@ -77,14 +77,14 @@ final class StandardTagFactory implements TagFactory
'covers' => Covers::class, 'covers' => Covers::class,
'deprecated' => Deprecated::class, 'deprecated' => Deprecated::class,
// 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example', // 'example' => '\phpDocumentor\Reflection\DocBlock\Tags\Example',
'link' => Link::class, 'link' => LinkTag::class,
'method' => Method::class, 'method' => Method::class,
'param' => Param::class, 'param' => Param::class,
'property-read' => PropertyRead::class, 'property-read' => PropertyRead::class,
'property' => Property::class, 'property' => Property::class,
'property-write' => PropertyWrite::class, 'property-write' => PropertyWrite::class,
'return' => Return_::class, 'return' => Return_::class,
'see' => See::class, 'see' => SeeTag::class,
'since' => Since::class, 'since' => Since::class,
'source' => Source::class, 'source' => Source::class,
'throw' => Throws::class, 'throw' => Throws::class,
@@ -166,7 +166,7 @@ final class StandardTagFactory implements TagFactory
/** /**
* {@inheritDoc} * {@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; $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`). * 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 private function findHandlerClassName(string $tagName, TypeContext $context) : string
{ {
@@ -264,7 +262,12 @@ final class StandardTagFactory implements TagFactory
{ {
$arguments = []; $arguments = [];
foreach ($parameters as $parameter) { 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])) { if (isset($locator[$typeHint])) {
$arguments[] = $locator[$typeHint]; $arguments[] = $locator[$typeHint];
continue; continue;
+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[][] * @return mixed[][]
*/ */
-1
View File
@@ -23,7 +23,6 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift; use function array_shift;
use function implode; use function implode;
use function preg_split; use function preg_split;
use function strlen;
use function strpos; use function strpos;
use function substr; use function substr;
+1 -1
View File
@@ -23,7 +23,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift; use function array_shift;
use function implode; use function implode;
use function preg_split; use function preg_split;
use function strlen; use function strpos;
use function substr; use function substr;
/** /**
+2 -2
View File
@@ -23,7 +23,7 @@ use const PREG_SPLIT_DELIM_CAPTURE;
use function array_shift; use function array_shift;
use function implode; use function implode;
use function preg_split; use function preg_split;
use function strlen; use function strpos;
use function substr; use function substr;
/** /**
@@ -111,7 +111,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
public function __toString() : string public function __toString() : string
{ {
return ($this->type ? $this->type . ' ' : '') return ($this->type ? $this->type . ' ' : '')
. (empty($this->variableName) ? null : ('$' . $this->variableName)) . (empty($this->variableName) ? '' : ('$' . $this->variableName))
. ($this->description ? ' ' . $this->description : ''); . ($this->description ? ' ' . $this->description : '');
} }
} }
+2 -1
View File
@@ -92,6 +92,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
*/ */
public function __toString() : string public function __toString() : string
{ {
return $this->version . ($this->description ? ' ' . $this->description->render() : ''); return ((string) $this->version) .
($this->description instanceof Description ? ' ' . $this->description->render() : '');
} }
} }
+4 -8
View File
@@ -20,7 +20,6 @@ use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory; use phpDocumentor\Reflection\DocBlock\TagFactory;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
use function array_filter;
use function array_shift; use function array_shift;
use function count; use function count;
use function explode; use function explode;
@@ -100,12 +99,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
return new DocBlock( return new DocBlock(
$summary, $summary,
$description ? $this->descriptionFactory->create($description, $context) : null, $description ? $this->descriptionFactory->create($description, $context) : null,
array_filter(
$this->parseTagBlock($tags, $context), $this->parseTagBlock($tags, $context),
static function ($tag) {
return $tag instanceof Tag;
}
),
$context, $context,
$location, $location,
$templateMarker === '#@+', $templateMarker === '#@+',
@@ -243,9 +237,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
$lines = $this->splitTagBlockIntoTagLines($tags); $lines = $this->splitTagBlockIntoTagLines($tags);
foreach ($lines as $key => $tagLine) { foreach ($lines as $key => $tagLine) {
$tag = $this->tagFactory->create(trim($tagLine), $context); $tag = $this->tagFactory->create(trim($tagLine), $context);
if ($tag instanceof Tag) { if (!($tag instanceof Tag)) {
$result[$key] = $tag; continue;
} }
$result[$key] = $tag;
} }
return $result; return $result;