phpstan-drupal
phpstan-drupal copied to clipboard
Service arguments are not verified against class __construct()
I noticed an issue where arguments to classes in the services file were not verified against the class->__construct() at any phpstan runlevel. Is this something that would be fixable?
Our error was bought to my attention when I was running drush phpstorm-metadata:generate from project drupal/phpstorm_metadata

Correct, this is not analyzed. Not on any level of PHPStan, it needs a custom rule. This probably exists in phpstan-symfony, but that package reads the dumped container information.
I believe PHPStan 1.8.0 made this feasible by using Collectors: https://phpstan.org/developing-extensions/collectors
This would collect on __construct for getNodeType. Then in processNode it would check the service map to see if the class is a service.
Then a custom rule could be applied to check the service definition against the arguments.