From 6fe66697a6f9f79401b7d5fc92b619914fbda320 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 30 Dec 2024 10:41:26 +0000 Subject: [PATCH] release PHP 7.4 downgraded --- .editorconfig | 9 - .../workflows/standalone_install.yaml | 0 build/rector-downgrade-php-74.php | 12 -- build/target-repository/.github/FUNDING.yml | 3 - build/target-repository/composer.json | 23 --- .../target-repository/phpstan-for-tests.neon | 9 - composer.json | 30 +-- ecs.php | 18 -- full-tool-build.sh | 15 -- phpstan.neon | 34 ---- phpunit.xml | 12 -- rector.php | 28 --- .../PublicClassMethodParamTypesCollector.php | 30 ++- .../MethodCallArgTypesCollector.php | 24 ++- .../MethodCallableCollector.php | 18 +- src/Configuration.php | 7 +- .../ClassMethodCallReferenceResolver.php | 5 +- .../Collector/PublicClassMethodMatcher.php | 2 +- src/NodeFinder/ClassMethodNodeFinder.php | 13 +- src/NodeFinder/MethodCallNodeFinder.php | 21 +- src/NodeFinder/ReturnNodeFinder.php | 4 +- src/NodeVisitor/CallableNodeVisitor.php | 5 +- src/PhpDoc/ApiDocStmtAnalyzer.php | 4 +- src/Printer/CollectorMetadataPrinter.php | 11 +- src/Printer/NodeComparator.php | 12 +- src/Reflection/ReflectionParser.php | 9 +- .../NarrowPrivateClassMethodParamTypeRule.php | 24 ++- .../NarrowPublicClassMethodParamTypeRule.php | 12 +- src/Rules/NarrowReturnObjectTypeRule.php | 24 ++- src/Rules/NoEmptyOnObjectRule.php | 12 +- src/Rules/NoIssetOnObjectRule.php | 12 +- src/Rules/NoMixedMethodCallerRule.php | 18 +- src/Rules/NoMixedPropertyFetcherRule.php | 18 +- src/Rules/NoParamTypeRemovalRule.php | 12 +- src/Rules/ReturnNullOverFalseRule.php | 15 +- src/ValueObject/MethodCallReference.php | 18 +- .../DifferentClassSameMethodCallName.php | 31 --- .../Fixture/DoubleShot.php | 18 -- .../Fixture/Fixture.php | 22 -- .../Fixture/SkipAbstractBase.php | 16 -- .../Fixture/SkipAlreadyCorrectType.php | 22 -- .../Fixture/SkipCorrectUnionType.php | 32 --- ...pDuplicatedCallOfSameMethodWithComment.php | 26 --- .../Fixture/SkipGenericType.php | 31 --- .../Fixture/SkipMayOverrideArg.php | 27 --- .../Fixture/SkipMixed.php | 18 -- .../Fixture/SkipMultipleUsed.php | 27 --- .../Fixture/SkipNoArgs.php | 15 -- .../Fixture/SkipNotFromThis.php | 14 -- .../Fixture/SkipNotPrivate.php | 22 -- .../Fixture/SkipOptedOut.php | 23 --- .../Fixture/SkipParentNotIf.php | 15 -- .../Fixture/SkipRecursive.php | 30 --- ...rowPrivateClassMethodParamTypeRuleTest.php | 67 ------- .../Source/AnotherClassWithRun.php | 15 -- .../Source/ConceptBase.php | 10 - .../Source/ConceptImpl1.php | 9 - .../FirstClassCallables/CallVariadics.php | 15 -- .../FirstClassCallables/SomeCalledMethod.php | 12 -- .../Fixture/HandleDefaultValue.php | 30 --- .../Fixture/PublicDoubleShot.php | 12 -- .../Fixture/SkipApiMarked.php | 17 -- .../Fixture/SkipCallable.php | 18 -- .../Fixture/SkipClassStringPassed.php | 12 -- .../Fixture/SkipClosure.php | 18 -- .../Fixture/SkipEnum.php | 19 -- .../Fixture/SkipEqualUnionType.php | 44 ---- .../Fixture/SkipExpectedClassType.php | 14 -- .../Fixture/SkipMixedAndString.php | 12 -- .../Fixture/SkipNonPublicClassMethod.php | 17 -- .../Fixture/SkipNullableCompare.php | 14 -- .../Fixture/SkipProperlyFilledParamType.php | 12 -- .../Fixture/SkipSelf.php | 17 -- .../Fixture/SkipThisPassedExactType.php | 14 -- .../SkipUsedInternallyForSecondType.php | 20 -- .../Fixture/ThisPassedFromInterface.php | 14 -- ...rrowPublicClassMethodParamTypeRuleTest.php | 189 ------------------ .../ExpectedClassString/FirstTypedCaller.php | 17 -- .../ExpectedClassString/SecondTypedCaller.php | 17 -- .../FirstClassTypedCaller.php | 17 -- .../SecondClassTypedCaller.php | 17 -- .../ExpectedNodeApi/CallWithProperty.php | 17 -- .../Source/ExpectedThisType/CallByThis.php | 15 -- .../CallByThisFromInterface.php | 16 -- .../Source/ExpectedType/FirstTypedCaller.php | 15 -- .../OnlyFirstTypeCalledOutside.php | 16 -- .../Source/ExpectedType/SecondTypedCaller.php | 15 -- .../ExpectedUnion/CallUnionArrayType.php | 31 --- .../Source/ExpectedUnion/CallUnionType.php | 22 -- .../ExpectedUnion/CallUnionTypeFlipped.php | 22 -- .../CallUnionTypeTernaryIfElse.php | 22 -- .../CallUnionTypeTernaryIfElseFlipped.php | 22 -- .../Source/FirstCaller.php | 15 -- .../Source/MixedAndString/FirstCaller.php | 15 -- .../Source/MixedAndString/SecondCaller.php | 15 -- .../Source/MixedAndString/ThirdCaller.php | 15 -- .../Source/NullableParam/FirstNullable.php | 16 -- .../Source/NullableParam/SecondNullable.php | 16 -- .../Source/PassMeAsType.php | 10 - .../Source/PickReasonEnum.php | 11 - .../Source/SecondCaller.php | 15 -- .../Source/SomeInterface.php | 8 - .../Fixture/SkipSomeContract.php | 17 -- .../Fixture/SkipSpecificReturnType.php | 15 -- .../Fixture/SomeAbstractReturnType.php | 16 -- .../NarrowReturnObjectTypeRuleTest.php | 46 ----- .../Source/AbstractControl.php | 9 - .../Source/SomeContract.php | 12 -- .../Source/SpecificControl.php | 9 - .../Fixture/ArrayAccessOnNestedObject.php | 16 -- .../Fixture/ArrayAccessOnObject.php | 16 -- .../Fixture/SkipIterator.php | 15 -- .../Fixture/SkipOnArray.php | 13 -- .../Fixture/SkipSplFixedArray.php | 15 -- .../Fixture/SkipXml.php | 15 -- .../Fixture/SkipXmlElementForeach.php | 17 -- .../NoArrayAccessOnObjectRuleTest.php | 48 ----- .../ChildOfSomeClassWithArrayAccess.php | 9 - .../Source/SomeClassWithArrayAccess.php | 26 --- .../Source/SomeClassWithSplFixedArray.php | 11 - .../Fixture/EmptyOnObject.php | 23 --- .../Fixture/SkipEmptyOnArray.php | 15 -- .../SkipEmptyOnArrayNestedOnObject.php | 17 -- .../Fixture/SkipPhpDocType.php | 12 -- .../Fixture/SkipPossibleUndefinedVariable.php | 19 -- .../NoEmptyOnObjectRuleTest.php | 46 ----- .../Fixture/IssetOnObject.php | 23 --- .../Fixture/SkipIssetOnArray.php | 15 -- .../SkipIssetOnArrayNestedOnObject.php | 17 -- .../Fixture/SkipIssetOnPropertyFetch.php | 27 --- .../Fixture/SkipPhpDocType.php | 12 -- .../Fixture/SkipPossibleUndefinedVariable.php | 19 -- .../NoIssetOnObjectRuleTest.php | 47 ----- .../Rules/NoIssetOnObjectRule/Source/Foo.php | 13 -- .../Fixture/MagicMethodName.php | 13 -- .../Fixture/SkipKnownCallerType.php | 15 -- .../Fixture/SkipMockObject.php | 19 -- .../Fixture/SkipPHPUnitMock.php | 21 -- .../Fixture/UnknownCallerType.php | 13 -- .../NoMixedMethodCallerRuleTest.php | 49 ----- .../Source/KnownType.php | 12 -- .../Source/SomeFinalClass.php | 10 - .../Fixture/DynamicName.php | 13 -- .../Fixture/SkipDynamicNameWithKnownType.php | 15 -- .../Fixture/SkipKnownFetcherType.php | 15 -- .../Fixture/UnknownPropertyFetcher.php | 13 -- .../NoMixedPropertyFetcherRuleTest.php | 48 ----- .../Source/KnownType.php | 10 - .../Fixture/AnInterface.php | 10 - .../Fixture/AnInterfaceOther.php | 12 -- ...sDifferentParameterWithInterfaceMethod.php | 16 -- .../HasDifferentParameterWithParentMethod.php | 12 -- .../Fixture/ParentClass.php | 12 -- .../Fixture/RemoveParentType.php | 14 -- .../Fixture/SkipConstruct.php | 20 -- ...kipHasSameParameterWithInterfaceMethod.php | 18 -- .../SkipHasSameParameterWithParentMethod.php | 12 -- .../Fixture/SkipIndirectRemoval.php | 18 -- .../Fixture/SkipNoParent.php | 9 - .../Fixture/SkipNoType.php | 14 -- .../Fixture/SkipNotHasParentMethod.php | 12 -- .../Fixture/SkipPhpDocType.php | 17 -- .../Fixture/SkipPresentType.php | 15 -- .../NoParamTypeRemovalRuleTest.php | 65 ------ .../Source/NoTypeInterface.php | 10 - .../Source/PhpDocType.php | 15 -- .../Source/SomeNode.php | 10 - .../Source/SomeRectorInterface.php | 10 - .../Fixture/CheckResultFromOtherMethod.php | 29 --- .../Fixture/CheckResultFromOtherMethod2.php | 31 --- .../Fixture/ReturnFalseOnly.php | 17 -- .../Fixture/SkipReturnBool.php | 17 -- .../ReturnNullOverFalseRuleTest.php | 48 ----- tests/SomeClass.php.inc | 13 -- tests/config/included_services.neon | 2 - 175 files changed, 239 insertions(+), 3085 deletions(-) delete mode 100644 .editorconfig rename {build/target-repository/.github => .github}/workflows/standalone_install.yaml (100%) delete mode 100644 build/rector-downgrade-php-74.php delete mode 100644 build/target-repository/.github/FUNDING.yml delete mode 100644 build/target-repository/composer.json delete mode 100644 build/target-repository/phpstan-for-tests.neon delete mode 100644 ecs.php delete mode 100644 full-tool-build.sh delete mode 100644 phpstan.neon delete mode 100644 phpunit.xml delete mode 100644 rector.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/ConceptBase.php delete mode 100644 tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/ConceptImpl1.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/CallVariadics.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/HandleDefaultValue.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipApiMarked.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipCallable.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClosure.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEnum.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipMixedAndString.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNonPublicClassMethod.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipProperlyFilledParamType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipSelf.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipUsedInternallyForSecondType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PickReasonEnum.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SecondCaller.php delete mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Fixture/SkipSomeContract.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Fixture/SkipSpecificReturnType.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Fixture/SomeAbstractReturnType.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/NarrowReturnObjectTypeRuleTest.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Source/SomeContract.php delete mode 100644 tests/Rules/NarrowReturnObjectTypeRule/Source/SpecificControl.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnNestedObject.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/ArrayAccessOnObject.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipIterator.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipOnArray.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipSplFixedArray.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXml.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Fixture/SkipXmlElementForeach.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Source/SomeClassWithArrayAccess.php delete mode 100644 tests/Rules/NoArrayAccessOnObjectRule/Source/SomeClassWithSplFixedArray.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/Fixture/EmptyOnObject.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/Fixture/SkipEmptyOnArray.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/Fixture/SkipEmptyOnArrayNestedOnObject.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/Fixture/SkipPhpDocType.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/Fixture/SkipPossibleUndefinedVariable.php delete mode 100644 tests/Rules/NoEmptyOnObjectRule/NoEmptyOnObjectRuleTest.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArray.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnArrayNestedOnObject.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnPropertyFetch.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/SkipPhpDocType.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Fixture/SkipPossibleUndefinedVariable.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php delete mode 100644 tests/Rules/NoIssetOnObjectRule/Source/Foo.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Fixture/MagicMethodName.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php delete mode 100644 tests/Rules/NoMixedMethodCallerRule/Source/SomeFinalClass.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/Fixture/DynamicName.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php delete mode 100644 tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/AnInterface.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/AnInterfaceOther.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/HasDifferentParameterWithInterfaceMethod.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/HasDifferentParameterWithParentMethod.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/ParentClass.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/RemoveParentType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipConstruct.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipHasSameParameterWithInterfaceMethod.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipHasSameParameterWithParentMethod.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipIndirectRemoval.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipNoParent.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipNoType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipNotHasParentMethod.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipPhpDocType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Fixture/SkipPresentType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/NoParamTypeRemovalRuleTest.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Source/PhpDocType.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Source/SomeNode.php delete mode 100644 tests/Rules/NoParamTypeRemovalRule/Source/SomeRectorInterface.php delete mode 100644 tests/Rules/ReturnNullOverFalseRule/Fixture/CheckResultFromOtherMethod.php delete mode 100644 tests/Rules/ReturnNullOverFalseRule/Fixture/CheckResultFromOtherMethod2.php delete mode 100644 tests/Rules/ReturnNullOverFalseRule/Fixture/ReturnFalseOnly.php delete mode 100644 tests/Rules/ReturnNullOverFalseRule/Fixture/SkipReturnBool.php delete mode 100644 tests/Rules/ReturnNullOverFalseRule/ReturnNullOverFalseRuleTest.php delete mode 100644 tests/SomeClass.php.inc delete mode 100644 tests/config/included_services.neon diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index bec95c44..00000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 diff --git a/build/target-repository/.github/workflows/standalone_install.yaml b/.github/workflows/standalone_install.yaml similarity index 100% rename from build/target-repository/.github/workflows/standalone_install.yaml rename to .github/workflows/standalone_install.yaml diff --git a/build/rector-downgrade-php-74.php b/build/rector-downgrade-php-74.php deleted file mode 100644 index 48e8c8b1..00000000 --- a/build/rector-downgrade-php-74.php +++ /dev/null @@ -1,12 +0,0 @@ -sets([DowngradeLevelSetList::DOWN_TO_PHP_74]); - - $rectorConfig->skip(['*/tests/*']); -}; diff --git a/build/target-repository/.github/FUNDING.yml b/build/target-repository/.github/FUNDING.yml deleted file mode 100644 index f797866a..00000000 --- a/build/target-repository/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms -github: tomasvotruba -custom: https://www.paypal.me/rectorphp diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json deleted file mode 100644 index af6abc9f..00000000 --- a/build/target-repository/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "rector/type-perfect", - "type": "phpstan-extension", - "description": "Next level type declaration checks", - "license": "MIT", - "require": { - "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.0", - "webmozart/assert": "^1.11" - }, - "autoload": { - "psr-4": { - "Rector\\TypePerfect\\": "src" - } - }, - "extra": { - "phpstan": { - "includes": [ - "config/extension.neon" - ] - } - } -} diff --git a/build/target-repository/phpstan-for-tests.neon b/build/target-repository/phpstan-for-tests.neon deleted file mode 100644 index 421c39ad..00000000 --- a/build/target-repository/phpstan-for-tests.neon +++ /dev/null @@ -1,9 +0,0 @@ -# this config is only for tests, it verifies all the rules are runnable -includes: - - vendor/rector/type-perfect/config/extension.neon - -parameters: - level: 4 - - ignoreErrors: - - '#Class method "getName\(\)" is never used#' diff --git a/composer.json b/composer.json index 28337644..af6abc9f 100644 --- a/composer.json +++ b/composer.json @@ -4,48 +4,20 @@ "description": "Next level type declaration checks", "license": "MIT", "require": { - "php": "^8.2", + "php": "^7.4|^8.0", "phpstan/phpstan": "^2.0", "webmozart/assert": "^1.11" }, - "require-dev": { - "nikic/php-parser": "^5.0", - "symplify/phpstan-extensions": "^12.0", - "symplify/rule-doc-generator": "^12.1", - "phpunit/phpunit": "^10.5", - "rector/rector": "^2.0", - "symplify/easy-coding-standard": "^12.1", - "phpstan/extension-installer": "^1.3", - "tomasvotruba/class-leak": "^0.2", - "tracy/tracy": "^2.10" - }, "autoload": { "psr-4": { "Rector\\TypePerfect\\": "src" } }, - "autoload-dev": { - "psr-4": { - "Rector\\TypePerfect\\Tests\\": "tests" - } - }, "extra": { "phpstan": { "includes": [ "config/extension.neon" ] } - }, - "config": { - "platform-check": false, - "allow-plugins": { - "phpstan/extension-installer": true - } - }, - "scripts": { - "check-cs": "vendor/bin/ecs check --ansi", - "fix-cs": "vendor/bin/ecs check --fix --ansi", - "phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify", - "rector": "vendor/bin/rector process --dry-run --ansi" } } diff --git a/ecs.php b/ecs.php deleted file mode 100644 index 7a5dab64..00000000 --- a/ecs.php +++ /dev/null @@ -1,18 +0,0 @@ -withPaths([ - __DIR__ . '/config', - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withRootFiles() - ->withPreparedSets(psr12: true, common: true) - ->withSkip([ - '*/Source/*', - '*/Fixture/*', - ]); diff --git a/full-tool-build.sh b/full-tool-build.sh deleted file mode 100644 index 93136248..00000000 --- a/full-tool-build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -# add patches -composer install --ansi - -# but skip dev dependencies -composer update --no-dev --ansi - -# remove tests and useless files, to make downgraded, scoped and deployed codebase as small as possible -rm -rf tests - -# downgrade with rector -mkdir rector-local -composer require rector/rector --working-dir rector-local -rector-local/vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 09501de1..00000000 --- a/phpstan.neon +++ /dev/null @@ -1,34 +0,0 @@ -includes: - - config/extension.neon - -parameters: - level: 8 - - paths: - - src - - config - - tests - - excludePaths: - # tests - - "*/Source/*" - - "*/Fixture/*" - - ignoreErrors: - - '#Method (.*?)::getCollectors\(\) return type with generic interface PHPStan\\Collectors\\Collector does not specify its types\: TNodeType, TValue#' - - # overly detailed generics - - '#Rector\\TypePerfect\\Tests\\Rules\\(.*?) generic (class|interface)#' - - - - identifier: phpstanApi.instanceofType - paths: - - src/Printer/CollectorMetadataPrinter.php - - src/Rules/NarrowPrivateClassMethodParamTypeRule.php - - src/Rules/NoArrayAccessOnObjectRule.php - - src/Rules/ReturnNullOverFalseRule.php - - - - identifier: phpstanApi.instanceofAssumption - paths: - - src/Rules/NoParamTypeRemovalRule.php diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index c8ec4d76..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - tests - - diff --git a/rector.php b/rector.php deleted file mode 100644 index 238b7781..00000000 --- a/rector.php +++ /dev/null @@ -1,28 +0,0 @@ -withPhpSets() - ->withRootFiles() - ->withPreparedSets( - codeQuality: true, - deadCode: true, - codingStyle: true, - typeDeclarations: true, - privatization: true, - naming: true, - earlyReturn: true - ) - ->withPaths([ - __DIR__ . '/config', - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->withImportNames(removeUnusedImports: true) - ->withSkip([ - '*/Source/*', - '*/Fixture/*', - ]); diff --git a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php index 89edda68..fd10e07d 100644 --- a/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php +++ b/src/Collector/ClassMethod/PublicClassMethodParamTypesCollector.php @@ -17,14 +17,30 @@ /** * @implements Collector */ -final readonly class PublicClassMethodParamTypesCollector implements Collector +final class PublicClassMethodParamTypesCollector implements Collector { - public function __construct( - private ApiDocStmtAnalyzer $apiDocStmtAnalyzer, - private PublicClassMethodMatcher $publicClassMethodMatcher, - private CollectorMetadataPrinter $collectorMetadataPrinter, - private Configuration $configuration - ) { + /** + * @readonly + */ + private ApiDocStmtAnalyzer $apiDocStmtAnalyzer; + /** + * @readonly + */ + private PublicClassMethodMatcher $publicClassMethodMatcher; + /** + * @readonly + */ + private CollectorMetadataPrinter $collectorMetadataPrinter; + /** + * @readonly + */ + private Configuration $configuration; + public function __construct(ApiDocStmtAnalyzer $apiDocStmtAnalyzer, PublicClassMethodMatcher $publicClassMethodMatcher, CollectorMetadataPrinter $collectorMetadataPrinter, Configuration $configuration) + { + $this->apiDocStmtAnalyzer = $apiDocStmtAnalyzer; + $this->publicClassMethodMatcher = $publicClassMethodMatcher; + $this->collectorMetadataPrinter = $collectorMetadataPrinter; + $this->configuration = $configuration; } public function getNodeType(): string diff --git a/src/Collector/MethodCall/MethodCallArgTypesCollector.php b/src/Collector/MethodCall/MethodCallArgTypesCollector.php index ffd412de..0d1ab5e2 100644 --- a/src/Collector/MethodCall/MethodCallArgTypesCollector.php +++ b/src/Collector/MethodCall/MethodCallArgTypesCollector.php @@ -18,13 +18,25 @@ /** * @implements Collector|null> */ -final readonly class MethodCallArgTypesCollector implements Collector +final class MethodCallArgTypesCollector implements Collector { - public function __construct( - private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - private CollectorMetadataPrinter $collectorMetadataPrinter, - private Configuration $configuration - ) { + /** + * @readonly + */ + private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver; + /** + * @readonly + */ + private CollectorMetadataPrinter $collectorMetadataPrinter; + /** + * @readonly + */ + private Configuration $configuration; + public function __construct(ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, CollectorMetadataPrinter $collectorMetadataPrinter, Configuration $configuration) + { + $this->classMethodCallReferenceResolver = $classMethodCallReferenceResolver; + $this->collectorMetadataPrinter = $collectorMetadataPrinter; + $this->configuration = $configuration; } public function getNodeType(): string diff --git a/src/Collector/MethodCallableNode/MethodCallableCollector.php b/src/Collector/MethodCallableNode/MethodCallableCollector.php index 0d52c657..c209ca22 100644 --- a/src/Collector/MethodCallableNode/MethodCallableCollector.php +++ b/src/Collector/MethodCallableNode/MethodCallableCollector.php @@ -19,12 +19,20 @@ * * @see https://github.com/phpstan/phpstan-src/blob/511c1e435fb43b8eb0ac310e6aa3230147963790/src/Analyser/NodeScopeResolver.php#L1936 */ -final readonly class MethodCallableCollector implements Collector +final class MethodCallableCollector implements Collector { - public function __construct( - private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, - private Configuration $configuration - ) { + /** + * @readonly + */ + private ClassMethodCallReferenceResolver $classMethodCallReferenceResolver; + /** + * @readonly + */ + private Configuration $configuration; + public function __construct(ClassMethodCallReferenceResolver $classMethodCallReferenceResolver, Configuration $configuration) + { + $this->classMethodCallReferenceResolver = $classMethodCallReferenceResolver; + $this->configuration = $configuration; } public function getNodeType(): string diff --git a/src/Configuration.php b/src/Configuration.php index 661329cf..82f81317 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -6,12 +6,17 @@ final class Configuration { + /** + * @var array + */ + private array $parameters; /** * @param array $parameters */ public function __construct( - private array $parameters + array $parameters ) { + $this->parameters = $parameters; // enabed by default in tests if (defined('PHPUNIT_COMPOSER_INSTALL')) { $this->parameters['narrow_param'] = true; diff --git a/src/Matcher/ClassMethodCallReferenceResolver.php b/src/Matcher/ClassMethodCallReferenceResolver.php index b9574210..137d2a04 100644 --- a/src/Matcher/ClassMethodCallReferenceResolver.php +++ b/src/Matcher/ClassMethodCallReferenceResolver.php @@ -14,7 +14,10 @@ final class ClassMethodCallReferenceResolver { - public function resolve(MethodCall|MethodCallableNode $methodCallOrMethodCallable, Scope $scope, bool $allowThisType): ?MethodCallReference + /** + * @param \PhpParser\Node\Expr\MethodCall|\PHPStan\Node\MethodCallableNode $methodCallOrMethodCallable + */ + public function resolve($methodCallOrMethodCallable, Scope $scope, bool $allowThisType): ?MethodCallReference { if ($methodCallOrMethodCallable instanceof MethodCallableNode) { $methodName = $methodCallOrMethodCallable->getName(); diff --git a/src/Matcher/Collector/PublicClassMethodMatcher.php b/src/Matcher/Collector/PublicClassMethodMatcher.php index 07261a03..a6a99009 100644 --- a/src/Matcher/Collector/PublicClassMethodMatcher.php +++ b/src/Matcher/Collector/PublicClassMethodMatcher.php @@ -71,6 +71,6 @@ public function shouldSkipClassMethod(ClassMethod $classMethod): bool $doc = $classMethod->getDocComment(); // skip symfony action - return $doc instanceof Doc && str_contains($doc->getText(), '@Route'); + return $doc instanceof Doc && strpos($doc->getText(), '@Route') !== false; } } diff --git a/src/NodeFinder/ClassMethodNodeFinder.php b/src/NodeFinder/ClassMethodNodeFinder.php index 6f45c4cb..4488d4c3 100644 --- a/src/NodeFinder/ClassMethodNodeFinder.php +++ b/src/NodeFinder/ClassMethodNodeFinder.php @@ -12,13 +12,16 @@ use PHPStan\Reflection\ClassReflection; use Rector\TypePerfect\Reflection\ReflectionParser; -final readonly class ClassMethodNodeFinder +final class ClassMethodNodeFinder { - public function __construct( - private ReflectionParser $reflectionParser, - ) { + /** + * @readonly + */ + private ReflectionParser $reflectionParser; + public function __construct(ReflectionParser $reflectionParser) + { + $this->reflectionParser = $reflectionParser; } - public function findByMethodCall(MethodCall $methodCall, Scope $scope): ?ClassMethod { $classReflection = $scope->getClassReflection(); diff --git a/src/NodeFinder/MethodCallNodeFinder.php b/src/NodeFinder/MethodCallNodeFinder.php index 040c1c51..c8c992ab 100644 --- a/src/NodeFinder/MethodCallNodeFinder.php +++ b/src/NodeFinder/MethodCallNodeFinder.php @@ -14,14 +14,25 @@ use Rector\TypePerfect\Reflection\ReflectionParser; use Webmozart\Assert\Assert; -final readonly class MethodCallNodeFinder +final class MethodCallNodeFinder { + /** + * @readonly + */ + private ReflectionParser $reflectionParser; + /** + * @readonly + */ + private NodeComparator $nodeComparator; + /** + * @readonly + */ private NodeFinder $nodeFinder; - public function __construct( - private ReflectionParser $reflectionParser, - private NodeComparator $nodeComparator, - ) { + public function __construct(ReflectionParser $reflectionParser, NodeComparator $nodeComparator) + { + $this->reflectionParser = $reflectionParser; + $this->nodeComparator = $nodeComparator; $this->nodeFinder = new NodeFinder(); } diff --git a/src/NodeFinder/ReturnNodeFinder.php b/src/NodeFinder/ReturnNodeFinder.php index 471a01fe..8fd6734f 100644 --- a/src/NodeFinder/ReturnNodeFinder.php +++ b/src/NodeFinder/ReturnNodeFinder.php @@ -12,9 +12,9 @@ use PhpParser\NodeTraverser; use Rector\TypePerfect\NodeVisitor\CallableNodeVisitor; -final readonly class ReturnNodeFinder +final class ReturnNodeFinder { - public function findOnlyReturnsExpr(ClassMethod $classMethod): Expr|null + public function findOnlyReturnsExpr(ClassMethod $classMethod): ?\PhpParser\Node\Expr { $returns = $this->findReturnsWithValues($classMethod); if (count($returns) !== 1) { diff --git a/src/NodeVisitor/CallableNodeVisitor.php b/src/NodeVisitor/CallableNodeVisitor.php index e0bb5699..ebb44582 100644 --- a/src/NodeVisitor/CallableNodeVisitor.php +++ b/src/NodeVisitor/CallableNodeVisitor.php @@ -25,7 +25,10 @@ public function __construct(callable $callable) $this->callable = $callable; } - public function enterNode(Node $node): int|Node|null + /** + * @return int|\PhpParser\Node|null + */ + public function enterNode(Node $node) { $originalNode = $node; $callable = $this->callable; diff --git a/src/PhpDoc/ApiDocStmtAnalyzer.php b/src/PhpDoc/ApiDocStmtAnalyzer.php index c6b2307c..2093629c 100644 --- a/src/PhpDoc/ApiDocStmtAnalyzer.php +++ b/src/PhpDoc/ApiDocStmtAnalyzer.php @@ -22,7 +22,7 @@ public function hasApiDoc(ClassMethod $classMethod, ClassReflection $classReflec return false; } - return str_contains($docComment->getText(), '@api'); + return strpos($docComment->getText(), '@api') !== false; } private function hasClassReflectionApiDoc(ClassReflection $classReflection): bool @@ -32,6 +32,6 @@ private function hasClassReflectionApiDoc(ClassReflection $classReflection): boo } $resolvedPhpDocBlock = $classReflection->getResolvedPhpDoc(); - return str_contains($resolvedPhpDocBlock->getPhpDocString(), '@api'); + return strpos($resolvedPhpDocBlock->getPhpDocString(), '@api') !== false; } } diff --git a/src/Printer/CollectorMetadataPrinter.php b/src/Printer/CollectorMetadataPrinter.php index afb8bc7d..d0408c2c 100644 --- a/src/Printer/CollectorMetadataPrinter.php +++ b/src/Printer/CollectorMetadataPrinter.php @@ -29,8 +29,11 @@ use PHPStan\Type\VerbosityLevel; use Rector\TypePerfect\Enum\Types\ResolvedTypes; -final readonly class CollectorMetadataPrinter +final class CollectorMetadataPrinter { + /** + * @readonly + */ private Standard $standard; public function __construct( @@ -120,7 +123,11 @@ private function transformSelfToClassName(Node $node, ?string $className): Node return new FullyQualified($className); } - private function resolveSortedTypes(UnionType|NodeIntersectionType $paramType, ?string $className): UnionType|NodeIntersectionType + /** + * @param \PhpParser\Node\UnionType|NodeIntersectionType $paramType + * @return \PhpParser\Node\UnionType|NodeIntersectionType + */ + private function resolveSortedTypes($paramType, ?string $className) { $typeNames = []; diff --git a/src/Printer/NodeComparator.php b/src/Printer/NodeComparator.php index 1d1efaef..e0a0aea6 100644 --- a/src/Printer/NodeComparator.php +++ b/src/Printer/NodeComparator.php @@ -7,11 +7,15 @@ use PhpParser\Node; use PHPStan\Node\Printer\Printer; -final readonly class NodeComparator +final class NodeComparator { - public function __construct( - private Printer $printer - ) { + /** + * @readonly + */ + private Printer $printer; + public function __construct(Printer $printer) + { + $this->printer = $printer; } public function areNodesEqual(Node $firstNode, Node $secondNode): bool diff --git a/src/Reflection/ReflectionParser.php b/src/Reflection/ReflectionParser.php index ab3fc546..407d1895 100644 --- a/src/Reflection/ReflectionParser.php +++ b/src/Reflection/ReflectionParser.php @@ -21,7 +21,10 @@ final class ReflectionParser */ private array $classesByFilename = []; - private readonly Parser $parser; + /** + * @readonly + */ + private Parser $parser; public function __construct() { @@ -39,7 +42,7 @@ public function parseClassReflection(ClassReflection $classReflection): ?ClassLi return $this->parseFilenameToClass($fileName); } - private function parseFilenameToClass(string $fileName): ClassLike|null + private function parseFilenameToClass(string $fileName): ?\PhpParser\Node\Stmt\ClassLike { if (isset($this->classesByFilename[$fileName])) { return $this->classesByFilename[$fileName]; @@ -58,7 +61,7 @@ private function parseFilenameToClass(string $fileName): ClassLike|null $nodeTraverser = new NodeTraverser(); $nodeTraverser->addVisitor(new NameResolver()); $nodeTraverser->traverse($stmts); - } catch (Throwable) { + } catch (Throwable $exception) { // not reachable return null; } diff --git a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php index 4c8d82e6..53f939ea 100644 --- a/src/Rules/NarrowPrivateClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPrivateClassMethodParamTypeRule.php @@ -31,18 +31,30 @@ * @see \Rector\TypePerfect\Tests\Rules\NarrowPrivateClassMethodParamTypeRule\NarrowPrivateClassMethodParamTypeRuleTest * @implements Rule */ -final readonly class NarrowPrivateClassMethodParamTypeRule implements Rule +final class NarrowPrivateClassMethodParamTypeRule implements Rule { + /** + * @readonly + */ + private Configuration $configuration; + /** + * @readonly + */ + private MethodCallNodeFinder $methodCallNodeFinder; + /** + * @readonly + */ + private ClassMethodNodeFinder $classMethodNodeFinder; /** * @var string */ public const ERROR_MESSAGE = 'Parameter %d should use "%s" type as the only type passed to this method'; - public function __construct( - private Configuration $configuration, - private MethodCallNodeFinder $methodCallNodeFinder, - private ClassMethodNodeFinder $classMethodNodeFinder - ) { + public function __construct(Configuration $configuration, MethodCallNodeFinder $methodCallNodeFinder, ClassMethodNodeFinder $classMethodNodeFinder) + { + $this->configuration = $configuration; + $this->methodCallNodeFinder = $methodCallNodeFinder; + $this->classMethodNodeFinder = $classMethodNodeFinder; } /** diff --git a/src/Rules/NarrowPublicClassMethodParamTypeRule.php b/src/Rules/NarrowPublicClassMethodParamTypeRule.php index 14645d90..a2f57d80 100644 --- a/src/Rules/NarrowPublicClassMethodParamTypeRule.php +++ b/src/Rules/NarrowPublicClassMethodParamTypeRule.php @@ -21,16 +21,20 @@ * * @implements Rule */ -final readonly class NarrowPublicClassMethodParamTypeRule implements Rule +final class NarrowPublicClassMethodParamTypeRule implements Rule { + /** + * @readonly + */ + private Configuration $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Parameters should have "%s" types as the only types passed to this method'; - public function __construct( - private Configuration $configuration - ) { + public function __construct(Configuration $configuration) + { + $this->configuration = $configuration; } /** diff --git a/src/Rules/NarrowReturnObjectTypeRule.php b/src/Rules/NarrowReturnObjectTypeRule.php index 295cb51d..9f3bacd6 100644 --- a/src/Rules/NarrowReturnObjectTypeRule.php +++ b/src/Rules/NarrowReturnObjectTypeRule.php @@ -24,18 +24,30 @@ * * @implements Rule */ -final readonly class NarrowReturnObjectTypeRule implements Rule +final class NarrowReturnObjectTypeRule implements Rule { + /** + * @readonly + */ + private ReturnNodeFinder $returnNodeFinder; + /** + * @readonly + */ + private MethodNodeAnalyser $methodNodeAnalyser; + /** + * @readonly + */ + private Configuration $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Provide more specific return type "%s" over abstract one'; - public function __construct( - private ReturnNodeFinder $returnNodeFinder, - private MethodNodeAnalyser $methodNodeAnalyser, - private Configuration $configuration - ) { + public function __construct(ReturnNodeFinder $returnNodeFinder, MethodNodeAnalyser $methodNodeAnalyser, Configuration $configuration) + { + $this->returnNodeFinder = $returnNodeFinder; + $this->methodNodeAnalyser = $methodNodeAnalyser; + $this->configuration = $configuration; } /** diff --git a/src/Rules/NoEmptyOnObjectRule.php b/src/Rules/NoEmptyOnObjectRule.php index 4a362301..269f316e 100644 --- a/src/Rules/NoEmptyOnObjectRule.php +++ b/src/Rules/NoEmptyOnObjectRule.php @@ -15,16 +15,20 @@ /** * @implements Rule */ -final readonly class NoEmptyOnObjectRule implements Rule +final class NoEmptyOnObjectRule implements Rule { + /** + * @readonly + */ + private EmptyIssetGuard $emptyIssetGuard; /** * @var string */ public const ERROR_MESSAGE = 'Use instanceof instead of empty() on object'; - public function __construct( - private EmptyIssetGuard $emptyIssetGuard - ) { + public function __construct(EmptyIssetGuard $emptyIssetGuard) + { + $this->emptyIssetGuard = $emptyIssetGuard; } public function getNodeType(): string diff --git a/src/Rules/NoIssetOnObjectRule.php b/src/Rules/NoIssetOnObjectRule.php index 3a60a442..0dc9cbe7 100644 --- a/src/Rules/NoIssetOnObjectRule.php +++ b/src/Rules/NoIssetOnObjectRule.php @@ -16,16 +16,20 @@ * @see \Rector\TypePerfect\Tests\Rules\NoIssetOnObjectRule\NoIssetOnObjectRuleTest * @implements Rule */ -final readonly class NoIssetOnObjectRule implements Rule +final class NoIssetOnObjectRule implements Rule { + /** + * @readonly + */ + private EmptyIssetGuard $emptyIssetGuard; /** * @var string */ public const ERROR_MESSAGE = 'Use instanceof instead of isset() on object'; - public function __construct( - private EmptyIssetGuard $emptyIssetGuard - ) { + public function __construct(EmptyIssetGuard $emptyIssetGuard) + { + $this->emptyIssetGuard = $emptyIssetGuard; } public function getNodeType(): string diff --git a/src/Rules/NoMixedMethodCallerRule.php b/src/Rules/NoMixedMethodCallerRule.php index a8de0d1e..8b64de6c 100644 --- a/src/Rules/NoMixedMethodCallerRule.php +++ b/src/Rules/NoMixedMethodCallerRule.php @@ -19,17 +19,25 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedMethodCallerRule\NoMixedMethodCallerRuleTest * @implements Rule */ -final readonly class NoMixedMethodCallerRule implements Rule +final class NoMixedMethodCallerRule implements Rule { + /** + * @readonly + */ + private Printer $printer; + /** + * @readonly + */ + private Configuration $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Mixed variable in a `%s->...()` can skip important errors. Make sure the type is known'; - public function __construct( - private Printer $printer, - private Configuration $configuration, - ) { + public function __construct(Printer $printer, Configuration $configuration) + { + $this->printer = $printer; + $this->configuration = $configuration; } /** diff --git a/src/Rules/NoMixedPropertyFetcherRule.php b/src/Rules/NoMixedPropertyFetcherRule.php index e715353c..f321cfcf 100644 --- a/src/Rules/NoMixedPropertyFetcherRule.php +++ b/src/Rules/NoMixedPropertyFetcherRule.php @@ -18,17 +18,25 @@ * @see \Rector\TypePerfect\Tests\Rules\NoMixedPropertyFetcherRule\NoMixedPropertyFetcherRuleTest * @implements Rule */ -final readonly class NoMixedPropertyFetcherRule implements Rule +final class NoMixedPropertyFetcherRule implements Rule { + /** + * @readonly + */ + private Printer $printer; + /** + * @readonly + */ + private Configuration $configuration; /** * @var string */ public const ERROR_MESSAGE = 'Mixed property fetch in a "%s->..." can skip important errors. Make sure the type is known'; - public function __construct( - private Printer $printer, - private Configuration $configuration, - ) { + public function __construct(Printer $printer, Configuration $configuration) + { + $this->printer = $printer; + $this->configuration = $configuration; } /** diff --git a/src/Rules/NoParamTypeRemovalRule.php b/src/Rules/NoParamTypeRemovalRule.php index cb473990..6ccf59f0 100644 --- a/src/Rules/NoParamTypeRemovalRule.php +++ b/src/Rules/NoParamTypeRemovalRule.php @@ -19,16 +19,20 @@ * @see \Rector\TypePerfect\Tests\Rules\ForbiddenParamTypeRemovalRule\ForbiddenParamTypeRemovalRuleTest * @implements Rule */ -final readonly class NoParamTypeRemovalRule implements Rule +final class NoParamTypeRemovalRule implements Rule { + /** + * @readonly + */ + private MethodNodeAnalyser $methodNodeAnalyser; /** * @var string */ public const ERROR_MESSAGE = 'Removing parent param type is forbidden'; - public function __construct( - private MethodNodeAnalyser $methodNodeAnalyser - ) { + public function __construct(MethodNodeAnalyser $methodNodeAnalyser) + { + $this->methodNodeAnalyser = $methodNodeAnalyser; } /** diff --git a/src/Rules/ReturnNullOverFalseRule.php b/src/Rules/ReturnNullOverFalseRule.php index de73e04d..ba9d8cae 100644 --- a/src/Rules/ReturnNullOverFalseRule.php +++ b/src/Rules/ReturnNullOverFalseRule.php @@ -19,19 +19,26 @@ /** * @implements Rule */ -final readonly class ReturnNullOverFalseRule implements Rule +final class ReturnNullOverFalseRule implements Rule { + /** + * @readonly + */ + private Configuration $configuration; /** * @api * @var string */ public const ERROR_MESSAGE = 'Returning false in non return bool class method. Use null with type|null instead or add bool return type'; + /** + * @readonly + */ private NodeFinder $nodeFinder; - public function __construct( - private Configuration $configuration, - ) { + public function __construct(Configuration $configuration) + { + $this->configuration = $configuration; $this->nodeFinder = new NodeFinder(); } diff --git a/src/ValueObject/MethodCallReference.php b/src/ValueObject/MethodCallReference.php index 9224546b..b14ed0ce 100644 --- a/src/ValueObject/MethodCallReference.php +++ b/src/ValueObject/MethodCallReference.php @@ -4,12 +4,20 @@ namespace Rector\TypePerfect\ValueObject; -final readonly class MethodCallReference +final class MethodCallReference { - public function __construct( - private string $class, - private string $method - ) { + /** + * @readonly + */ + private string $class; + /** + * @readonly + */ + private string $method; + public function __construct(string $class, string $method) + { + $this->class = $class; + $this->method = $method; } public function getClass(): string diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php deleted file mode 100644 index 31c25875..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DifferentClassSameMethodCallName.php +++ /dev/null @@ -1,31 +0,0 @@ -run($anotherClassWithRun); - } - - /** - * @param SomeStaticCall|MethodCall $node - */ - private function run(Node $node) - { - if ($node->name instanceof MethodCall) { - $this->run($node->name); - } - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php deleted file mode 100644 index a9a8d499..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/DoubleShot.php +++ /dev/null @@ -1,18 +0,0 @@ -isCheck($arg, $param); - } - private function isCheck(\PhpParser\Node $arg, \PhpParser\Node $param) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php deleted file mode 100644 index 68bd53cc..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/Fixture.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php deleted file mode 100644 index ecafcfb7..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAbstractBase.php +++ /dev/null @@ -1,16 +0,0 @@ -isCheck($arg); - } - private function isCheck(ConceptBase $arg) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php deleted file mode 100644 index f74f3dd6..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipAlreadyCorrectType.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheck($node); - } - } - - private function isCheck(MethodCall $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php deleted file mode 100644 index 9480df8a..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipCorrectUnionType.php +++ /dev/null @@ -1,32 +0,0 @@ -isIncludeOnceOrRequireOnce($node)) { - return []; - } - - return []; - } - - /** - * @param Assign|Return_ $node - */ - private function isIncludeOnceOrRequireOnce(\PhpParser\Node $node) - { - return true; - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php deleted file mode 100644 index 632fc7de..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php +++ /dev/null @@ -1,26 +0,0 @@ -printFile(new FileWithoutNamespace([])); - } - - private function printFile(\PhpParser\Node $node) - { - } - - public function secondMethod() - { - // some comment - $this->printFile(new FileNode([])); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php deleted file mode 100644 index e62b5097..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipGenericType.php +++ /dev/null @@ -1,31 +0,0 @@ -getsAGeneric($node); - } - - /** - * @param T $node - * @return void - */ - private function getsAGeneric(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php deleted file mode 100644 index b2658cd3..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMayOverrideArg.php +++ /dev/null @@ -1,27 +0,0 @@ -mayOverrideNode(); - - $this->isCheck($node); - - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php deleted file mode 100644 index 66a104e1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMixed.php +++ /dev/null @@ -1,18 +0,0 @@ -isCheck($arg); - } - private function isCheck(\PhpParser\Node $arg) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php deleted file mode 100644 index 1919ec98..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipMultipleUsed.php +++ /dev/null @@ -1,27 +0,0 @@ -isCheck($node); - } - - if ($node instanceof PropertyFetch) { - $this->isCheck($node); - } - } - - private function isCheck(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php deleted file mode 100644 index 90094439..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNoArgs.php +++ /dev/null @@ -1,15 +0,0 @@ -execute(); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php deleted file mode 100644 index 65436953..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotFromThis.php +++ /dev/null @@ -1,14 +0,0 @@ -format('Y-m-d'); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php deleted file mode 100644 index a16c0ad1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipNotPrivate.php +++ /dev/null @@ -1,22 +0,0 @@ -isCheckNotPrivate($node); - } - } - - public function isCheckNotPrivate(Node $node) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php deleted file mode 100644 index a74a81b1..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipOptedOut.php +++ /dev/null @@ -1,23 +0,0 @@ -isCheck($type); - } - - private function isCheck(\PHPStan\Type\Type $type) - { - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php deleted file mode 100644 index 04a51b74..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipParentNotIf.php +++ /dev/null @@ -1,15 +0,0 @@ -execute($node); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php deleted file mode 100644 index 7ebbdc60..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Fixture/SkipRecursive.php +++ /dev/null @@ -1,30 +0,0 @@ -run($node); - } - - /** - * @param SomeStaticCall|MethodCall $node - */ - private function run(Node $node): void - { - if ($node->name instanceof MethodCall) { - $this->run($node->name); - } - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php deleted file mode 100644 index 1005cc1d..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/NarrowPrivateClassMethodParamTypeRuleTest.php +++ /dev/null @@ -1,67 +0,0 @@ - $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorsWithLines): void - { - $this->analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipDuplicatedCallOfSameMethodWithComment.php', []]; - - yield [__DIR__ . '/Fixture/SkipCorrectUnionType.php', []]; - yield [__DIR__ . '/Fixture/SkipRecursive.php', []]; - yield [__DIR__ . '/Fixture/SkipMixed.php', []]; - yield [__DIR__ . '/Fixture/SkipOptedOut.php', []]; - yield [__DIR__ . '/Fixture/SkipNotFromThis.php', []]; - - yield [__DIR__ . '/Fixture/SkipParentNotIf.php', []]; - yield [__DIR__ . '/Fixture/SkipNoArgs.php', []]; - yield [__DIR__ . '/Fixture/SkipAlreadyCorrectType.php', []]; - yield [__DIR__ . '/Fixture/SkipMayOverrideArg.php', []]; - yield [__DIR__ . '/Fixture/SkipMultipleUsed.php', []]; - yield [__DIR__ . '/Fixture/SkipNotPrivate.php', []]; - - $errorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 1, MethodCall::class); - yield [__DIR__ . '/Fixture/Fixture.php', [[$errorMessage, 19]]]; - yield [__DIR__ . '/Fixture/DifferentClassSameMethodCallName.php', [[$errorMessage, 25]]]; - - $argErrorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 1, Arg::class); - $paramErrorMessage = sprintf(NarrowPrivateClassMethodParamTypeRule::ERROR_MESSAGE, 2, Param::class); - yield [__DIR__ . '/Fixture/DoubleShot.php', [[$argErrorMessage, 15], [$paramErrorMessage, 15]]]; - yield [__DIR__ . '/Fixture/SkipGenericType.php', []]; - yield [__DIR__ . '/Fixture/SkipAbstractBase.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowPrivateClassMethodParamTypeRule::class); - } -} diff --git a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php b/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php deleted file mode 100644 index 0b3ba332..00000000 --- a/tests/Rules/NarrowPrivateClassMethodParamTypeRule/Source/AnotherClassWithRun.php +++ /dev/null @@ -1,15 +0,0 @@ -callMe(...); - - $someCalledMethod->callMe(1000); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php deleted file mode 100644 index 3b1da8cc..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/FirstClassCallables/SomeCalledMethod.php +++ /dev/null @@ -1,12 +0,0 @@ -takesUnionWithDifferentDefaultValue(1); - - $o = new HandleDefaultValue(); - $o->takesUnionWithSameTypeDefaultValue(1); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php deleted file mode 100644 index b156afb1..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/PublicDoubleShot.php +++ /dev/null @@ -1,12 +0,0 @@ -map(function () {}); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php deleted file mode 100644 index 3efc7162..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipClassStringPassed.php +++ /dev/null @@ -1,12 +0,0 @@ -map(function () {}); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEnum.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEnum.php deleted file mode 100644 index 1d695daf..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEnum.php +++ /dev/null @@ -1,19 +0,0 @@ -pick(PickReasonEnum::BarcodeIssue); - } -} \ No newline at end of file diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php deleted file mode 100644 index 7c6cb87e..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipEqualUnionType.php +++ /dev/null @@ -1,44 +0,0 @@ -class - : $obj->var; - } - - public function runTernaryFlipped(StaticCall|MethodCall $obj) - { - return $obj instanceof MethodCall - ? $obj->var - : $obj->class; - } - - /** - * @param Node[]|Node $node - */ - public function runArrayTyped(array | Node $node) - { - } - - /** - * @param array|Node $node - */ - public function runArrayTyped2(array | Node $node) - { - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php deleted file mode 100644 index 1c722337..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExpectedClassType.php +++ /dev/null @@ -1,14 +0,0 @@ -callMe(1000); - } - - private function callMe($number) - { - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php deleted file mode 100644 index 70f5b1a7..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipNullableCompare.php +++ /dev/null @@ -1,14 +0,0 @@ -takesSelf(new SkipSelf()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php deleted file mode 100644 index c7670e11..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipThisPassedExactType.php +++ /dev/null @@ -1,14 +0,0 @@ -run(new DateTime('now')); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php deleted file mode 100644 index df4f8ebc..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ThisPassedFromInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(array $filePaths, array $expectedErrorsWithLines): void - { - $this->analyse($filePaths, $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [[__DIR__ . '/Fixture/SkipNonPublicClassMethod.php'], []]; - - // skip first class callables as anything can be passed there - yield [[ - __DIR__ . '/Fixture/FirstClassCallables/CallVariadics.php', - __DIR__ . '/Fixture/FirstClassCallables/SomeCalledMethod.php', - ], []]; - - // skip expected scalar type - yield [[ - __DIR__ . '/Fixture/SkipProperlyFilledParamType.php', - __DIR__ . '/Source/ExpectedType/FirstTypedCaller.php', - __DIR__ . '/Source/ExpectedType/SecondTypedCaller.php', - ], []]; - - // skip expected object type - yield [[ - __DIR__ . '/Fixture/SkipExpectedClassType.php', - __DIR__ . '/Source/ExpectedClassType/FirstClassTypedCaller.php', - __DIR__ . '/Source/ExpectedClassType/SecondClassTypedCaller.php', - ], []]; - - // skip class-string - yield [[ - __DIR__ . '/Fixture/SkipClassStringPassed.php', - __DIR__ . '/Source/ExpectedClassString/FirstTypedCaller.php', - __DIR__ . '/Source/ExpectedClassString/SecondTypedCaller.php', - ], []]; - - // skip everything in case of values is mixed - yield [[ - __DIR__ . '/Fixture/SkipMixedAndString.php', - __DIR__ . '/Source/MixedAndString/FirstCaller.php', - __DIR__ . '/Source/MixedAndString/SecondCaller.php', - ], []]; - - // skip int + string values - yield [[ - __DIR__ . '/Fixture/SkipMixedAndString.php', - __DIR__ . '/Source/MixedAndString/FirstCaller.php', - __DIR__ . '/Source/MixedAndString/ThirdCaller.php', - ], []]; - - // skip nullable compare - yield [[ - __DIR__ . '/Fixture/SkipNullableCompare.php', - __DIR__ . '/Source/NullableParam/FirstNullable.php', - __DIR__ . '/Source/NullableParam/SecondNullable.php', - ], []]; - - // skip api - yield [[ - __DIR__ . '/Fixture/SkipApiMarked.php', - __DIR__ . '/Source/ExpectedNodeApi/CallWithProperty.php', - ], []]; - - // skip equal union type - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionType.php', - ], []]; - - // skip equal union type flipped - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeFlipped.php', - ], []]; - - // skip equal union type ternary if else - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php', - ], []]; - - // skip equal union type ternary if else flipped - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php', - ], []]; - - // skip equal union type array typed - yield [[ - __DIR__ . '/Fixture/SkipEqualUnionType.php', - __DIR__ . '/Source/ExpectedUnion/CallUnionArrayType.php', - ], []]; - - // skip this passed exact type - yield [[ - __DIR__ . '/Fixture/SkipThisPassedExactType.php', - __DIR__ . '/Source/ExpectedThisType/CallByThis.php', - ], []]; - - // skip used internally for second type - yield [[ - __DIR__ . '/Fixture/SkipUsedInternallyForSecondType.php', - __DIR__ . '/Source/ExpectedType/OnlyFirstTypeCalledOutside.php', - ], []]; - - $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); - yield [[ - __DIR__ . '/Fixture/PublicDoubleShot.php', - __DIR__ . '/Source/FirstCaller.php', - __DIR__ . '/Source/SecondCaller.php', - ], [[$argErrorMessage, 9]]]; - - // this passed from interface - $argErrorMessage = sprintf( - NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, - CallByThisFromInterface::class - ); - yield [[ - __DIR__ . '/Fixture/ThisPassedFromInterface.php', - __DIR__ . '/Source/ExpectedThisType/CallByThisFromInterface.php', - ], [[$argErrorMessage, 11]]]; - - yield [[ - __DIR__ . '/Fixture/SkipSelf.php', - ], []]; - - yield [[ - __DIR__ . '/Fixture/SkipClosure.php', - ], []]; - - yield [[ - __DIR__ . '/Fixture/SkipCallable.php', - ], []]; - - yield [[ - __DIR__ . '/Fixture/SkipEnum.php', - ], []]; - - $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); - yield [[ - __DIR__ . '/Fixture/HandleDefaultValue.php', - ], [[$argErrorMessage, 15]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowPublicClassMethodParamTypeRule::class); - } - - /** - * Warning, just spent hour looking for why the test does not run :D This should be implicit part of the parent - * class. - * - * @return Collector[] - */ - protected function getCollectors(): array - { - return self::getContainer()->getServicesByTag('phpstan.collector'); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php deleted file mode 100644 index 35c8ce08..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/FirstTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php deleted file mode 100644 index 4d4815ab..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassString/SecondTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -resolve($classReflection->getName()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php deleted file mode 100644 index 8ad53ce6..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/FirstClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php deleted file mode 100644 index 222edca0..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedClassType/SecondClassTypedCaller.php +++ /dev/null @@ -1,17 +0,0 @@ -callMeWithClassType($knownType); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php deleted file mode 100644 index 44abed42..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedNodeApi/CallWithProperty.php +++ /dev/null @@ -1,17 +0,0 @@ -callNode($property); - } - -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php deleted file mode 100644 index e78ad816..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThis.php +++ /dev/null @@ -1,15 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php deleted file mode 100644 index eb90be0c..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedThisType/CallByThisFromInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -run($this); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php deleted file mode 100644 index 9eacb9d4..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/FirstTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php deleted file mode 100644 index a3e116a3..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/OnlyFirstTypeCalledOutside.php +++ /dev/null @@ -1,16 +0,0 @@ -run(new stdClass()); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php deleted file mode 100644 index cc0e2dfe..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedType/SecondTypedCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php deleted file mode 100644 index 813720b1..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionArrayType.php +++ /dev/null @@ -1,31 +0,0 @@ -runArrayTyped($node); - } - - public function run2(SkipEqualUnionType $skipEqualUnionType, Node $node): void - { - /** @var Node[]|Node $node */ - $node = rand(0, 1) - ? $node - : [$node]; - - $skipEqualUnionType->runArrayTyped2($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php deleted file mode 100644 index b3b11a0f..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionType.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php deleted file mode 100644 index a65c98bb..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -run($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php deleted file mode 100644 index 5643966a..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElse.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernary($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php deleted file mode 100644 index 2ac613fa..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/ExpectedUnion/CallUnionTypeTernaryIfElseFlipped.php +++ /dev/null @@ -1,22 +0,0 @@ -runTernaryFlipped($value); - } - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php deleted file mode 100644 index 81565e00..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php deleted file mode 100644 index abf52f56..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/FirstCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve('string'); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php deleted file mode 100644 index c087c8d7..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/SecondCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve($mixedValue); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php deleted file mode 100644 index 532bda8b..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/MixedAndString/ThirdCaller.php +++ /dev/null @@ -1,15 +0,0 @@ -resolve(1000); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php deleted file mode 100644 index b6668616..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/FirstNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php deleted file mode 100644 index 2ace4328..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/NullableParam/SecondNullable.php +++ /dev/null @@ -1,16 +0,0 @@ -callNode($node); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php deleted file mode 100644 index ee1a0d09..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/PassMeAsType.php +++ /dev/null @@ -1,10 +0,0 @@ -callMeTwice(100); - } -} diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php deleted file mode 100644 index ee3221b0..00000000 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Source/SomeInterface.php +++ /dev/null @@ -1,8 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipSpecificReturnType.php', []]; - yield [__DIR__ . '/Fixture/SkipSomeContract.php', []]; - - $errorMessage = sprintf(NarrowReturnObjectTypeRule::ERROR_MESSAGE, SpecificControl::class); - yield [__DIR__ . '/Fixture/SomeAbstractReturnType.php', [[$errorMessage, 12]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NarrowReturnObjectTypeRule::class); - } -} diff --git a/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php b/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php deleted file mode 100644 index 8b600f03..00000000 --- a/tests/Rules/NarrowReturnObjectTypeRule/Source/AbstractControl.php +++ /dev/null @@ -1,9 +0,0 @@ -children() as $name => $childElement) { - return isset($childElement['some']); - } - } -} diff --git a/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php b/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php deleted file mode 100644 index 7b5030f0..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/NoArrayAccessOnObjectRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/ArrayAccessOnObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]]; - yield [__DIR__ . '/Fixture/ArrayAccessOnNestedObject.php', [[NoArrayAccessOnObjectRule::ERROR_MESSAGE, 14]]]; - - yield [__DIR__ . '/Fixture/SkipIterator.php', []]; - yield [__DIR__ . '/Fixture/SkipOnArray.php', []]; - yield [__DIR__ . '/Fixture/SkipSplFixedArray.php', []]; - yield [__DIR__ . '/Fixture/SkipXml.php', []]; - yield [__DIR__ . '/Fixture/SkipXmlElementForeach.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoArrayAccessOnObjectRule::class); - } -} diff --git a/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php b/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php deleted file mode 100644 index a04d76d4..00000000 --- a/tests/Rules/NoArrayAccessOnObjectRule/Source/ChildOfSomeClassWithArrayAccess.php +++ /dev/null @@ -1,9 +0,0 @@ -args[9])) { - return $methodCall->args[9]; - } - } -} diff --git a/tests/Rules/NoEmptyOnObjectRule/Fixture/SkipPhpDocType.php b/tests/Rules/NoEmptyOnObjectRule/Fixture/SkipPhpDocType.php deleted file mode 100644 index ec18890f..00000000 --- a/tests/Rules/NoEmptyOnObjectRule/Fixture/SkipPhpDocType.php +++ /dev/null @@ -1,12 +0,0 @@ -foo = 'bar'; - } - } -} diff --git a/tests/Rules/NoEmptyOnObjectRule/NoEmptyOnObjectRuleTest.php b/tests/Rules/NoEmptyOnObjectRule/NoEmptyOnObjectRuleTest.php deleted file mode 100644 index 59ce9fd4..00000000 --- a/tests/Rules/NoEmptyOnObjectRule/NoEmptyOnObjectRuleTest.php +++ /dev/null @@ -1,46 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/EmptyOnObject.php', [[NoEmptyOnObjectRule::ERROR_MESSAGE, 19]]]; - - yield [__DIR__ . '/Fixture/SkipEmptyOnArray.php', []]; - yield [__DIR__ . '/Fixture/SkipEmptyOnArrayNestedOnObject.php', []]; - yield [__DIR__ . '/Fixture/SkipPossibleUndefinedVariable.php', []]; - yield [__DIR__ . '/Fixture/SkipPhpDocType.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoEmptyOnObjectRule::class); - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php b/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php deleted file mode 100644 index 8509aee3..00000000 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/IssetOnObject.php +++ /dev/null @@ -1,23 +0,0 @@ -args[9])) { - return $methodCall->args[9]; - } - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnPropertyFetch.php b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnPropertyFetch.php deleted file mode 100644 index 66f1bd5c..00000000 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipIssetOnPropertyFetch.php +++ /dev/null @@ -1,27 +0,0 @@ -initializeFoo(); - - $this->foo->sayHello(); - } - - private function initializeFoo(): void - { - if (!isset($this->foo)) - { - $this->foo = new Foo(); - } - } -} \ No newline at end of file diff --git a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipPhpDocType.php b/tests/Rules/NoIssetOnObjectRule/Fixture/SkipPhpDocType.php deleted file mode 100644 index a35ede98..00000000 --- a/tests/Rules/NoIssetOnObjectRule/Fixture/SkipPhpDocType.php +++ /dev/null @@ -1,12 +0,0 @@ -foo = 'bar'; - } - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php b/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php deleted file mode 100644 index a9f915b4..00000000 --- a/tests/Rules/NoIssetOnObjectRule/NoIssetOnObjectRuleTest.php +++ /dev/null @@ -1,47 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/IssetOnObject.php', [[NoIssetOnObjectRule::ERROR_MESSAGE, 19]]]; - - yield [__DIR__ . '/Fixture/SkipIssetOnArray.php', []]; - yield [__DIR__ . '/Fixture/SkipIssetOnArrayNestedOnObject.php', []]; - yield [__DIR__ . '/Fixture/SkipPossibleUndefinedVariable.php', []]; - yield [__DIR__ . '/Fixture/SkipIssetOnPropertyFetch.php', []]; - yield [__DIR__ . '/Fixture/SkipPhpDocType.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoIssetOnObjectRule::class); - } -} diff --git a/tests/Rules/NoIssetOnObjectRule/Source/Foo.php b/tests/Rules/NoIssetOnObjectRule/Source/Foo.php deleted file mode 100644 index d69a712f..00000000 --- a/tests/Rules/NoIssetOnObjectRule/Source/Foo.php +++ /dev/null @@ -1,13 +0,0 @@ -$magic(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php deleted file mode 100644 index 297d2526..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipKnownCallerType.php +++ /dev/null @@ -1,15 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php deleted file mode 100644 index 58168a73..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipMockObject.php +++ /dev/null @@ -1,19 +0,0 @@ -createMock(MagicMethodName::class); - - $mock - ->method('run') - ->willReturn(true); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php deleted file mode 100644 index ecf6e76e..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/SkipPHPUnitMock.php +++ /dev/null @@ -1,21 +0,0 @@ -createMock(SomeFinalClass::class); - - $someClassMock->expects($this->once()) - ->method('some') - ->with($this->any()) - ->willReturn(1000); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php b/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php deleted file mode 100644 index 5a01e193..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Fixture/UnknownCallerType.php +++ /dev/null @@ -1,13 +0,0 @@ -call(); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php b/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php deleted file mode 100644 index ffc37211..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/NoMixedMethodCallerRuleTest.php +++ /dev/null @@ -1,49 +0,0 @@ - $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorsWithLines): void - { - $this->analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipKnownCallerType.php', []]; - yield [__DIR__ . '/Fixture/SkipMockObject.php', []]; - yield [__DIR__ . '/Fixture/SkipPHPUnitMock.php', []]; - - $errorMessage = sprintf(NoMixedMethodCallerRule::ERROR_MESSAGE, '$someType'); - yield [__DIR__ . '/Fixture/MagicMethodName.php', [[$errorMessage, 11]]]; - - $errorMessage = sprintf(NoMixedMethodCallerRule::ERROR_MESSAGE, '$mixedType'); - yield [__DIR__ . '/Fixture/UnknownCallerType.php', [[$errorMessage, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedMethodCallerRule::class); - } -} diff --git a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php b/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php deleted file mode 100644 index 75536c75..00000000 --- a/tests/Rules/NoMixedMethodCallerRule/Source/KnownType.php +++ /dev/null @@ -1,12 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php deleted file mode 100644 index c3812a18..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipDynamicNameWithKnownType.php +++ /dev/null @@ -1,15 +0,0 @@ -{$name}; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php deleted file mode 100644 index 48ec8acc..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/SkipKnownFetcherType.php +++ /dev/null @@ -1,15 +0,0 @@ -name; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php b/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php deleted file mode 100644 index ef906f07..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Fixture/UnknownPropertyFetcher.php +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php b/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php deleted file mode 100644 index 6d84b500..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/NoMixedPropertyFetcherRuleTest.php +++ /dev/null @@ -1,48 +0,0 @@ - $expectedErrorsWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorsWithLines): void - { - $this->analyse([$filePath], $expectedErrorsWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipDynamicNameWithKnownType.php', []]; - yield [__DIR__ . '/Fixture/SkipKnownFetcherType.php', []]; - - $message = sprintf(NoMixedPropertyFetcherRule::ERROR_MESSAGE, '$unknownType'); - yield [__DIR__ . '/Fixture/DynamicName.php', [[$message, 11]]]; - - $message = sprintf(NoMixedPropertyFetcherRule::ERROR_MESSAGE, '$unknownType'); - yield [__DIR__ . '/Fixture/UnknownPropertyFetcher.php', [[$message, 11]]]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoMixedPropertyFetcherRule::class); - } -} diff --git a/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php b/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php deleted file mode 100644 index 2655c864..00000000 --- a/tests/Rules/NoMixedPropertyFetcherRule/Source/KnownType.php +++ /dev/null @@ -1,10 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [__DIR__ . '/Fixture/SkipConstruct.php', []]; - yield [__DIR__ . '/Fixture/SkipPhpDocType.php', []]; - yield [__DIR__ . '/Fixture/SkipPresentType.php', []]; - yield [__DIR__ . '/Fixture/SkipNoType.php', []]; - - yield [__DIR__ . '/Fixture/SkipIndirectRemoval.php', []]; - - yield [__DIR__ . '/Fixture/RemoveParentType.php', [[NoParamTypeRemovalRule::ERROR_MESSAGE, 11]]]; - - yield [__DIR__ . '/Fixture/SkipNoParent.php', []]; - yield [__DIR__ . '/Fixture/SkipNotHasParentMethod.php', []]; - yield [__DIR__ . '/Fixture/SkipHasSameParameterWithParentMethod.php', []]; - yield [__DIR__ . '/Fixture/SkipHasSameParameterWithInterfaceMethod.php', []]; - - yield [ - __DIR__ . '/Fixture/HasDifferentParameterWithParentMethod.php', - [[NoParamTypeRemovalRule::ERROR_MESSAGE, 9]], - ]; - yield [ - __DIR__ . '/Fixture/HasDifferentParameterWithInterfaceMethod.php', - [[NoParamTypeRemovalRule::ERROR_MESSAGE, 9], [ - NoParamTypeRemovalRule::ERROR_MESSAGE, - 13, - ]], - ]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(NoParamTypeRemovalRule::class); - } -} diff --git a/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php b/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php deleted file mode 100644 index 333fbd22..00000000 --- a/tests/Rules/NoParamTypeRemovalRule/Source/NoTypeInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -loadFromDb($name)) { - return false; - } - - return true; - } - - private function loadFromDb(string $name): ?array - { - if (mt_rand(1, 0)) { - return null; - } - - return ['test' => 'foo']; - } -} diff --git a/tests/Rules/ReturnNullOverFalseRule/Fixture/CheckResultFromOtherMethod2.php b/tests/Rules/ReturnNullOverFalseRule/Fixture/CheckResultFromOtherMethod2.php deleted file mode 100644 index 65fe0768..00000000 --- a/tests/Rules/ReturnNullOverFalseRule/Fixture/CheckResultFromOtherMethod2.php +++ /dev/null @@ -1,31 +0,0 @@ -isPropertyVisible($name)) { - return false; - } - - return isset($this->$name); - } - - private function isPropertyVisible(string $name): bool - { - if (mt_rand(1, 0)) { - return true; - } - - return false; - } -} diff --git a/tests/Rules/ReturnNullOverFalseRule/Fixture/ReturnFalseOnly.php b/tests/Rules/ReturnNullOverFalseRule/Fixture/ReturnFalseOnly.php deleted file mode 100644 index 0b91cf97..00000000 --- a/tests/Rules/ReturnNullOverFalseRule/Fixture/ReturnFalseOnly.php +++ /dev/null @@ -1,17 +0,0 @@ - $expectedErrorMessagesWithLines - */ - #[DataProvider('provideData')] - public function testRule(string $filePath, array $expectedErrorMessagesWithLines): void - { - $this->analyse([$filePath], $expectedErrorMessagesWithLines); - } - - public static function provideData(): Iterator - { - yield [ - __DIR__ . '/Fixture/ReturnFalseOnly.php', - [[ReturnNullOverFalseRule::ERROR_MESSAGE, 9]], - ]; - yield [__DIR__ . '/Fixture/CheckResultFromOtherMethod.php', []]; - yield [__DIR__ . '/Fixture/CheckResultFromOtherMethod2.php', []]; - - yield [__DIR__ . '/Fixture/SkipReturnBool.php', []]; - } - - /** - * @return string[] - */ - public static function getAdditionalConfigFiles(): array - { - return [__DIR__ . '/../../../config/extension.neon']; - } - - protected function getRule(): Rule - { - return self::getContainer()->getByType(ReturnNullOverFalseRule::class); - } -} diff --git a/tests/SomeClass.php.inc b/tests/SomeClass.php.inc deleted file mode 100644 index 17ce8504..00000000 --- a/tests/SomeClass.php.inc +++ /dev/null @@ -1,13 +0,0 @@ -name; - } -} diff --git a/tests/config/included_services.neon b/tests/config/included_services.neon deleted file mode 100644 index 6291a434..00000000 --- a/tests/config/included_services.neon +++ /dev/null @@ -1,2 +0,0 @@ -includes: - - ../../config/services.neon