Skip to content

Inconsistency in drupal-check #269

@martin-christensen

Description

@martin-christensen

How is drupal-check installed?

drupal-check is installed as a dependency to my project

Environment:

  • OS: macOS
  • PHP Version: 7.4
  • Drupal core: 9.x.x

Describe the bug
Working on a private custom module and implementing drupal-check on every PR for that module.

When testing locally and in github workflows, it gives me no errors and everything seems to be fine.

Besides drupal-check, the module has dev requirements to Drupal core and requirements to contrib modules, which functionality is used/extended within this private custom module.

BUT, when including this module in an actual Drupal project and within this running drupal-check against the module, I'm getting an error,

Call to an undefined method                                      
         Drupal\Core\Entity\EntityInterface::getName().

I have also tried to follow the guide Drupal 9 Readiness, which gives the same non-error, as when running in the module directly.

Console output ran within module

Memory limit set to -1
Performing deprecation checks
Performing analysis checks
Analyzing path: /Users/mach02/projects/web/dk-news-backend/aller_aptoma
Current working directory: /Users/mach02/projects/web/dk-news-backend
Using Drupal root: /Users/mach02/projects/web/dk-news-backend/web
Using vendor root: /Users/mach02/projects/web/dk-news-backend/vendor
Assumed running as global dependency
PHPStan path: /Users/mach02/projects/web/dk-news-backend/vendor/phpstan/phpstan/phpstan.phar
PHPStan configuration path: /private/var/folders/mz/lf0jy1694vx39q03n28jtd9clydr27/T/drupal_check_phpstan_1648628179.neon
PHPStan configuration:
parameters:
        tipsOfTheDay: false
        reportUnmatchedIgnoredErrors: false
        excludePaths:
                - */tests/Drupal/Tests/Listeners/Legacy/*
                - */tests/fixtures/*.php
                - */settings*.php
                - */node_modules/*

        ignoreErrors:
                - '#\Drupal calls should be avoided in classes, use dependency injection instead#'
                - '#Plugin definitions cannot be altered.#'
                - '#Missing cache backend declaration for performance.#'
                - '#Plugin manager has cache backend specified but does not declare cache tags.#'
                - '#Unsafe usage of new static\(\)#'

        drupal:
                drupal_root: /Users/mach02/projects/web/dk-news-backend/web

        level: 4
        bootstrapFiles:
                - /Users/mach02/projects/web/dk-news-backend/vendor/mglaman/drupal-check/error-bootstrap.php

includes:
        - /Users/mach02/projects/web/dk-news-backend/vendor/phpstan/phpstan-deprecation-rules/rules.neon
        - /Users/mach02/projects/web/dk-news-backend/vendor/mglaman/phpstan-drupal/extension.neon


Executing PHPStan
Result cache not used because the metadata do not match.
 16/16 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% < 1 sec/< 1 sec 72.5 MiB

Result cache is saved.

 [OK] No errors                                                                 

Used memory: 74.5 MB
Finished executing PHPStan
Unlinking PHPStan configuration
Return PHPStan exit code
Thanks for using drupal-check!

Consider sponsoring the development of the maintainers which make drupal-check possible:

- phpstan (ondrejmirtes): https://github.com/sponsors/ondrejmirtes
- phpstan-deprecation-rules (ondrejmirtes)): https://github.com/sponsors/ondrejmirtes
- phpstan-drupal (mglaman)): https://github.com/sponsors/mglaman
- drupal-check (mglaman)): https://github.com/sponsors/mglaman

Console output ran within a Drupal project

Memory limit set to -1
Performing deprecation checks
Performing analysis checks
Analyzing path: /Users/mach02/projects/web/dk-seoghoer-backend/web/modules/custom/dk-news-backend/aller_aptoma
Current working directory: /Users/mach02/projects/web/dk-seoghoer-backend
Using Drupal root: /Users/mach02/projects/web/dk-seoghoer-backend/web
Using vendor root: /Users/mach02/projects/web/dk-seoghoer-backend/vendor
Assumed running as global dependency
PHPStan path: /Users/mach02/projects/web/dk-seoghoer-backend/vendor/phpstan/phpstan/phpstan.phar
PHPStan configuration path: /private/var/folders/mz/lf0jy1694vx39q03n28jtd9clydr27/T/drupal_check_phpstan_1648628230.neon
PHPStan configuration:
parameters:
        tipsOfTheDay: false
        reportUnmatchedIgnoredErrors: false
        excludePaths:
                - */tests/Drupal/Tests/Listeners/Legacy/*
                - */tests/fixtures/*.php
                - */settings*.php
                - */node_modules/*

        ignoreErrors:
                - "#\\Drupal calls should be avoided in classes, use dependency injection instead#"
                - "#Plugin definitions cannot be altered.#"
                - "#Missing cache backend declaration for performance.#"
                - "#Plugin manager has cache backend specified but does not declare cache tags.#"
                - "#Unsafe usage of new static\\(\\)#"

        drupal:
                drupal_root: /Users/mach02/projects/web/dk-seoghoer-backend/web

        level: 4
        bootstrapFiles:
                - /Users/mach02/projects/web/dk-seoghoer-backend/vendor/mglaman/drupal-check/error-bootstrap.php

includes:
        - /Users/mach02/projects/web/dk-seoghoer-backend/vendor/phpstan/phpstan-deprecation-rules/rules.neon
        - /Users/mach02/projects/web/dk-seoghoer-backend/vendor/mglaman/phpstan-drupal/extension.neon


Executing PHPStan
Result cache not used because the metadata do not match.
 16/16 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% 4 secs/4 secs 124.5 MiB

Result cache is saved.
 ------ ---------------------------------------------------- 
  Line   src/Plugin/rest/resource/AllerAptomaApiContent.php  
 ------ ---------------------------------------------------- 
  272    Call to an undefined method                         
         Drupal\Core\Entity\EntityInterface::getName().      
 ------ ---------------------------------------------------- 


 [ERROR] Found 1 error                                                          

Used memory: 132.5 MB
Finished executing PHPStan
Unlinking PHPStan configuration
Return PHPStan exit code
Thanks for using drupal-check!

Consider sponsoring the development of the maintainers which make drupal-check possible:

- phpstan (ondrejmirtes): https://github.com/sponsors/ondrejmirtes
- phpstan-deprecation-rules (ondrejmirtes)): https://github.com/sponsors/ondrejmirtes
- phpstan-drupal (mglaman)): https://github.com/sponsors/mglaman
- drupal-check (mglaman)): https://github.com/sponsors/mglaman

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions