You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On ^1.2 version, decorating a service using autowiring feature without explicit class for decorator, leads to an error:
[19-Dec-2023 10:55:19 UTC] PHP Warning: Undefined array key "Drupal\phpstan_example\BarInterface" in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/ServiceMap.php on line 65
Warning: Undefined array key "Drupal\phpstan_example\BarInterface" in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/ServiceMap.php on line 65
TypeError thrown in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/DrupalServiceDefinition.php on line 130 while loading bootstrap file /var/www/html/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: mglaman\PHPStanDrupal\Drupal\DrupalServiceDefinition::addDecorator(): Argument #1 ($definition) must be of type mglaman\PHPStanDrupal\Drupal\DrupalServiceDefinition, null given, called in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/ServiceMap.php on line 65
Basically, I have an interface defined in services.yml file which is an alias for a specific class that implements that interface. But that class is another service which decorates contrib one. In example above: Foo is contrib services, defined in third-party code, BarInterface — an interface for my decorator used as an alias for its definition and Bar is an actual decorator.
The text was updated successfully, but these errors were encountered:
Bug report
On ^1.2 version, decorating a service using autowiring feature without explicit
class
for decorator, leads to an error:There is no issue on ~1.1 version, only on 1.2.0+
Code snippet that reproduces the problem
example.services.yml:
This definition is valid and works, but PHPStan fails on them. If I add explicit class for decorator, it would work:
Drupal\phpstan_example\Foo: Drupal\phpstan_example\BarInterface: '@Drupal\phpstan_example\Bar' Drupal\phpstan_example\Bar: + class: Drupal\phpstan_example\Bar decorates: Drupal\phpstan_example\Foo
Looks like related to #578, but still an issue.
phpstan_example.zip — an example module with a problem.
Basically, I have an interface defined in services.yml file which is an alias for a specific class that implements that interface. But that class is another service which decorates contrib one. In example above:
Foo
is contrib services, defined in third-party code,BarInterface
— an interface for my decorator used as an alias for its definition andBar
is an actual decorator.The text was updated successfully, but these errors were encountered: