diff --git a/.gitignore b/.gitignore index dab6983..d41552f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ /tools /tests/tmp /vendor -composer.lock +/composer.lock .phpunit.result.cache diff --git a/build-cs/composer.json b/build-cs/composer.json index 0ad2802..d10b56a 100644 --- a/build-cs/composer.json +++ b/build-cs/composer.json @@ -5,7 +5,7 @@ "require-dev": { "consistence-community/coding-standard": "^3.11", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", - "slevomat/coding-standard": "^6.4.1" + "slevomat/coding-standard": "^7.0.0" }, "config": { "allow-plugins": { diff --git a/build-cs/composer.lock b/build-cs/composer.lock index da571ce..03d1eb0 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -4,35 +4,35 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b33744523e2d619e22ae3fd7c30f4283", + "content-hash": "e864762ae0c59b5c172d16fa0bea7f70", "packages": [], "packages-dev": [ { "name": "consistence-community/coding-standard", - "version": "3.11.0", + "version": "3.11.1", "source": { "type": "git", "url": "https://github.com/consistence-community/coding-standard.git", - "reference": "20f5c3673013be606a62ba0b6624f5c0e43bb64e" + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/20f5c3673013be606a62ba0b6624f5c0e43bb64e", - "reference": "20f5c3673013be606a62ba0b6624f5c0e43bb64e", + "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df", "shasum": "" }, "require": { "php": ">=7.4", - "slevomat/coding-standard": "~6.4", - "squizlabs/php_codesniffer": "~3.5.8" + "slevomat/coding-standard": "~7.0", + "squizlabs/php_codesniffer": "~3.6.0" }, "replace": { "consistence/coding-standard": "3.10.*" }, "require-dev": { "phing/phing": "2.16.4", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpunit/phpunit": "9.5.2" + "php-parallel-lint/php-parallel-lint": "1.3.0", + "phpunit/phpunit": "9.5.4" }, "type": "library", "autoload": { @@ -69,9 +69,10 @@ "standard" ], "support": { - "source": "https://github.com/consistence-community/coding-standard/tree/3.11.0" + "issues": "https://github.com/consistence-community/coding-standard/issues", + "source": "https://github.com/consistence-community/coding-standard/tree/3.11.1" }, - "time": "2021-02-28T08:38:12+00:00" + "time": "2021-05-03T18:13:22+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -150,37 +151,33 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "0.4.9", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531" + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531", - "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/dbc093d7af60eff5cd575d2ed761b15ed40bd08e", + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "consistence/coding-standard": "^3.5", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "phing/phing": "^2.16.0", + "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.26", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^4.7.2", - "symfony/process": "^4.0" + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "0.4-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -197,43 +194,43 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/master" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.2.0" }, - "time": "2020-08-03T20:32:43+00:00" + "time": "2021-09-16T20:46:02+00:00" }, { "name": "slevomat/coding-standard", - "version": "6.4.1", + "version": "7.0.18", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "696dcca217d0c9da2c40d02731526c1e25b65346" + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346", - "reference": "696dcca217d0c9da2c40d02731526c1e25b65346", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.1 || ^8.0", - "phpstan/phpdoc-parser": "0.4.5 - 0.4.9", - "squizlabs/php_codesniffer": "^3.5.6" + "phpstan/phpdoc-parser": "^1.0.0", + "squizlabs/php_codesniffer": "^3.6.1" }, "require-dev": { - "phing/phing": "2.16.3", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpstan/phpstan": "0.12.48", - "phpstan/phpstan-deprecation-rules": "0.12.5", - "phpstan/phpstan-phpunit": "0.12.16", - "phpstan/phpstan-strict-rules": "0.12.5", - "phpunit/phpunit": "7.5.20|8.5.5|9.4.0" + "phing/phing": "2.17.0", + "php-parallel-lint/php-parallel-lint": "1.3.1", + "phpstan/phpstan": "1.2.0", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0", + "phpstan/phpstan-strict-rules": "1.1.0", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.10" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "6.x-dev" + "dev-master": "7.x-dev" } }, "autoload": { @@ -248,7 +245,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/6.4.1" + "source": "https://github.com/slevomat/coding-standard/tree/7.0.18" }, "funding": [ { @@ -260,20 +257,20 @@ "type": "tidelift" } ], - "time": "2020-10-05T12:39:37+00:00" + "time": "2021-12-07T17:19:06+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.8", + "version": "3.6.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", "shasum": "" }, "require": { @@ -316,7 +313,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2020-10-23T02:01:07+00:00" + "time": "2021-12-12T21:44:58+00:00" } ], "aliases": [], diff --git a/phpcs.xml b/phpcs.xml index f50b458..2edcd2d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,5 @@ - + @@ -9,47 +9,71 @@ src tests + - + - + - - + + + + - + - + + + + 10 + + + + + + 10 + + + + 10 + + + + - - - + + + - - + + + + + + @@ -58,11 +82,31 @@ + + + + + + + + + + + + + + + + + + + + + + + tests/*/data - tests/*/traits - tests/notAutoloaded - src/Reflection/SignatureMap/functionMap.php diff --git a/src/Ast/ConstExpr/ConstExprArrayNode.php b/src/Ast/ConstExpr/ConstExprArrayNode.php index 82135ef..1f9def3 100644 --- a/src/Ast/ConstExpr/ConstExprArrayNode.php +++ b/src/Ast/ConstExpr/ConstExprArrayNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class ConstExprArrayNode implements ConstExprNode { diff --git a/src/Ast/Node.php b/src/Ast/Node.php index faa3f7e..51a1a19 100644 --- a/src/Ast/Node.php +++ b/src/Ast/Node.php @@ -8,7 +8,6 @@ interface Node public function __toString(): string; /** - * @param string $key * @param mixed $value */ public function setAttribute(string $key, $value): void; @@ -16,7 +15,6 @@ interface Node public function hasAttribute(string $key): bool; /** - * @param string $key * @return mixed */ public function getAttribute(string $key); diff --git a/src/Ast/NodeAttributes.php b/src/Ast/NodeAttributes.php index 711d6ba..3da1779 100644 --- a/src/Ast/NodeAttributes.php +++ b/src/Ast/NodeAttributes.php @@ -2,6 +2,8 @@ namespace PHPStan\PhpDocParser\Ast; +use function array_key_exists; + trait NodeAttributes { @@ -9,7 +11,6 @@ trait NodeAttributes private $attributes = []; /** - * @param string $key * @param mixed $value */ public function setAttribute(string $key, $value): void @@ -23,7 +24,6 @@ trait NodeAttributes } /** - * @param string $key * @return mixed */ public function getAttribute(string $key) diff --git a/src/Ast/PhpDoc/DeprecatedTagValueNode.php b/src/Ast/PhpDoc/DeprecatedTagValueNode.php index b05368e..abf2f1a 100644 --- a/src/Ast/PhpDoc/DeprecatedTagValueNode.php +++ b/src/Ast/PhpDoc/DeprecatedTagValueNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; class DeprecatedTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/ExtendsTagValueNode.php b/src/Ast/PhpDoc/ExtendsTagValueNode.php index 4ee842f..3bf53e1 100644 --- a/src/Ast/PhpDoc/ExtendsTagValueNode.php +++ b/src/Ast/PhpDoc/ExtendsTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; class ExtendsTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/ImplementsTagValueNode.php b/src/Ast/PhpDoc/ImplementsTagValueNode.php index e2b1163..99043d9 100644 --- a/src/Ast/PhpDoc/ImplementsTagValueNode.php +++ b/src/Ast/PhpDoc/ImplementsTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; class ImplementsTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/InvalidTagValueNode.php b/src/Ast/PhpDoc/InvalidTagValueNode.php index a496e8e..1bcf226 100644 --- a/src/Ast/PhpDoc/InvalidTagValueNode.php +++ b/src/Ast/PhpDoc/InvalidTagValueNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Parser\ParserException; class InvalidTagValueNode implements PhpDocTagValueNode { @@ -12,10 +13,10 @@ class InvalidTagValueNode implements PhpDocTagValueNode /** @var string (may be empty) */ public $value; - /** @var \PHPStan\PhpDocParser\Parser\ParserException */ + /** @var ParserException */ public $exception; - public function __construct(string $value, \PHPStan\PhpDocParser\Parser\ParserException $exception) + public function __construct(string $value, ParserException $exception) { $this->value = $value; $this->exception = $exception; diff --git a/src/Ast/PhpDoc/MethodTagValueNode.php b/src/Ast/PhpDoc/MethodTagValueNode.php index ec509a1..155897b 100644 --- a/src/Ast/PhpDoc/MethodTagValueNode.php +++ b/src/Ast/PhpDoc/MethodTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function implode; class MethodTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/MixinTagValueNode.php b/src/Ast/PhpDoc/MixinTagValueNode.php index 8761ca4..d9b7d78 100644 --- a/src/Ast/PhpDoc/MixinTagValueNode.php +++ b/src/Ast/PhpDoc/MixinTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class MixinTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/ParamTagValueNode.php b/src/Ast/PhpDoc/ParamTagValueNode.php index fce87c3..f93af0e 100644 --- a/src/Ast/PhpDoc/ParamTagValueNode.php +++ b/src/Ast/PhpDoc/ParamTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class ParamTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/PhpDocNode.php b/src/Ast/PhpDoc/PhpDocNode.php index e3b4cfa..566f7df 100644 --- a/src/Ast/PhpDoc/PhpDocNode.php +++ b/src/Ast/PhpDoc/PhpDocNode.php @@ -4,6 +4,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function array_column; +use function array_filter; +use function array_map; +use function implode; class PhpDocNode implements Node { @@ -34,7 +38,6 @@ class PhpDocNode implements Node /** - * @param string $tagName * @return PhpDocTagNode[] */ public function getTagsByName(string $tagName): array diff --git a/src/Ast/PhpDoc/PhpDocTagNode.php b/src/Ast/PhpDoc/PhpDocTagNode.php index f847d19..856cc3f 100644 --- a/src/Ast/PhpDoc/PhpDocTagNode.php +++ b/src/Ast/PhpDoc/PhpDocTagNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; class PhpDocTagNode implements PhpDocChildNode { diff --git a/src/Ast/PhpDoc/PropertyTagValueNode.php b/src/Ast/PhpDoc/PropertyTagValueNode.php index b2cdbb1..046003d 100644 --- a/src/Ast/PhpDoc/PropertyTagValueNode.php +++ b/src/Ast/PhpDoc/PropertyTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class PropertyTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/ReturnTagValueNode.php b/src/Ast/PhpDoc/ReturnTagValueNode.php index 2b8a184..d53c8c7 100644 --- a/src/Ast/PhpDoc/ReturnTagValueNode.php +++ b/src/Ast/PhpDoc/ReturnTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class ReturnTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/TemplateTagValueNode.php b/src/Ast/PhpDoc/TemplateTagValueNode.php index 4a8f415..1595956 100644 --- a/src/Ast/PhpDoc/TemplateTagValueNode.php +++ b/src/Ast/PhpDoc/TemplateTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class TemplateTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/ThrowsTagValueNode.php b/src/Ast/PhpDoc/ThrowsTagValueNode.php index 67d0590..62d2aed 100644 --- a/src/Ast/PhpDoc/ThrowsTagValueNode.php +++ b/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class ThrowsTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php b/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php index 819f05b..ad6b85a 100644 --- a/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php +++ b/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; +use function trim; class TypeAliasImportTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/TypeAliasTagValueNode.php b/src/Ast/PhpDoc/TypeAliasTagValueNode.php index 21fbb06..4ccaaac 100644 --- a/src/Ast/PhpDoc/TypeAliasTagValueNode.php +++ b/src/Ast/PhpDoc/TypeAliasTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class TypeAliasTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/UsesTagValueNode.php b/src/Ast/PhpDoc/UsesTagValueNode.php index 0a641d1..cd573d9 100644 --- a/src/Ast/PhpDoc/UsesTagValueNode.php +++ b/src/Ast/PhpDoc/UsesTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; class UsesTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/PhpDoc/VarTagValueNode.php b/src/Ast/PhpDoc/VarTagValueNode.php index dc06202..afb941a 100644 --- a/src/Ast/PhpDoc/VarTagValueNode.php +++ b/src/Ast/PhpDoc/VarTagValueNode.php @@ -4,6 +4,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; class VarTagValueNode implements PhpDocTagValueNode { diff --git a/src/Ast/Type/ArrayShapeItemNode.php b/src/Ast/Type/ArrayShapeItemNode.php index e8a78f3..660c6c9 100644 --- a/src/Ast/Type/ArrayShapeItemNode.php +++ b/src/Ast/Type/ArrayShapeItemNode.php @@ -5,6 +5,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; class ArrayShapeItemNode implements TypeNode { diff --git a/src/Ast/Type/ArrayShapeNode.php b/src/Ast/Type/ArrayShapeNode.php index 094aaa1..38d64dd 100644 --- a/src/Ast/Type/ArrayShapeNode.php +++ b/src/Ast/Type/ArrayShapeNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class ArrayShapeNode implements TypeNode { diff --git a/src/Ast/Type/CallableTypeNode.php b/src/Ast/Type/CallableTypeNode.php index 6faa4cd..83ade94 100644 --- a/src/Ast/Type/CallableTypeNode.php +++ b/src/Ast/Type/CallableTypeNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class CallableTypeNode implements TypeNode { diff --git a/src/Ast/Type/GenericTypeNode.php b/src/Ast/Type/GenericTypeNode.php index 399e562..6bb704d 100644 --- a/src/Ast/Type/GenericTypeNode.php +++ b/src/Ast/Type/GenericTypeNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class GenericTypeNode implements TypeNode { diff --git a/src/Ast/Type/IntersectionTypeNode.php b/src/Ast/Type/IntersectionTypeNode.php index e9ebf52..7f9aff3 100644 --- a/src/Ast/Type/IntersectionTypeNode.php +++ b/src/Ast/Type/IntersectionTypeNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class IntersectionTypeNode implements TypeNode { diff --git a/src/Ast/Type/UnionTypeNode.php b/src/Ast/Type/UnionTypeNode.php index 58195c6..08acf56 100644 --- a/src/Ast/Type/UnionTypeNode.php +++ b/src/Ast/Type/UnionTypeNode.php @@ -3,6 +3,7 @@ namespace PHPStan\PhpDocParser\Ast\Type; use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; class UnionTypeNode implements TypeNode { diff --git a/src/Lexer/Lexer.php b/src/Lexer/Lexer.php index 1caf7cf..e759cd5 100644 --- a/src/Lexer/Lexer.php +++ b/src/Lexer/Lexer.php @@ -2,6 +2,13 @@ namespace PHPStan\PhpDocParser\Lexer; +use function array_keys; +use function assert; +use function count; +use function implode; +use function preg_match_all; +use const PREG_SET_ORDER; + /** * Implementation based on Nette Tokenizer (New BSD License; https://github.com/nette/tokenizer) */ diff --git a/src/Parser/ConstExprParser.php b/src/Parser/ConstExprParser.php index d9dd9df..8a466ac 100644 --- a/src/Parser/ConstExprParser.php +++ b/src/Parser/ConstExprParser.php @@ -2,8 +2,11 @@ namespace PHPStan\PhpDocParser\Parser; +use LogicException; use PHPStan\PhpDocParser\Ast; use PHPStan\PhpDocParser\Lexer\Lexer; +use function strtolower; +use function trim; class ConstExprParser { @@ -95,7 +98,7 @@ class ConstExprParser return $this->parseArray($tokens, Lexer::TOKEN_CLOSE_SQUARE_BRACKET); } - throw new \LogicException($tokens->currentTokenValue()); + throw new LogicException($tokens->currentTokenValue()); } diff --git a/src/Parser/ParserException.php b/src/Parser/ParserException.php index d6fd6fe..d3f35b9 100644 --- a/src/Parser/ParserException.php +++ b/src/Parser/ParserException.php @@ -2,9 +2,15 @@ namespace PHPStan\PhpDocParser\Parser; +use Exception; use PHPStan\PhpDocParser\Lexer\Lexer; +use function assert; +use function json_encode; +use function sprintf; +use const JSON_UNESCAPED_SLASHES; +use const JSON_UNESCAPED_UNICODE; -class ParserException extends \Exception +class ParserException extends Exception { /** @var string */ diff --git a/src/Parser/PhpDocParser.php b/src/Parser/PhpDocParser.php index 746efa2..8d4573a 100644 --- a/src/Parser/PhpDocParser.php +++ b/src/Parser/PhpDocParser.php @@ -5,6 +5,10 @@ namespace PHPStan\PhpDocParser\Parser; use PHPStan\PhpDocParser\Ast; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use PHPStan\PhpDocParser\Lexer\Lexer; +use PHPStan\ShouldNotHappenException; +use function array_values; +use function count; +use function trim; class PhpDocParser { @@ -43,7 +47,7 @@ class PhpDocParser try { $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC); - } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { + } catch (ParserException $e) { $name = ''; if (count($children) > 0) { $lastChild = $children[count($children) - 1]; @@ -208,7 +212,7 @@ class PhpDocParser $tokens->dropSavePoint(); - } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { + } catch (ParserException $e) { $tokens->rollback(); $tagValue = new Ast\PhpDoc\InvalidTagValueNode($this->parseOptionalDescription($tokens), $e); } @@ -374,7 +378,7 @@ class PhpDocParser return new Ast\PhpDoc\UsesTagValueNode($type, $description); } - throw new \PHPStan\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } private function parseTypeAliasTagValue(TokenIterator $tokens): Ast\PhpDoc\TypeAliasTagValueNode @@ -396,7 +400,7 @@ class PhpDocParser $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); if (!$tokens->tryConsumeTokenValue('from')) { - throw new \PHPStan\PhpDocParser\Parser\ParserException( + throw new ParserException( $tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), diff --git a/src/Parser/TokenIterator.php b/src/Parser/TokenIterator.php index 410251a..1e73223 100644 --- a/src/Parser/TokenIterator.php +++ b/src/Parser/TokenIterator.php @@ -3,6 +3,11 @@ namespace PHPStan\PhpDocParser\Parser; use PHPStan\PhpDocParser\Lexer\Lexer; +use function array_pop; +use function assert; +use function count; +use function in_array; +use function strlen; class TokenIterator { @@ -71,8 +76,7 @@ class TokenIterator /** - * @param int $tokenType - * @throws \PHPStan\PhpDocParser\Parser\ParserException + * @throws ParserException */ public function consumeTokenType(int $tokenType): void { @@ -185,12 +189,11 @@ class TokenIterator /** - * @param int $expectedTokenType - * @throws \PHPStan\PhpDocParser\Parser\ParserException + * @throws ParserException */ private function throwError(int $expectedTokenType): void { - throw new \PHPStan\PhpDocParser\Parser\ParserException( + throw new ParserException( $this->currentTokenValue(), $this->currentTokenType(), $this->currentTokenOffset(), diff --git a/src/Parser/TypeParser.php b/src/Parser/TypeParser.php index 5492a39..dcbc71d 100644 --- a/src/Parser/TypeParser.php +++ b/src/Parser/TypeParser.php @@ -2,8 +2,11 @@ namespace PHPStan\PhpDocParser\Parser; +use LogicException; use PHPStan\PhpDocParser\Ast; use PHPStan\PhpDocParser\Lexer\Lexer; +use function strpos; +use function trim; class TypeParser { @@ -104,7 +107,7 @@ class TypeParser $tokens->dropSavePoint(); // because of ConstFetchNode } - $exception = new \PHPStan\PhpDocParser\Parser\ParserException( + $exception = new ParserException( $tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), @@ -122,7 +125,7 @@ class TypeParser } return new Ast\Type\ConstTypeNode($constExpr); - } catch (\LogicException $e) { + } catch (LogicException $e) { throw $exception; } } @@ -312,7 +315,7 @@ class TypeParser $type = $this->parseCallable($tokens, $identifier); $tokens->dropSavePoint(); - } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { + } catch (ParserException $e) { $tokens->rollback(); $type = $identifier; } @@ -333,7 +336,7 @@ class TypeParser $type = new Ast\Type\ArrayTypeNode($type); } - } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { + } catch (ParserException $e) { $tokens->rollback(); } @@ -383,7 +386,7 @@ class TypeParser $tokens->dropSavePoint(); return new Ast\Type\ArrayShapeItemNode($key, $optional, $value); - } catch (\PHPStan\PhpDocParser\Parser\ParserException $e) { + } catch (ParserException $e) { $tokens->rollback(); $value = $this->parse($tokens); diff --git a/tests/PHPStan/Ast/PhpDoc/NodePrintTest.php b/tests/PHPStan/Ast/PhpDoc/NodePrintTest.php index ab04779..db39bf3 100644 --- a/tests/PHPStan/Ast/PhpDoc/NodePrintTest.php +++ b/tests/PHPStan/Ast/PhpDoc/NodePrintTest.php @@ -2,6 +2,7 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use Iterator; use PHPStan\PhpDocParser\Ast\Node; use PHPUnit\Framework\TestCase; @@ -17,7 +18,7 @@ final class NodePrintTest extends TestCase } - public function providePhpDocData(): \Iterator + public function providePhpDocData(): Iterator { yield [ new PhpDocNode([ diff --git a/tests/PHPStan/Parser/ConstExprParserTest.php b/tests/PHPStan/Parser/ConstExprParserTest.php index 425882f..0084419 100644 --- a/tests/PHPStan/Parser/ConstExprParserTest.php +++ b/tests/PHPStan/Parser/ConstExprParserTest.php @@ -14,8 +14,9 @@ use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; use PHPStan\PhpDocParser\Lexer\Lexer; +use PHPUnit\Framework\TestCase; -class ConstExprParserTest extends \PHPUnit\Framework\TestCase +class ConstExprParserTest extends TestCase { /** @var Lexer */ @@ -41,9 +42,6 @@ class ConstExprParserTest extends \PHPUnit\Framework\TestCase * @dataProvider provideStringNodeParseData * @dataProvider provideArrayNodeParseData * @dataProvider provideFetchNodeParseData - * @param string $input - * @param ConstExprNode $expectedExpr - * @param int $nextTokenType */ public function testParse(string $input, ConstExprNode $expectedExpr, int $nextTokenType = Lexer::TOKEN_END): void { diff --git a/tests/PHPStan/Parser/FuzzyTest.php b/tests/PHPStan/Parser/FuzzyTest.php index 6b613d7..d2e7a45 100644 --- a/tests/PHPStan/Parser/FuzzyTest.php +++ b/tests/PHPStan/Parser/FuzzyTest.php @@ -4,9 +4,16 @@ namespace PHPStan\PhpDocParser\Parser; use Iterator; use PHPStan\PhpDocParser\Lexer\Lexer; +use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; +use function file_get_contents; +use function glob; +use function is_dir; +use function mkdir; +use function sprintf; +use function unlink; -class FuzzyTest extends \PHPUnit\Framework\TestCase +class FuzzyTest extends TestCase { /** @var Lexer */ @@ -28,7 +35,6 @@ class FuzzyTest extends \PHPUnit\Framework\TestCase /** * @dataProvider provideTypeParserData - * @param string $input */ public function testTypeParser(string $input): void { @@ -49,7 +55,6 @@ class FuzzyTest extends \PHPUnit\Framework\TestCase /** * @dataProvider provideConstExprParserData - * @param string $input */ public function testConstExprParser(string $input): void { diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index 6a9b19d..16af55c 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -2,6 +2,7 @@ namespace PHPStan\PhpDocParser\Parser; +use Iterator; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; @@ -35,8 +36,10 @@ use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; use PHPStan\PhpDocParser\Lexer\Lexer; +use PHPUnit\Framework\TestCase; +use const PHP_EOL; -class PhpDocParserTest extends \PHPUnit\Framework\TestCase +class PhpDocParserTest extends TestCase { /** @var Lexer */ @@ -72,10 +75,6 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase * @dataProvider provideTypeAliasImportTagsData * @dataProvider provideRealWorldExampleData * @dataProvider provideDescriptionWithOrWithoutHtml - * @param string $label - * @param string $input - * @param PhpDocNode $expectedPhpDocNode - * @param int $nextTokenType */ public function testParse(string $label, string $input, PhpDocNode $expectedPhpDocNode, int $nextTokenType = Lexer::TOKEN_END): void { @@ -88,7 +87,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase } - public function provideParamTagsData(): \Iterator + public function provideParamTagsData(): Iterator { yield [ 'OK without description', @@ -246,7 +245,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase '@param', new InvalidTagValueNode( '', - new \PHPStan\PhpDocParser\Parser\ParserException( + new ParserException( '*/', Lexer::TOKEN_CLOSE_PHPDOC, 11, @@ -265,7 +264,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase '@param', new InvalidTagValueNode( '#desc', - new \PHPStan\PhpDocParser\Parser\ParserException( + new ParserException( '#desc', Lexer::TOKEN_OTHER, 11, @@ -284,7 +283,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase '@param', new InvalidTagValueNode( '(Foo', - new \PHPStan\PhpDocParser\Parser\ParserException( + new ParserException( '*/', Lexer::TOKEN_CLOSE_PHPDOC, 16, @@ -303,7 +302,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase '@param', new InvalidTagValueNode( '(Foo $foo', - new \PHPStan\PhpDocParser\Parser\ParserException( + new ParserException( '$foo', Lexer::TOKEN_VARIABLE, 16, @@ -322,7 +321,7 @@ class PhpDocParserTest extends \PHPUnit\Framework\TestCase '@param', new InvalidTagValueNode( 'Foo