diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/extends_parent_with_private_construct.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/extends_parent_with_private_construct.php.inc deleted file mode 100644 index ebc453d9a4c..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/extends_parent_with_private_construct.php.inc +++ /dev/null @@ -1,46 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} - -?> ------ - $this->user_id ?? $this->application->get(MissingValue::class), - ]; - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/fixture.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/fixture.php.inc deleted file mode 100644 index b92c4f6e5e5..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/fixture.php.inc +++ /dev/null @@ -1,34 +0,0 @@ - ------ -targetFileSystem->dumpFile('file', 'content'); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_construct.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_construct.php.inc deleted file mode 100644 index c68300797d4..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_construct.php.inc +++ /dev/null @@ -1,47 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} - -?> ------ - $this->user_id ?? $this->application->get(MissingValue::class), - ]; - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_empty_construct.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_empty_construct.php.inc deleted file mode 100644 index af9f208f319..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/follow_parent_empty_construct.php.inc +++ /dev/null @@ -1,47 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} - -?> ------ - $this->user_id ?? $this->application->get(MissingValue::class), - ]; - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/in_constructor.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/in_constructor.php.inc deleted file mode 100644 index c47a4d1d480..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/in_constructor.php.inc +++ /dev/null @@ -1,31 +0,0 @@ - ------ -dumpFile('file', 'content'); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/instant_make_in_static_method.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/instant_make_in_static_method.php.inc deleted file mode 100644 index 18d19123c67..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/instant_make_in_static_method.php.inc +++ /dev/null @@ -1,37 +0,0 @@ - 123])->render(); - - return FileSystem::write('file', 'content'); - } -} - -?> ------ -view('example', ['new_example' => 123])->render(); - - return (new \Rector\Tests\Transform\Rector\StaticCall\StaticCallToMethodCallRector\Source\TargetFileSystem())->dumpFile('file', 'content'); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_method.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_method.php.inc deleted file mode 100644 index a0fc4d87597..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_method.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ -getSmartFileSystem()->dumpFile('file', 'content'); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_property.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_property.php.inc deleted file mode 100644 index e97b039a668..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/re_use_parent_property.php.inc +++ /dev/null @@ -1,33 +0,0 @@ - ------ -smartFileSystemProperty->dumpFile('file', 'content'); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/skip_when_parent_has_final_construct.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/skip_when_parent_has_final_construct.php.inc deleted file mode 100644 index 471e647b0a7..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/skip_when_parent_has_final_construct.php.inc +++ /dev/null @@ -1,19 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/with_asterisk.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/with_asterisk.php.inc deleted file mode 100644 index efdd63625cc..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Fixture/with_asterisk.php.inc +++ /dev/null @@ -1,34 +0,0 @@ - 123]); - } -} - -?> ------ -responseFactory->view('example', ['new_example' => 123]); - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_construct_on_php74.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_construct_on_php74.php.inc deleted file mode 100644 index 39bb72454ee..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_construct_on_php74.php.inc +++ /dev/null @@ -1,49 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} - -?> ------ -application = $application; - } - public function toArray( - Request $request, - ): array { - return [ - 'user_id' => $this->user_id ?? $this->application->get(MissingValue::class), - ]; - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_empty_construct_on_php74.php.inc b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_empty_construct_on_php74.php.inc deleted file mode 100644 index a3e30933dfb..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/FixturePhp74/follow_parent_empty_construct_on_php74.php.inc +++ /dev/null @@ -1,49 +0,0 @@ - $this->user_id ?? App::get(MissingValue::class), - ]; - } -} - -?> ------ -application = $application; - } - public function toArray( - Request $request, - ): array { - return [ - 'user_id' => $this->user_id ?? $this->application->get(MissingValue::class), - ]; - } -} - -?> diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ClassWithFileSystem.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ClassWithFileSystem.php deleted file mode 100644 index 7718207b12b..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ClassWithFileSystem.php +++ /dev/null @@ -1,13 +0,0 @@ -resource = $resource; - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ResourceWithFinalConstruct.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ResourceWithFinalConstruct.php deleted file mode 100644 index 045ff2ce346..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/ResourceWithFinalConstruct.php +++ /dev/null @@ -1,15 +0,0 @@ -resource = $resource; - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/SomeResource.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/SomeResource.php deleted file mode 100644 index a4ea1a30416..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/Source/SomeResource.php +++ /dev/null @@ -1,12 +0,0 @@ -resource = new \SimpleXMLElement(''); - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorOnPhp74Test.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorOnPhp74Test.php deleted file mode 100644 index 8cb1fd30f64..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorOnPhp74Test.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/FixturePhp74'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule_php74.php'; - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php deleted file mode 100644 index b81a2775c16..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/StaticCallToMethodCallRectorTest.php +++ /dev/null @@ -1,28 +0,0 @@ -doTestFile($filePath); - } - - public static function provideData(): Iterator - { - return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); - } - - public function provideConfigFilePath(): string - { - return __DIR__ . '/config/configured_rule.php'; - } -} diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php deleted file mode 100644 index 27840daff3a..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule.php +++ /dev/null @@ -1,30 +0,0 @@ -phpVersion(PhpVersionFeature::PROPERTY_PROMOTION); - - $rectorConfig - ->ruleWithConfiguration(StaticCallToMethodCallRector::class, [ - new StaticCallToMethodCall('Nette\Utils\FileSystem', 'write', TargetFileSystem::class, 'dumpFile'), - new StaticCallToMethodCall( - 'Illuminate\Support\Facades\Response', - '*', - 'Illuminate\Contracts\Routing\ResponseFactory', - '*' - ), - new StaticCallToMethodCall( - 'Illuminate\Support\Facades\App', - '*', - 'Illuminate\Foundation\Application', - '*' - ), - ]); -}; diff --git a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule_php74.php b/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule_php74.php deleted file mode 100644 index 14b7207f17a..00000000000 --- a/rules-tests/Transform/Rector/StaticCall/StaticCallToMethodCallRector/config/configured_rule_php74.php +++ /dev/null @@ -1,22 +0,0 @@ -phpVersion(PhpVersionFeature::TYPED_PROPERTIES); - - $rectorConfig - ->ruleWithConfiguration(StaticCallToMethodCallRector::class, [ - new StaticCallToMethodCall( - 'Illuminate\Support\Facades\App', - '*', - 'Illuminate\Foundation\Application', - '*' - ), - ]); -}; diff --git a/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php b/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php deleted file mode 100644 index da0fde8e337..00000000000 --- a/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php +++ /dev/null @@ -1,79 +0,0 @@ -typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass( - $class, - $classMethod, - $objectType, - ); - - if ($expr instanceof Expr) { - if ($expr instanceof Variable) { - $this->addClassMethodParamForVariable($expr, $objectType, $classMethod); - } - - return $expr; - } - - // Cannot add constructor dependency when nearest parent constructor is final - if ($this->classDependencyManipulator->hasFinalParentConstructor($class)) { - return null; - } - - $propertyName = $this->propertyNaming->fqnToVariableName($objectType); - $this->classDependencyManipulator->addConstructorDependency( - $class, - new PropertyMetadata($propertyName, $objectType) - ); - - return $this->propertyFetchFactory->createFromType($objectType); - } - - private function addClassMethodParamForVariable( - Variable $variable, - ObjectType $objectType, - ClassMethod|Function_ $functionLike - ): void { - /** @var string $variableName */ - $variableName = $this->nodeNameResolver->getName($variable); - - // add variable to __construct as dependency - $functionLike->params[] = $this->nodeFactory->createParamFromNameAndType($variableName, $objectType); - } -} diff --git a/rules/Transform/NodeFactory/PropertyFetchFactory.php b/rules/Transform/NodeFactory/PropertyFetchFactory.php deleted file mode 100644 index 16b1d39ab83..00000000000 --- a/rules/Transform/NodeFactory/PropertyFetchFactory.php +++ /dev/null @@ -1,26 +0,0 @@ -propertyNaming->fqnToVariableName($objectType->getClassName()); - - return new PropertyFetch($thisVariable, $propertyName); - } -} diff --git a/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php b/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php deleted file mode 100644 index 2b3350c354c..00000000000 --- a/rules/Transform/NodeTypeAnalyzer/TypeProvidingExprFromClassResolver.php +++ /dev/null @@ -1,145 +0,0 @@ -nodeNameResolver->getName($class); - - // A. match a method - $classReflection = $this->reflectionProvider->getClass($className); - $methodCallProvidingType = $this->resolveMethodCallProvidingType($classReflection, $objectType); - if ($methodCallProvidingType instanceof MethodCall) { - return $methodCallProvidingType; - } - - // B. match existing property - $propertyFetch = $this->resolvePropertyFetchProvidingType($classReflection, $objectType); - if ($propertyFetch instanceof PropertyFetch) { - return $propertyFetch; - } - - // C. param in constructor? - return $this->resolveConstructorParamProvidingType($classMethod, $objectType); - } - - private function resolveMethodCallProvidingType( - ClassReflection $classReflection, - ObjectType $objectType - ): ?MethodCall { - $methodReflections = $this->getClassMethodReflections($classReflection); - - foreach ($methodReflections as $methodReflection) { - $functionVariant = ParametersAcceptorSelector::combineAcceptors($methodReflection->getVariants()); - $returnType = $functionVariant->getReturnType(); - - if (! $this->isMatchingType($returnType, $objectType)) { - continue; - } - - $thisVariable = new Variable('this'); - return new MethodCall($thisVariable, $methodReflection->getName()); - } - - return null; - } - - private function resolvePropertyFetchProvidingType( - ClassReflection $classReflection, - ObjectType $objectType - ): ?PropertyFetch { - $nativeReflectionClass = $classReflection->getNativeReflection(); - - foreach ($nativeReflectionClass->getProperties() as $reflectionProperty) { - $phpPropertyReflection = $classReflection->getNativeProperty($reflectionProperty->getName()); - - $readableType = $phpPropertyReflection->getReadableType(); - if (! $this->isMatchingType($readableType, $objectType)) { - continue; - } - - return new PropertyFetch(new Variable('this'), $reflectionProperty->getName()); - } - - return null; - } - - private function resolveConstructorParamProvidingType( - ClassMethod $classMethod, - ObjectType $objectType - ): ?Variable { - if (! $this->nodeNameResolver->isName($classMethod, MethodName::CONSTRUCT)) { - return null; - } - - $variableName = $this->propertyNaming->fqnToVariableName($objectType); - return new Variable($variableName); - } - - private function isMatchingType(Type $readableType, ObjectType $objectType): bool - { - if ($readableType instanceof MixedType) { - return false; - } - - $readableType = TypeCombinator::removeNull($readableType); - $className = ClassNameFromObjectTypeResolver::resolve($readableType); - - if ($className === null) { - return false; - } - - return $readableType->equals($objectType); - } - - /** - * @return MethodReflection[] - */ - private function getClassMethodReflections(ClassReflection $classReflection): array - { - $nativeReflection = $classReflection->getNativeReflection(); - $methodReflections = []; - - foreach ($nativeReflection->getMethods() as $reflectionMethod) { - $methodReflections[] = $classReflection->getNativeMethod($reflectionMethod->getName()); - } - - return $methodReflections; - } -} diff --git a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php index 0ac046f61b6..53d21553326 100644 --- a/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php +++ b/rules/Transform/Rector/StaticCall/StaticCallToMethodCallRector.php @@ -5,37 +5,20 @@ namespace Rector\Transform\Rector\StaticCall; use PhpParser\Node; -use PhpParser\Node\Expr\MethodCall; -use PhpParser\Node\Expr\New_; -use PhpParser\Node\Expr\StaticCall; -use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt\Class_; +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Exception\ShouldNotHappenException; use Rector\Rector\AbstractRector; use Rector\RuleDoc\CodeSample\ConfiguredCodeSample; use Rector\RuleDoc\RuleDefinition; -use Rector\Transform\NodeAnalyzer\FuncCallStaticCallToMethodCallAnalyzer; use Rector\Transform\ValueObject\StaticCallToMethodCall; -use Webmozart\Assert\Assert; /** - * @note used in Laravel Rector https://github.com/driftingly/rector-laravel/blob/f46812350e0b4ef535c82d3759e86bb5c6abb651/config/sets/laravel-static-to-injection.php#L23 - * - * @see \Rector\Tests\Transform\Rector\StaticCall\StaticCallToMethodCallRector\StaticCallToMethodCallRectorTest + * @deprecated This rule is deprecated, as passing a service through the constructor to replace a static call is risky and this generic rule is legacy. Write a custom rule for the exact project case instead. */ -final class StaticCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface +final class StaticCallToMethodCallRector extends AbstractRector implements ConfigurableRectorInterface, DeprecatedInterface { - /** - * @var StaticCallToMethodCall[] - */ - private array $staticCallsToMethodCalls = []; - - public function __construct( - private readonly FuncCallStaticCallToMethodCallAnalyzer $funcCallStaticCallToMethodCallAnalyzer - ) { - } - public function getRuleDefinition(): RuleDefinition { return new RuleDefinition('Change static call to service method via constructor injection', [ @@ -99,54 +82,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - $class = $node; - $hasChanged = false; - - foreach ($node->getMethods() as $classMethod) { - $this->traverseNodesWithCallable($classMethod, function (Node $node) use ( - $class, - $classMethod, - &$hasChanged - ): null|MethodCall|StaticCall { - if (! $node instanceof StaticCall) { - return null; - } - - foreach ($this->staticCallsToMethodCalls as $staticCallToMethodCall) { - if (! $staticCallToMethodCall->isStaticCallMatch($node)) { - continue; - } - - if ($classMethod->isStatic()) { - return $this->refactorToInstanceCall($node, $staticCallToMethodCall); - } - - $expr = $this->funcCallStaticCallToMethodCallAnalyzer->matchTypeProvidingExpr( - $class, - $classMethod, - $staticCallToMethodCall->getClassObjectType(), - ); - - if ($expr === null) { - return null; - } - - $methodName = $this->getMethodName($node, $staticCallToMethodCall); - - $hasChanged = true; - - return new MethodCall($expr, $methodName, $node->args); - } - - return $node; - }); - } - - if ($hasChanged) { - return $node; - } - - return null; + throw new ShouldNotHappenException(sprintf( + '"%s" rule is deprecated, as passing a service through the constructor to replace a static call is risky; write a custom rule for the exact project case instead', + self::class + )); } /** @@ -154,36 +93,5 @@ public function refactor(Node $node): ?Node */ public function configure(array $configuration): void { - Assert::allIsAOf($configuration, StaticCallToMethodCall::class); - - $this->staticCallsToMethodCalls = $configuration; - } - - private function getMethodName( - StaticCall $staticCall, - StaticCallToMethodCall $staticCallToMethodCall - ): string { - if ($staticCallToMethodCall->getMethodName() === '*') { - $methodName = $this->getName($staticCall->name); - } else { - $methodName = $staticCallToMethodCall->getMethodName(); - } - - if (! is_string($methodName)) { - throw new ShouldNotHappenException(); - } - - return $methodName; - } - - private function refactorToInstanceCall( - StaticCall $staticCall, - StaticCallToMethodCall $staticCallToMethodCall - ): MethodCall { - $new = new New_(new FullyQualified($staticCallToMethodCall->getClassType())); - - $methodName = $this->getMethodName($staticCall, $staticCallToMethodCall); - - return new MethodCall($new, $methodName, $staticCall->args); } } diff --git a/rules/Transform/ValueObject/StaticCallToMethodCall.php b/rules/Transform/ValueObject/StaticCallToMethodCall.php index e6cfd1b5300..693d3c27697 100644 --- a/rules/Transform/ValueObject/StaticCallToMethodCall.php +++ b/rules/Transform/ValueObject/StaticCallToMethodCall.php @@ -10,6 +10,9 @@ use PHPStan\Type\ObjectType; use Rector\Validation\RectorAssert; +/** + * @api used in deprecated StaticCallToMethodCallRector configs + */ final readonly class StaticCallToMethodCall { public function __construct( diff --git a/src/NodeManipulator/ClassDependencyManipulator.php b/src/NodeManipulator/ClassDependencyManipulator.php index 565ab0099a1..e51993b8f55 100644 --- a/src/NodeManipulator/ClassDependencyManipulator.php +++ b/src/NodeManipulator/ClassDependencyManipulator.php @@ -33,6 +33,7 @@ use Rector\ValueObject\PhpVersionFeature; /** + * @api used by rector-symfony and rector-doctrine * @see \Rector\Tests\NodeManipulator\ClassDependencyManipulatorTest */ final readonly class ClassDependencyManipulator @@ -190,33 +191,6 @@ public function addStmtsToConstructorIfNotThereYet(Class_ $class, array $stmts): $classMethod->stmts = array_merge($stmts, (array) $classMethod->stmts); } - public function hasFinalParentConstructor(Class_ $class): bool - { - if ($class->getMethod(MethodName::CONSTRUCT) instanceof ClassMethod) { - return false; - } - - $classReflection = $this->reflectionResolver->resolveClassReflection($class); - if (! $classReflection instanceof ClassReflection) { - return false; - } - - $ancestors = array_filter( - $classReflection->getAncestors(), - static fn (ClassReflection $ancestor): bool => $ancestor->getName() !== $classReflection->getName() - ); - - foreach ($ancestors as $ancestor) { - if (! $ancestor->hasNativeMethod(MethodName::CONSTRUCT)) { - continue; - } - - return $ancestor->getNativeMethod(MethodName::CONSTRUCT)->isFinalByKeyword()->yes(); - } - - return false; - } - private function resolveConstruct(Class_ $class): ?ClassMethod { $constructorMethod = $class->getMethod(MethodName::CONSTRUCT);