Problem/Motivation
Discovered in #3260401: Google is abandoning FLoC - so remove the header, in a full PHPStan run we only consider the core and composer directories:
paths:
- .
- ../composer
But if sites/default/default.settings.php is modified, it is analysed during a partial run, because PHPStan is not configured to explicitly exclude it:
$ ../vendor/bin/phpstan analyze ../sites/default/default.settings.php
Note: Using configuration file /var/www/html/drupal/core/phpstan.neon.dist.
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ -------------------------------------------
Line sites/default/default.settings.php
------ -------------------------------------------
662 Variable $app_root might not be defined.
662 Variable $site_path might not be defined.
------ -------------------------------------------
Steps to reproduce
Proposed resolution
Extend excludePaths to include default.settings.php:
excludePaths:
# Skip settings.
- ../*/*settings*.php
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3322182-7.patch | 400 bytes | longwave |
| #2 | 3322182-2.patch | 363 bytes | longwave |
Comments
Comment #2
longwaveComment #3
spokjeI think you also have to remove the 2 errors for default.settings.php in the baseline?
Comment #4
longwaveI wonder if instead this should be more specific, ie. ignore
../sites/*/*settings*.php?Comment #5
catchOr... should we be ignoring the entire sites directory?
Comment #6
spokje+1 to ignoring the /sites directory, there's nothing but config code in there anyway?
Comment #7
longwaveOK, let's try this.
Comment #8
nod_Makes sense to me
Comment #9
spokjeStill think we have to remove the reported errors for
default.settings.phpfrom the baseline: https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan-bas...Comment #10
longwaveThat is the other copy of the file, used by the scaffolding plugin. We could also exclude that directory, but I think it's probably worth scanning and keeping in the baseline?
Comment #11
spokjeAh, sorry, you're absolutely right. back to RTBC.
Comment #12
alexpottI think you can have code in sites that you might want to scan - but then you should have your own config and baseline so this works for as far as I can see.
Committed and pushed 6a0ea57c28 to 10.1.x and e4deca18fd to 10.0.x. Thanks!