Skip to content

[Php81] Drop Symfony PHP closure check from ArrayToFirstClassCallableRector - #8291

Merged
TomasVotruba merged 1 commit into
mainfrom
array-first-class-callable-drop-symfony-check
Aug 4, 2026
Merged

[Php81] Drop Symfony PHP closure check from ArrayToFirstClassCallableRector#8291
TomasVotruba merged 1 commit into
mainfrom
array-first-class-callable-drop-symfony-check

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The IS_INSIDE_SYMFONY_PHP_CLOSURE check was a blunt instrument: it skipped every array callable anywhere inside a Symfony PHP config closure, regardless of what the array was passed to.

Since #8288, IS_ARG_NOT_ACCEPTING_CLOSURE decides this from the actual parameter type - if the parameter cannot hold a Closure, the array callable is kept as is. That covers the Symfony config case precisely and, unlike the closure check, also works outside config files.

// still skipped - ServiceConfigurator::factory(string|array|ReferenceConfigurator $factory), no Closure in the union
$services->set(SomeService::class)
    ->factory([SomeFactory::class, 'create']);
 return static function (ContainerConfigurator $container): void {
-    // previously skipped only because it sits inside a Symfony closure
-    $array = [$this, 'name'];
+    // now decided by the parameter type instead
+    $array = $this->name(...);
 };

Removes, all now without consumers:

  • SymfonyClosureNodeVisitor (and its rector-symfony SymfonyPhpClosureDetector dependency from core)
  • AttributeKey::IS_INSIDE_SYMFONY_PHP_CLOSURE
  • skip_symfony_config.php.inc fixture - it asserted $container->services()->factory([...]), which symfony/dependency-injection is not installed to resolve here; the union-type path is already covered by skip_union_array_param.php.inc and skip_array_param.php.inc

Definition::setFactory() remains covered by the name-based IS_ARRAY_AS_STRING_CALLABLE check.

…Rector

The IS_ARG_NOT_ACCEPTING_CLOSURE union type check covers the Symfony
config case precisely, based on the actual parameter type rather than
on being anywhere inside a Symfony PHP config closure.

Removes SymfonyClosureNodeVisitor and the IS_INSIDE_SYMFONY_PHP_CLOSURE
attribute key, both of which had no other consumers.
@TomasVotruba
TomasVotruba merged commit d01c74f into main Aug 4, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the array-first-class-callable-drop-symfony-check branch August 4, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant