PHPStan allows us to ignore by identifier rather than message (as of 1.11). This is slightly less specific than the message is, but has the benefit of being a lot fewer bytes and a lot easier to deduplicate. This significantly reduces the size of the PHP baseline when used for Drupal Core.
Use the new formatter by passing --error-format=identifier_baseline to the phpstan analyze command. Note that you can unfortunately not pipe to the baseline because this clears out the file before PHPStan is started.
⚠️ The baseline file must be empty since the error formatter would otherwise not get any errors to display (as they are all ignored). You can add a return []; at the top of the baseline to easily do this.
In case no identifier is available the formatter falls back to using the message in the same way PHPStan's BaselinePhpErrorFormatter would do.
There's one important difference vs the BaselinePhpErrorFormatter because $message and $file are not escaped using Helpers::escape as is done in PHPStan. Helpers is a class from the nette/di package that's marked as internal. To add that code back we'd need to add nette/di as a dependency to phpstan-drupal or fork the helper.
PHPStan allows us to ignore by identifier rather than message (as of 1.11). This is slightly less specific than the message is, but has the benefit of being a lot fewer bytes and a lot easier to deduplicate. This significantly reduces the size of the PHP baseline when used for Drupal Core.
Use the new formatter by passing
--error-format=identifier_baseline
to thephpstan analyze
command. Note that you can unfortunately not pipe to the baseline because this clears out the file before PHPStan is started.⚠️ The baseline file must be empty since the error formatter would otherwise not get any errors to display (as they are all ignored). You can add a
return [];
at the top of the baseline to easily do this.In case no identifier is available the formatter falls back to using the message in the same way PHPStan's
BaselinePhpErrorFormatter
would do.There's one important difference vs the
BaselinePhpErrorFormatter
because$message
and$file
are not escaped usingHelpers::escape
as is done in PHPStan.Helpers
is a class from the nette/di package that's marked as internal. To add that code back we'd need to addnette/di
as a dependency tophpstan-drupal
or fork the helper.