Open neclimdul opened 3 weeks ago
is there a contrib module you can point to that demonstrates the issue?
Its been true on any module I've tested.
For example, I have a module that uses this baseline that I built to work in gitlab-ci on d.o
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Drupal\\\\Core\\\\Form\\\\FormInterface\\:\\:getEntity\\(\\)\\.$#"
count: 3
path: coveo.module
-
message: "#^Method Drupal\\\\coveo\\\\Plugin\\\\search_api\\\\backend\\\\SearchApiCoveoBackend\\:\\:getAutocompleteSuggestions\\(\\) has invalid return type Drupal\\\\search_api_autocomplete\\\\Suggestion\\\\SuggestionInterface\\.$#"
count: 1
path: src/Plugin/search_api/backend/SearchApiCoveoBackend.php
-
message: "#^Parameter \\$search of method Drupal\\\\coveo\\\\Plugin\\\\search_api\\\\backend\\\\SearchApiCoveoBackend\\:\\:getAutocompleteSuggestions\\(\\) has invalid type Drupal\\\\search_api_autocomplete\\\\SearchInterface\\.$#"
count: 2
path: src/Plugin/search_api/backend/SearchApiCoveoBackend.php
If I run phpstan in ddev all these are reported.
> ddev phpstan
Note: Using configuration file /var/www/html/phpstan.neon.
21/21 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ --------------------------------------------------------------------------
Line coveo/coveo.module
------ --------------------------------------------------------------------------
20 Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().
50 Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().
68 Call to an undefined method Drupal\Core\Form\FormInterface::getEntity().
------ --------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------------------
Line coveo/src/Plugin/search_api/backend/SearchApiCoveoBackend.php
------ -----------------------------------------------------------------------------------------------------------------------------------------
539 Method Drupal\coveo\Plugin\search_api\backend\SearchApiCoveoBackend::getAutocompleteSuggestions() has invalid return type
Drupal\search_api_autocomplete\Suggestion\SuggestionInterface.
539 Parameter $search of method Drupal\coveo\Plugin\search_api\backend\SearchApiCoveoBackend::getAutocompleteSuggestions() has invalid type
Drupal\search_api_autocomplete\SearchInterface.
539 Parameter $search of method Drupal\coveo\Plugin\search_api\backend\SearchApiCoveoBackend::getAutocompleteSuggestions() has invalid type
Drupal\search_api_autocomplete\SearchInterface.
------ -----------------------------------------------------------------------------------------------------------------------------------------
Updating through ddev generates this diff
> ddev phpstan --generate-baseline=phpstan-baseline.neon --allow-empty-baseline
Note: Using configuration file /var/www/html/phpstan.neon.
21/21 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[OK] Baseline generated with 6 errors.
> git diff phpstan-baseline.neon
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 247d5b2..813f791 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -3,14 +3,14 @@ parameters:
-
message: "#^Call to an undefined method Drupal\\\\Core\\\\Form\\\\FormInterface\\:\\:getEntity\\(\\)\\.$#"
count: 3
- path: coveo.module
+ path: web/modules/custom/coveo/coveo.module
-
message: "#^Method Drupal\\\\coveo\\\\Plugin\\\\search_api\\\\backend\\\\SearchApiCoveoBackend\\:\\:getAutocompleteSuggestions\\(\\) has invalid return type Drupal\\\\search_api_autocomplete\\\\Suggestion\\\\SuggestionInterface\\.$#"
count: 1
- path: src/Plugin/search_api/backend/SearchApiCoveoBackend.php
+ path: web/modules/custom/coveo/src/Plugin/search_api/backend/SearchApiCoveoBackend.php
-
message: "#^Parameter \\$search of method Drupal\\\\coveo\\\\Plugin\\\\search_api\\\\backend\\\\SearchApiCoveoBackend\\:\\:getAutocompleteSuggestions\\(\\) has invalid type Drupal\\\\search_api_autocomplete\\\\SearchInterface\\.$#"
count: 2
- path: src/Plugin/search_api/backend/SearchApiCoveoBackend.php
+ path: web/modules/custom/coveo/src/Plugin/search_api/backend/SearchApiCoveoBackend.php
But if you push that to drupal.org the pipeline fails because the files don't exist in the web/modules/custom
directory
https://git.drupalcode.org/project/coveo/-/jobs/3226498
You can see this commit fixing the phpstan failures by using the correct paths. https://git.drupalcode.org/project/coveo/-/commit/5e8d58e755dc1d2663618294a775747236845755
The PHPStan support this provides runs in web/modules/custom/ which means that the baselines aren't compatible with those that would be generated for gitlab-ci. This makes it much less useful for testing a module and fixing CI issues.