Skip to main content

PHPStan Drupal 0.12.0 released!

Published on

🥳Six days after starting on the PHPStan 0.12.0 release compatibility, the PHPStan Drupal extension is now working. The phpstan-drupal:0.12.0 release is now available. It required some reengineering, though. Thanks to Ondřej Mirtes for giving the code a review and pull request to fix my parameters schema 🙏. There should be no impact on your Drupal projects, these were all changes to meet refactoring within PHPStan.

However, there were some changes. PHPStan Drupal allowed you to specify a drupal_root parameter that pointed PHPStan to your Drupal build It is now drupal.drupal_root, nested up the drupal parameter.

For example

# phpstan.neon
parameters:
    drupal:
        drupal_root: /path/to/drupal

If you provide entity type managers, mappings, you just need to move the data from the root drupal definition under parameters. Here's an example

parameters:
    drupal:
        entityTypeStorageMapping:
            search_api_index: Drupal\search_api\Entity\SearchApiConfigEntityStorage
            search_api_server: Drupal\search_api\Entity\SearchApiConfigEntityStorage

Give it a spin! drupal-check will be updated in the next coming days as well. There are currently some unexpected failures. You can track the following pull request: https://github.com/mglaman/drupal-check/pull/119

I have also opened an issue and made a patch for the Upgrade Status module to support the new version, as well.

Has drupal-check or PHPStan helped you out?

Photo by Jantine Doornbos on Unsplash