Drupal Rector version

palantirnet/drupal-rector: 0.13.0

Problem / Motivation

#3286594-3: Automated Drupal 10 compatibility fixes

The patch did not fix dispatch arguments, and a contributor noted that it needed to be.

https://drupal.slack.com/archives/C014CT1CN1M/p1659096840107009

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Just checked the rule is MakeDispatchFirstArgumentEventRector and is part of SYMFONY_43 config set, which we require.

    $rectorConfig->sets([
        PHPUnitSetList::PHPUNIT_80,
        SymfonySetList::SYMFONY_40,
        SymfonySetList::SYMFONY_41,
        SymfonySetList::SYMFONY_42,
        SymfonySetList::SYMFONY_43,
        SymfonySetList::SYMFONY_44
    ]);
mglaman’s picture

Based on off of the diff in #3300681: Update module for D10 readiness the event name is a variable, and that could be why. Rector know the first argument was a string variable.

   // Get the event_dispatcher service and dispatch the event.
   $event_dispatcher = \Drupal::service('event_dispatcher');
-  $event_dispatcher->dispatch($event_name, $event);
+  $event_dispatcher->dispatch($event, $event_name);

See

        $firstArg = $node->args[0];
        if (! $firstArg instanceof Arg) {
            return null;
        }

        $firstArgumentValue = $firstArg->value;
        if ($this->stringTypeAnalyzer->isStringOrUnionStringOnlyType($firstArgumentValue)) {
            $this->refactorStringArgument($node);
            return $node;
        }

mglaman’s picture

Title: Event dispatch argument order not fixed » Event dispatch argument order not fixed when event name is a variable value