From 1b6f616cf9a3c4aadf8f288120b3cc01c3f69586 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sun, 12 Jan 2020 22:44:42 +0100 Subject: [PATCH] import names --- .github/workflows/code_checks.yml | 1 + docs/AllRectorsOverview.md | 3 +- .../AttributeAwareGenericTagValueNode.php | 8 +- .../AttributeAwareImplementsTagValueNode.php | 8 +- .../AttributeAwareInvalidTagValueNode.php | 8 +- .../AttributeAwareMethodTagValueNode.php | 8 +- ...ributeAwareMethodTagValueParameterNode.php | 8 +- .../AttributeAwareParamTagValueNode.php | 7 +- .../Ast/PhpDoc/AttributeAwarePhpDocNode.php | 6 +- .../PhpDoc/AttributeAwarePhpDocTagNode.php | 8 +- .../PhpDoc/AttributeAwarePhpDocTextNode.php | 8 +- .../AttributeAwarePropertyTagValueNode.php | 8 +- .../AttributeAwareReturnTagValueNode.php | 8 +- .../AttributeAwareTemplateTagValueNode.php | 8 +- .../AttributeAwareThrowsTagValueNode.php | 8 +- .../PhpDoc/AttributeAwareUsesTagValueNode.php | 8 +- .../PhpDoc/AttributeAwareVarTagValueNode.php | 8 +- .../Type/AttributeAwareArrayShapeItemNode.php | 8 +- .../Ast/Type/AttributeAwareArrayShapeNode.php | 8 +- .../Ast/Type/AttributeAwareArrayTypeNode.php | 8 +- .../Type/AttributeAwareCallableTypeNode.php | 8 +- ...ttributeAwareCallableTypeParameterNode.php | 8 +- .../Type/AttributeAwareGenericTypeNode.php | 8 +- .../Type/AttributeAwareIdentifierTypeNode.php | 8 +- .../AttributeAwareIntersectionTypeNode.php | 8 +- .../Type/AttributeAwareNullableTypeNode.php | 8 +- .../Ast/Type/AttributeAwareThisTypeNode.php | 8 +- .../Ast/Type/AttributeAwareUnionTypeNode.php | 8 +- ...buteAwareDeprecatedTagValueNodeFactory.php | 23 ++- ...tributeAwareExtendsTagValueNodeFactory.php | 40 ++-- ...tributeAwareGenericTagValueNodeFactory.php | 23 ++- ...buteAwareImplementsTagValueNodeFactory.php | 40 ++-- ...tributeAwareInvalidTagValueNodeFactory.php | 26 +-- ...wareMethodTagValueParameterNodeFactory.php | 39 +++- ...AttributeAwareParamTagValueNodeFactory.php | 40 +++- .../AttributeAwarePhpDocNodeFactory.php | 56 +++++- .../AttributeAwarePhpDocTagNodeFactory.php | 23 ++- .../AttributeAwarePhpDocTextNodeFactory.php | 23 ++- ...ributeAwarePropertyTagValueNodeFactory.php | 41 ++-- ...ttributeAwareReturnTagValueNodeFactory.php | 40 ++-- ...ributeAwareTemplateTagValueNodeFactory.php | 27 +-- ...ttributeAwareThrowsTagValueNodeFactory.php | 40 ++-- .../AttributeAwareUsesTagValueNodeFactory.php | 26 +-- .../AttributeAwareVarTagValueNodeFactory.php | 16 +- .../AttributeAwareArrayTypeNodeFactory.php | 16 +- .../AttributeAwareCallableTypeNodeFactory.php | 27 +-- .../AttributeAwareGenericTypeNodeFactory.php | 44 +++-- ...ttributeAwareIdentifierTypeNodeFactory.php | 23 ++- ...ributeAwareIntersectionTypeNodeFactory.php | 39 +++- .../AttributeAwareNullableTypeNodeFactory.php | 37 +++- .../AttributeAwareThisTypeNodeFactory.php | 23 ++- .../AttributeAwareUnionTypeNodeFactory.php | 39 +++- ...ttributeAwareNodeFactoryAwareInterface.php | 12 ++ ...wareNodeFactoryCollectorAwareInterface.php | 14 -- .../Ast/AttributeAwareNodeFactory.php | 183 ++---------------- .../Ast/AttributeAwareNodeFactoryTest.php | 2 - .../ChangeNestedIfsToEarlyReturnRector.php | 3 +- rector.yaml | 8 +- 58 files changed, 723 insertions(+), 479 deletions(-) create mode 100644 packages/AttributeAwarePhpDoc/src/Contract/AttributeNodeAwareFactory/AttributeAwareNodeFactoryAwareInterface.php delete mode 100644 packages/AttributeAwarePhpDoc/src/Contract/AttributeNodeAwareFactory/AttributeAwareNodeFactoryCollectorAwareInterface.php diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index e3ad484f151..7643e37b9cb 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -101,6 +101,7 @@ jobs: - run: | php ci/check_services_in_yaml_configs.php php ci/run_all_sets.php + bin/rector sync-types fatal_scan: runs-on: ubuntu-latest diff --git a/docs/AllRectorsOverview.md b/docs/AllRectorsOverview.md index 7015d2b1c3e..5e6531287e9 100644 --- a/docs/AllRectorsOverview.md +++ b/docs/AllRectorsOverview.md @@ -8252,8 +8252,7 @@ Change $this->getParam() calls to action method arguments + Sdd symfony @Route +public function someAction($id) { - $id = $this->getParam('id'); --} -+} + } ```
diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareGenericTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareGenericTagValueNode.php index 71034c4a5f3..d7c4706697f 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareGenericTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareGenericTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareGenericTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareGenericTagValueNode extends GenericTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareImplementsTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareImplementsTagValueNode.php index 04e0acefe72..9a3f4bfa5d1 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareImplementsTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareImplementsTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareImplementsTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareImplementsTagValueNode extends ImplementsTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareInvalidTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareInvalidTagValueNode.php index f6d2b716157..de1b80424b2 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareInvalidTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareInvalidTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareInvalidTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareInvalidTagValueNode extends InvalidTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueNode.php index 401e33e91ee..c4e8d0975b5 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareMethodTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareMethodTagValueNode extends MethodTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueParameterNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueParameterNode.php index 1fd14784b8e..dab8fc94011 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueParameterNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareMethodTagValueParameterNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareMethodTagValueParameterNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareMethodTagValueParameterNode extends MethodTagValueParameterNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareParamTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareParamTagValueNode.php index bf98fb122c1..2fba687c9ba 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareParamTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareParamTagValueNode.php @@ -4,11 +4,14 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; -final class AttributeAwareParamTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +final class AttributeAwareParamTagValueNode extends ParamTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; /** * @var bool diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocNode.php index 7d75b61afbd..3462ed12bcd 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocNode.php @@ -5,11 +5,13 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; -final class AttributeAwarePhpDocNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +final class AttributeAwarePhpDocNode extends PhpDocNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; /** * @var PhpDocChildNode[]|AttributeAwareNodeInterface[] diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTagNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTagNode.php index 97a7815d4ec..31a0e1ecc1d 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTagNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTagNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwarePhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePhpDocTagNode extends PhpDocTagNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTextNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTextNode.php index f3c8edd7ab7..0cf6855ec65 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTextNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePhpDocTextNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwarePhpDocTextNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePhpDocTextNode extends PhpDocTextNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePropertyTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePropertyTagValueNode.php index 22106ad0c4e..f937e72c384 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePropertyTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwarePropertyTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwarePropertyTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePropertyTagValueNode extends PropertyTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareReturnTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareReturnTagValueNode.php index 0cd657893a2..b0fd88f895d 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareReturnTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareReturnTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareReturnTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareReturnTagValueNode extends ReturnTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareTemplateTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareTemplateTagValueNode.php index 8e029888e12..a7ec2843ae6 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareTemplateTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareTemplateTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareTemplateTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareTemplateTagValueNode extends TemplateTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareThrowsTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareThrowsTagValueNode.php index dd6cff43a17..36491596ec7 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareThrowsTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareThrowsTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareThrowsTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareThrowsTagValueNode extends ThrowsTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareUsesTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareUsesTagValueNode.php index 9de8b426cf7..c96bcd354d2 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareUsesTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareUsesTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareUsesTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareUsesTagValueNode extends UsesTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareVarTagValueNode.php b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareVarTagValueNode.php index c16535759ec..e672894ce25 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareVarTagValueNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/PhpDoc/AttributeAwareVarTagValueNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\PhpDoc; -final class AttributeAwareVarTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareVarTagValueNode extends VarTagValueNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeItemNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeItemNode.php index f4e56ab576d..bc1a6105e1e 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeItemNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeItemNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareArrayShapeItemNode extends \PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\ArrayShapeItemNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareArrayShapeItemNode extends ArrayShapeItemNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeNode.php index f23cdab79b4..6d2a1c29aa5 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayShapeNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareArrayShapeNode extends \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareArrayShapeNode extends ArrayShapeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayTypeNode.php index 616721bfc9c..f86b1985419 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareArrayTypeNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareArrayTypeNode extends \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareArrayTypeNode extends ArrayTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeNode.php index fd136aa34cd..dc808a6218e 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeNode.php @@ -4,9 +4,13 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareCallableTypeNode extends \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareCallableTypeNode extends CallableTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; public function __toString(): string { diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeParameterNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeParameterNode.php index 80c2df9a9a0..a6c8b965227 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeParameterNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareCallableTypeParameterNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareCallableTypeParameterNode extends \PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\CallableTypeParameterNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareCallableTypeParameterNode extends CallableTypeParameterNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareGenericTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareGenericTypeNode.php index d5080294479..39543397a48 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareGenericTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareGenericTypeNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareGenericTypeNode extends \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareGenericTypeNode extends GenericTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIdentifierTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIdentifierTypeNode.php index 5d4f578f77a..b3fcff27663 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIdentifierTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIdentifierTypeNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareIdentifierTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareIdentifierTypeNode extends IdentifierTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIntersectionTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIntersectionTypeNode.php index 67df724715f..86287d7e756 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIntersectionTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareIntersectionTypeNode.php @@ -4,9 +4,13 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareIntersectionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareIntersectionTypeNode extends IntersectionTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; public function __toString(): string { diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareNullableTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareNullableTypeNode.php index 41ddd0ea93e..4e44dc44298 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareNullableTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareNullableTypeNode.php @@ -4,9 +4,13 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareNullableTypeNode extends \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\NullableTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareNullableTypeNode extends NullableTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; public function __toString(): string { diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareThisTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareThisTypeNode.php index 9ca464f9f76..375a142c610 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareThisTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareThisTypeNode.php @@ -4,7 +4,11 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareThisTypeNode extends \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareThisTypeNode extends ThisTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; } diff --git a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareUnionTypeNode.php b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareUnionTypeNode.php index ffec1d6e365..882741462dd 100644 --- a/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareUnionTypeNode.php +++ b/packages/AttributeAwarePhpDoc/src/Ast/Type/AttributeAwareUnionTypeNode.php @@ -4,9 +4,13 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\Ast\Type; -final class AttributeAwareUnionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode implements \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface +use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; +use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareUnionTypeNode extends UnionTypeNode implements AttributeAwareNodeInterface { - use \Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait; + use AttributeTrait; /** * Preserve common format diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareDeprecatedTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareDeprecatedTagValueNodeFactory.php index 37850e75396..9ff6275b6d6 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareDeprecatedTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareDeprecatedTagValueNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareDeprecatedTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareDeprecatedTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareDeprecatedTagValueNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode::class; + return DeprecatedTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode::class, true); + return is_a($node, DeprecatedTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode $node + * @param DeprecatedTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareDeprecatedTagValueNode($node->description); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareDeprecatedTagValueNode($node->description); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareExtendsTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareExtendsTagValueNodeFactory.php index ce6b58eede5..22b3f2484b9 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareExtendsTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareExtendsTagValueNodeFactory.php @@ -4,27 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareExtendsTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareExtendsTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareExtendsTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode::class; + return ExtendsTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode::class, true); + return is_a($node, ExtendsTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode $node + * @param ExtendsTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareExtendsTagValueNode( - $node->type, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareExtendsTagValueNode($node->type, $node->description); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareGenericTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareGenericTagValueNodeFactory.php index a7e1a3cdbe1..670c9e7969e 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareGenericTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareGenericTagValueNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareGenericTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareGenericTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareGenericTagValueNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode::class; + return GenericTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode::class, true); + return is_a($node, GenericTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode $node + * @param GenericTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareGenericTagValueNode($node->value); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareGenericTagValueNode($node->value); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareImplementsTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareImplementsTagValueNodeFactory.php index 19b10273cf9..7c4400f0006 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareImplementsTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareImplementsTagValueNodeFactory.php @@ -4,27 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareImplementsTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareImplementsTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareImplementsTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode::class; + return ImplementsTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode::class, true); + return is_a($node, ImplementsTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode $node + * @param ImplementsTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareImplementsTagValueNode( - $node->type, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareImplementsTagValueNode($node->type, $node->description); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareInvalidTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareInvalidTagValueNodeFactory.php index 5e8aaa760e4..a978d79d83e 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareInvalidTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareInvalidTagValueNodeFactory.php @@ -4,27 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareInvalidTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareInvalidTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareInvalidTagValueNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode::class; + return InvalidTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode::class, true); + return is_a($node, InvalidTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode $node + * @param InvalidTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareInvalidTagValueNode( - $node->value, - $node->exception - ); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareInvalidTagValueNode($node->value, $node->exception); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareMethodTagValueParameterNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareMethodTagValueParameterNodeFactory.php index 458da85ce3b..d0c090be323 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareMethodTagValueParameterNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareMethodTagValueParameterNodeFactory.php @@ -4,25 +4,41 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareMethodTagValueParameterNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareMethodTagValueParameterNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareMethodTagValueParameterNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode::class; + return MethodTagValueParameterNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode::class, true); + return is_a($node, MethodTagValueParameterNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode $node + * @param MethodTagValueParameterNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareMethodTagValueParameterNode( + public function create(Node $node): AttributeAwareNodeInterface + { + if ($node->type !== null) { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + } + + return new AttributeAwareMethodTagValueParameterNode( $node->type, $node->isReference, $node->isVariadic, @@ -30,4 +46,9 @@ final class AttributeAwareMethodTagValueParameterNodeFactory implements \Rector\ $node->defaultValue ); } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; + } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareParamTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareParamTagValueNodeFactory.php index f2ef243e09b..2d2049bddfb 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareParamTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareParamTagValueNodeFactory.php @@ -4,29 +4,49 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareParamTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareParamTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareParamTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class; + return ParamTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class, true); + return is_a($node, ParamTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode $node + * @param ParamTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareParamTagValueNode( + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareParamTagValueNode( $node->type, $node->isVariadic, $node->parameterName, - $node->description + $node->description, + false ); } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; + } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocNodeFactory.php index 4a72423afdb..5c4d98c5895 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocNodeFactory.php @@ -4,24 +4,60 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwarePhpDocNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Ast\PhpDocNodeTraverser; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePhpDocNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { - public function getOriginalNodeClass(): string + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + + /** + * @var PhpDocNodeTraverser + */ + private $phpDocNodeTraverser; + + public function __construct(PhpDocNodeTraverser $phpDocNodeTraverser) { - return \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode::class; + $this->phpDocNodeTraverser = $phpDocNodeTraverser; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function getOriginalNodeClass(): string { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode::class, true); + return PhpDocNode::class; + } + + public function isMatch(Node $node): bool + { + return is_a($node, PhpDocNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $node + * @param PhpDocNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocNode($node->children); + public function create(Node $node): AttributeAwareNodeInterface + { + $this->phpDocNodeTraverser->traverseWithCallable($node, function (Node $node): AttributeAwareNodeInterface { + if ($node instanceof AttributeAwareNodeInterface) { + return $node; + } + + return $this->attributeAwareNodeFactory->createFromNode($node); + }); + + return new AttributeAwarePhpDocNode($node->children); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTagNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTagNodeFactory.php index 21cdbf2e031..e7c3e0bc6ef 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTagNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTagNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwarePhpDocTagNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocTagNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePhpDocTagNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode::class; + return PhpDocTagNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode::class, true); + return is_a($node, PhpDocTagNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $node + * @param PhpDocTagNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocTagNode($node->name, $node->value); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwarePhpDocTagNode($node->name, $node->value); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTextNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTextNodeFactory.php index 8d532fd446b..a0ff1efc001 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTextNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePhpDocTextNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwarePhpDocTextNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocTextNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePhpDocTextNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode::class; + return PhpDocTextNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode::class, true); + return is_a($node, PhpDocTextNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode $node + * @param PhpDocTextNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePhpDocTextNode($node->text); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwarePhpDocTextNode($node->text); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePropertyTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePropertyTagValueNodeFactory.php index e82318a854f..5c0faf47627 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePropertyTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwarePropertyTagValueNodeFactory.php @@ -4,28 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwarePropertyTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePropertyTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwarePropertyTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class; + return PropertyTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class, true); + return is_a($node, PropertyTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode $node + * @param PropertyTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwarePropertyTagValueNode( - $node->type, - $node->propertyName, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwarePropertyTagValueNode($node->type, $node->propertyName, $node->description); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareReturnTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareReturnTagValueNodeFactory.php index 27f1cc40b72..15401135ca8 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareReturnTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareReturnTagValueNodeFactory.php @@ -4,27 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareReturnTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareReturnTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareReturnTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class; + return ReturnTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class, true); + return is_a($node, ReturnTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode $node + * @param ReturnTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareReturnTagValueNode( - $node->type, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareReturnTagValueNode($node->type, $node->description); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareTemplateTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareTemplateTagValueNodeFactory.php index d275fb40c9f..f49898c1505 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareTemplateTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareTemplateTagValueNodeFactory.php @@ -4,28 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareTemplateTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareTemplateTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareTemplateTagValueNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode::class; + return TemplateTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode::class, true); + return is_a($node, TemplateTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode $node + * @param TemplateTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareTemplateTagValueNode( - $node->name, - $node->bound, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareTemplateTagValueNode($node->name, $node->bound, $node->description); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareThrowsTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareThrowsTagValueNodeFactory.php index c232ce1e9c2..058b209aab9 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareThrowsTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareThrowsTagValueNodeFactory.php @@ -4,27 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareThrowsTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareThrowsTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareThrowsTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class; + return ThrowsTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class, true); + return is_a($node, ThrowsTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode $node + * @param ThrowsTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareThrowsTagValueNode( - $node->type, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareThrowsTagValueNode($node->type, $node->description); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareUsesTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareUsesTagValueNodeFactory.php index 2f1096630f3..191401a6bee 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareUsesTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareUsesTagValueNodeFactory.php @@ -4,27 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; -final class AttributeAwareUsesTagValueNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode; +use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareUsesTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareUsesTagValueNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode::class; + return UsesTagValueNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode::class, true); + return is_a($node, UsesTagValueNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\PhpDoc\UsesTagValueNode $node + * @param UsesTagValueNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareUsesTagValueNode( - $node->type, - $node->description - ); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareUsesTagValueNode($node->type, $node->description); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareVarTagValueNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareVarTagValueNodeFactory.php index 4c758d508ad..f42c49238b3 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareVarTagValueNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/PhpDoc/AttributeAwareVarTagValueNodeFactory.php @@ -7,11 +7,18 @@ namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use Rector\AttributeAwarePhpDoc\Ast\PhpDoc\AttributeAwareVarTagValueNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; -final class AttributeAwareVarTagValueNodeFactory implements AttributeNodeAwareFactoryInterface +final class AttributeAwareVarTagValueNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { return VarTagValueNode::class; @@ -27,6 +34,13 @@ final class AttributeAwareVarTagValueNodeFactory implements AttributeNodeAwareFa */ public function create(Node $node): AttributeAwareNodeInterface { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + return new AttributeAwareVarTagValueNode($node->type, $node->variableName, $node->description); } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; + } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareArrayTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareArrayTypeNodeFactory.php index 255ad48f4c1..84467a72227 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareArrayTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareArrayTypeNodeFactory.php @@ -7,11 +7,18 @@ namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode; use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareArrayTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; -final class AttributeAwareArrayTypeNodeFactory implements AttributeNodeAwareFactoryInterface +final class AttributeAwareArrayTypeNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { return ArrayTypeNode::class; @@ -27,6 +34,13 @@ final class AttributeAwareArrayTypeNodeFactory implements AttributeNodeAwareFact */ public function create(Node $node): AttributeAwareNodeInterface { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + return new AttributeAwareArrayTypeNode($node->type); } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; + } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareCallableTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareCallableTypeNodeFactory.php index 23d656e0d01..d4b6e91ce8a 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareCallableTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareCallableTypeNodeFactory.php @@ -4,28 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareCallableTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareCallableTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareCallableTypeNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode::class; + return CallableTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode::class, true); + return is_a($node, CallableTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode $node + * @param CallableTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareCallableTypeNode( - $node->identifier, - $node->parameters, - $node->returnType - ); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareGenericTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareGenericTypeNodeFactory.php index 3e60beae635..a5e42681e9d 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareGenericTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareGenericTypeNodeFactory.php @@ -4,27 +4,47 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareGenericTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareGenericTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareGenericTypeNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode::class; + return GenericTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode::class, true); + return is_a($node, GenericTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode $node + * @param GenericTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareGenericTypeNode( - $node->type, - $node->genericTypes - ); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + foreach ($node->genericTypes as $key => $genericType) { + $node->genericTypes[$key] = $this->attributeAwareNodeFactory->createFromNode($genericType); + } + + return new AttributeAwareGenericTypeNode($node->type, $node->genericTypes); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIdentifierTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIdentifierTypeNodeFactory.php index 33c249f3b87..014dfbdbce4 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIdentifierTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIdentifierTypeNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareIdentifierTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIdentifierTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareIdentifierTypeNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode::class; + return IdentifierTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode::class, true); + return is_a($node, IdentifierTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $node + * @param IdentifierTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIdentifierTypeNode($node->name); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareIdentifierTypeNode($node->name); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIntersectionTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIntersectionTypeNodeFactory.php index db15ff96aea..be14c51ea24 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIntersectionTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareIntersectionTypeNodeFactory.php @@ -4,24 +4,45 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareIntersectionTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIntersectionTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareIntersectionTypeNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode::class; + return IntersectionTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode::class, true); + return is_a($node, IntersectionTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode $node + * @param IntersectionTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIntersectionTypeNode($node->types); + public function create(Node $node): AttributeAwareNodeInterface + { + foreach ($node->types as $key => $intersectionedType) { + $node->types[$key] = $this->attributeAwareNodeFactory->createFromNode($intersectionedType); + } + + return new AttributeAwareIntersectionTypeNode($node->types); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareNullableTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareNullableTypeNodeFactory.php index ada79b17577..cedeeeb63f5 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareNullableTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareNullableTypeNodeFactory.php @@ -4,24 +4,43 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareNullableTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\NullableTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareNullableTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareNullableTypeNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode::class; + return NullableTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode::class, true); + return is_a($node, NullableTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode $node + * @param NullableTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareNullableTypeNode($node->type); + public function create(Node $node): AttributeAwareNodeInterface + { + $node->type = $this->attributeAwareNodeFactory->createFromNode($node->type); + + return new AttributeAwareNullableTypeNode($node->type); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareThisTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareThisTypeNodeFactory.php index 00e5a16cd85..7f18b06d51e 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareThisTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareThisTypeNodeFactory.php @@ -4,24 +4,29 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareThisTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareThisTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareThisTypeNodeFactory implements AttributeNodeAwareFactoryInterface { public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode::class; + return ThisTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode::class, true); + return is_a($node, ThisTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\ThisTypeNode $node + * @param ThisTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareThisTypeNode(); + public function create(Node $node): AttributeAwareNodeInterface + { + return new AttributeAwareThisTypeNode(); } } diff --git a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareUnionTypeNodeFactory.php b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareUnionTypeNodeFactory.php index c52d4c10c20..25475eaf79b 100644 --- a/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareUnionTypeNodeFactory.php +++ b/packages/AttributeAwarePhpDoc/src/AttributeAwareNodeFactory/Type/AttributeAwareUnionTypeNodeFactory.php @@ -4,24 +4,45 @@ declare(strict_types=1); namespace Rector\AttributeAwarePhpDoc\AttributeAwareNodeFactory\Type; -final class AttributeAwareUnionTypeNodeFactory implements \Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode; +use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareUnionTypeNode; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeAwareNodeFactoryAwareInterface; +use Rector\AttributeAwarePhpDoc\Contract\AttributeNodeAwareFactory\AttributeNodeAwareFactoryInterface; +use Rector\BetterPhpDocParser\Attributes\Ast\AttributeAwareNodeFactory; +use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface; + +final class AttributeAwareUnionTypeNodeFactory implements AttributeNodeAwareFactoryInterface, AttributeAwareNodeFactoryAwareInterface { + /** + * @var AttributeAwareNodeFactory + */ + private $attributeAwareNodeFactory; + public function getOriginalNodeClass(): string { - return \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode::class; + return UnionTypeNode::class; } - public function isMatch(\PHPStan\PhpDocParser\Ast\Node $node): bool + public function isMatch(Node $node): bool { - return is_a($node, \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode::class, true); + return is_a($node, UnionTypeNode::class, true); } /** - * @param \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $node + * @param UnionTypeNode $node */ - public function create( - \PHPStan\PhpDocParser\Ast\Node $node - ): \Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface { - return new \Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareUnionTypeNode($node->types); + public function create(Node $node): AttributeAwareNodeInterface + { + foreach ($node->types as $key => $unionedType) { + $node->types[$key] = $this->attributeAwareNodeFactory->createFromNode($unionedType); + } + + return new AttributeAwareUnionTypeNode($node->types); + } + + public function setAttributeAwareNodeFactory(AttributeAwareNodeFactory $attributeAwareNodeFactory): void + { + $this->attributeAwareNodeFactory = $attributeAwareNodeFactory; } } diff --git a/packages/AttributeAwarePhpDoc/src/Contract/AttributeNodeAwareFactory/AttributeAwareNodeFactoryAwareInterface.php b/packages/AttributeAwarePhpDoc/src/Contract/AttributeNodeAwareFactory/AttributeAwareNodeFactoryAwareInterface.php new file mode 100644 index 00000000000..a71d0bea56b --- /dev/null +++ b/packages/AttributeAwarePhpDoc/src/Contract/AttributeNodeAwareFactory/AttributeAwareNodeFactoryAwareInterface.php @@ -0,0 +1,12 @@ +phpDocNodeTraverser = $phpDocNodeTraverser; + public function __construct(AttributeAwareNodeFactoryCollector $attributeAwareNodeFactoryCollector) + { $this->attributeAwareNodeFactoryCollector = $attributeAwareNodeFactoryCollector; } @@ -76,145 +37,23 @@ final class AttributeAwareNodeFactory return $node; } - if ($node instanceof PhpDocNode) { - $this->phpDocNodeTraverser->traverseWithCallable($node, function (Node $node): AttributeAwareNodeInterface { - if ($node instanceof AttributeAwareNodeInterface) { - return $node; - } - - return $this->createFromNode($node); - }); - - return new AttributeAwarePhpDocNode($node->children); - } - foreach ($this->attributeAwareNodeFactoryCollector->provide() as $attributeNodeAwareFactory) { if (! $attributeNodeAwareFactory->isMatch($node)) { continue; } + // prevents cyclic dependency + if ($attributeNodeAwareFactory instanceof AttributeAwareNodeFactoryAwareInterface) { + $attributeNodeAwareFactory->setAttributeAwareNodeFactory($this); + } + return $attributeNodeAwareFactory->create($node); } - if ($node instanceof PhpDocTagValueNode) { - return $this->createFromPhpDocValueNode($node); - } - - if ($node instanceof TypeNode) { - return $this->createFromTypeNode($node); - } - - throw new ShouldNotHappenException(sprintf('Node "%s" was missed in "%s".', get_class($node), __METHOD__)); - } - - private function createFromPhpDocValueNode(PhpDocTagValueNode $phpDocTagValueNode): PhpDocTagValueNode - { - if ($phpDocTagValueNode instanceof VarTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareVarTagValueNode( - $typeNode, - $phpDocTagValueNode->variableName, - $phpDocTagValueNode->description - ); - } - - if ($phpDocTagValueNode instanceof ReturnTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareReturnTagValueNode($typeNode, $phpDocTagValueNode->description); - } - - if ($phpDocTagValueNode instanceof ParamTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareParamTagValueNode( - $typeNode, - $phpDocTagValueNode->isVariadic, - $phpDocTagValueNode->parameterName, - $phpDocTagValueNode->description, - false - ); - } - - if ($phpDocTagValueNode instanceof MethodTagValueNode) { - $typeNode = $phpDocTagValueNode->returnType !== null ? $this->createFromTypeNode( - $phpDocTagValueNode->returnType - ) : null; - return new AttributeAwareMethodTagValueNode( - $phpDocTagValueNode->isStatic, - $typeNode, - $phpDocTagValueNode->methodName, - $phpDocTagValueNode->parameters, - $phpDocTagValueNode->description - ); - } - - if ($phpDocTagValueNode instanceof PropertyTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwarePropertyTagValueNode( - $typeNode, - $phpDocTagValueNode->propertyName, - $phpDocTagValueNode->description - ); - } - - if ($phpDocTagValueNode instanceof ExtendsTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareExtendsTagValueNode($typeNode, $phpDocTagValueNode->description); - } - - if ($phpDocTagValueNode instanceof ImplementsTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareImplementsTagValueNode($typeNode, $phpDocTagValueNode->description); - } - - if ($phpDocTagValueNode instanceof ThrowsTagValueNode) { - $typeNode = $this->createFromTypeNode($phpDocTagValueNode->type); - return new AttributeAwareThrowsTagValueNode($typeNode, $phpDocTagValueNode->description); - } - - throw new NotImplementedYetException(sprintf( - 'Implement "%s" to "%s"', - get_class($phpDocTagValueNode), + throw new ShouldNotHappenException(sprintf( + 'Node "%s" was missed in "%s". Generate it with: bin/rector sync-types', + get_class($node), __METHOD__ )); } - - /** - * @return AttributeAwareNodeInterface|TypeNode - */ - private function createFromTypeNode(TypeNode $typeNode): AttributeAwareNodeInterface - { - if ($typeNode instanceof NullableTypeNode) { - $typeNode->type = $this->createFromTypeNode($typeNode->type); - return new AttributeAwareNullableTypeNode($typeNode->type); - } - - if ($typeNode instanceof UnionTypeNode || $typeNode instanceof IntersectionTypeNode) { - foreach ($typeNode->types as $i => $subTypeNode) { - $typeNode->types[$i] = $this->createFromTypeNode($subTypeNode); - } - - if ($typeNode instanceof UnionTypeNode) { - return new AttributeAwareUnionTypeNode($typeNode->types); - } - - return new AttributeAwareIntersectionTypeNode($typeNode->types); - } - - if ($typeNode instanceof ArrayTypeNode) { - $typeNode->type = $this->createFromTypeNode($typeNode->type); - return new AttributeAwareArrayTypeNode($typeNode->type); - } - - if ($typeNode instanceof GenericTypeNode) { - /** @var AttributeAwareIdentifierTypeNode $identifierTypeNode */ - $identifierTypeNode = $this->createFromTypeNode($typeNode->type); - foreach ($typeNode->genericTypes as $key => $genericType) { - $typeNode->genericTypes[$key] = $this->createFromTypeNode($genericType); - } - - return new AttributeAwareGenericTypeNode($identifierTypeNode, $typeNode->genericTypes); - } - - throw new NotImplementedYetException(sprintf('Implement "%s" to "%s"', get_class($typeNode), __METHOD__)); - } } diff --git a/packages/BetterPhpDocParser/tests/Attributes/Ast/AttributeAwareNodeFactoryTest.php b/packages/BetterPhpDocParser/tests/Attributes/Ast/AttributeAwareNodeFactoryTest.php index 40732770308..0e55daa2fca 100644 --- a/packages/BetterPhpDocParser/tests/Attributes/Ast/AttributeAwareNodeFactoryTest.php +++ b/packages/BetterPhpDocParser/tests/Attributes/Ast/AttributeAwareNodeFactoryTest.php @@ -65,8 +65,6 @@ final class AttributeAwareNodeFactoryTest extends AbstractKernelTestCase /** @var PropertyTagValueNode $propertyTagValueNode */ $nullableTypeNode = $propertyTagValueNode->type; - dump($nullableTypeNode); - $this->assertInstanceOf(NullableTypeNode::class, $nullableTypeNode); $this->assertInstanceOf(AttributeAwareNullableTypeNode::class, $nullableTypeNode); diff --git a/packages/SOLID/src/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php b/packages/SOLID/src/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php index 4c373798996..535cff8a2e1 100644 --- a/packages/SOLID/src/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php +++ b/packages/SOLID/src/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php @@ -7,6 +7,7 @@ namespace Rector\SOLID\Rector\If_; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\BinaryOp; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Return_; @@ -152,7 +153,7 @@ PHP // special case if ($invertedCondition instanceof BooleanNot) { - if ($invertedCondition->expr instanceof BinaryOp\BooleanAnd) { + if ($invertedCondition->expr instanceof BooleanAnd) { $booleanNotPartIf = new If_(new BooleanNot($invertedCondition->expr->left)); $booleanNotPartIf->stmts = [clone $return]; $this->addNodeAfterNode($booleanNotPartIf, $if); diff --git a/rector.yaml b/rector.yaml index ae85f662ede..e92676364d6 100644 --- a/rector.yaml +++ b/rector.yaml @@ -1,11 +1,17 @@ services: - Rector\SOLID\Rector\If_\ChangeNestedIfsToEarlyReturnRector: null + Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector: null +# Rector\SOLID\Rector\If_\ChangeNestedIfsToEarlyReturnRector: null # Rector\SOLID\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector: null imports: - { resource: "create-rector.yaml", ignore_errors: true } parameters: + paths: + - src + - tests + - packages + exclude_paths: - "/Source/" - "/*Source/"