mglaman / phpstan-drupal

Extension for PHPStan to allow analysis of Drupal code.
https://phpstan-drupal.mglaman.dev/
MIT License
199 stars 76 forks source link

Fixing TypeError and deprecated message #778

Closed balagan73 closed 3 months ago

balagan73 commented 4 months ago

When running phpstan, I was getting TypeError thrown in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/DrupalServiceDefinition.php on line 55 while loading bootstrap file /var/www/html/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: mglaman\PHPStanDrupal\Drupal\DrupalServiceDefinition::setDeprecated(): Argument #2 ($template) must be of type ?string, array given, called in /var/www/html/vendor/mglaman/phpstan-drupal/src/Drupal/ServiceMap.php on line 63

Also, the deprecated message is not too helpful: "deprecated" => "The "%service_id%" service is deprecated in drupal:9.0.0 and is removed from drupal:20.0.0. This is a test."

This would be replaced by Symfony's dependecy-injection Definition class. As phpstan pulls them directly from the yaml file, we should do the replacement.

balagan73 commented 4 months ago

Messages dumped after the change:

^ "update.update_hook_registry_factory"
^ "The "update.update_hook_registry_factory" service is deprecated. You should use the 'update.update_hook_registry' service instead. See https://www.drupal.org/node/3423659"
^ "update.post_update_registry_factory"
^ "The "update.post_update_registry_factory" service is deprecated. You should use the 'update.post_update_registry' service instead. See https://www.drupal.org/node/3423659"
^ "Drupal\sdc\Twig\TwigComponentLoader"
^ "The "Drupal\Core\Template\Loader\ComponentLoader" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0."
^ "Drupal\sdc\ComponentNegotiator"
^ "The "Drupal\Core\Theme\ComponentNegotiator" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0."
^ "Drupal\sdc\Twig\TwigExtension"
^ "The "Drupal\Core\Template\ComponentsTwigExtension" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0."
^ "Drupal\sdc\Component\SchemaCompatibilityChecker"
^ "The "Drupal\Core\Theme\Component\SchemaCompatibilityChecker" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0."
^ "Drupal\sdc\Component\ComponentValidator"
^ "The "Drupal\Core\Theme\Component\ComponentValidator" service is deprecated since drupal/core 10.3.0 and will be removed in 11.0."
^ "deprecation_test.service"
^ "The "deprecation_test.service" service is deprecated in drupal:9.0.0 and is removed from drupal:20.0.0. This is a test."
^ "deprecation_test.alias"
^ "The "deprecation_test.service" alias is deprecated in drupal:9.0.0 and is removed from drupal:20.0.0. This is a test."
^ "ctools.serializable.tempstore.factory"
^ "The "ctools.serializable.tempstore.factory" service is deprecated. You should use the core shared tempstore factory service instead."
^ "stage_file_proxy.fetch_manager"
^ "The "stage_file_proxy.fetch_manager service is deprecated. Use "stage_file_proxy.download_manager" instead"
^ "stage_file_proxy.subscriber"
^ "The "stage_file_proxy.subscriber service is deprecated. Use "stage_file_proxy.proxy_subscriber" instead"
mglaman commented 3 months ago

Took a minute to see it was sdc implementing this verbose format