diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 3ca32b36378..304a6e14250 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -69,7 +69,6 @@ use Rector\PhpParser\NodeVisitor\AssignedToNodeVisitor; use Rector\PhpParser\NodeVisitor\ByRefReturnNodeVisitor; use Rector\PhpParser\NodeVisitor\ByRefVariableNodeVisitor; -use Rector\PhpParser\NodeVisitor\CallLikeThisBoundClosureArgsNodeVisitor; use Rector\PhpParser\NodeVisitor\ClassConstFetchNodeVisitor; use Rector\PhpParser\NodeVisitor\ClosureWithVariadicParametersNodeVisitor; use Rector\PhpParser\NodeVisitor\ContextNodeVisitor; @@ -171,7 +170,6 @@ final class LazyContainerFactory PropertyOrClassConstDefaultNodeVisitor::class, ParamDefaultNodeVisitor::class, ClassConstFetchNodeVisitor::class, - CallLikeThisBoundClosureArgsNodeVisitor::class, ArgNotAcceptingClosureNodeVisitor::class, ]; diff --git a/src/NodeAnalyzer/CallLikeExpectsThisBoundClosureArgsAnalyzer.php b/src/NodeAnalyzer/CallLikeExpectsThisBoundClosureArgsAnalyzer.php deleted file mode 100644 index a5039df661c..00000000000 --- a/src/NodeAnalyzer/CallLikeExpectsThisBoundClosureArgsAnalyzer.php +++ /dev/null @@ -1,91 +0,0 @@ -isFirstClassCallable() || $callLike->getArgs() === []) { - return []; - } - - $callArgs = $callLike->getArgs(); - $hasClosureArg = (bool) array_filter($callArgs, fn (Arg $arg): bool => $arg->value instanceof Closure); - - if (! $hasClosureArg) { - return []; - } - - $argsUsingThisBoundClosure = []; - - $reflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($callLike); - - if ($reflection === null) { - return []; - } - - $scope = $callLike->getAttribute(AttributeKey::SCOPE); - - if ($scope === null) { - return []; - } - - $parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select($reflection, $callLike, $scope); - $parameters = $parametersAcceptor->getParameters(); - - foreach ($callArgs as $index => $arg) { - if (! $arg->value instanceof Closure) { - continue; - } - - if ($arg->name?->name !== null) { - foreach ($parameters as $parameter) { - if (! $parameter instanceof ExtendedParameterReflection) { - continue; - } - - $hasObjectBinding = (bool) $parameter->getClosureThisType(); - if ($hasObjectBinding && $arg->name->name === $parameter->getName()) { - $argsUsingThisBoundClosure[] = $arg; - } - } - - continue; - } - - if (! is_string($arg->name?->name)) { - $parameter = $parameters[$index] ?? null; - - if (! $parameter instanceof ExtendedParameterReflection) { - continue; - } - - $hasObjectBinding = (bool) $parameter->getClosureThisType(); - if ($hasObjectBinding) { - $argsUsingThisBoundClosure[] = $arg; - } - } - } - - return $argsUsingThisBoundClosure; - } -} diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index 482b8856091..c902a3ae221 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -167,8 +167,6 @@ final class AttributeKey public const string PHP_VERSION_CONDITIONED = 'php_version_conditioned'; - public const string IS_CLOSURE_USES_THIS = 'has_this_closure'; - public const string HAS_CLOSURE_WITH_VARIADIC_ARGS = 'has_closure_with_variadic_args'; public const string IS_IN_TRY_BLOCK = 'is_in_try_block'; diff --git a/src/PhpParser/NodeVisitor/CallLikeThisBoundClosureArgsNodeVisitor.php b/src/PhpParser/NodeVisitor/CallLikeThisBoundClosureArgsNodeVisitor.php deleted file mode 100644 index 96a5ce9c64a..00000000000 --- a/src/PhpParser/NodeVisitor/CallLikeThisBoundClosureArgsNodeVisitor.php +++ /dev/null @@ -1,52 +0,0 @@ -isFirstClassCallable()) { - return null; - } - - $args = $this->callLikeExpectsThisBindedClosureArgsAnalyzer->getArgsUsingThisBoundClosure($node); - - if ($args === []) { - return null; - } - - foreach ($args as $arg) { - if ($arg->value instanceof Closure && ! $arg->hasAttribute(AttributeKey::IS_CLOSURE_USES_THIS)) { - $arg->value->setAttribute(AttributeKey::IS_CLOSURE_USES_THIS, true); - } - } - - return $node; - } -}