phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Allow selected deprecations to be skipped/ignored

Open mondrake opened this issue 9 months ago • 1 comments

symfony/phpunit-bridge used to provide the Ignoring Deprecations feature, by means of which a deprecation error triggered during a test, that matches any pattern from a set defined in an ignore file, would be ignored and not reported.

In Drupal testing, we are making extensive use of this feature, to the point that when we started testing with PHPUnit 10, we developed our own replacement of the functionality.

The logic is that in large codebases with strong BC focus, we may incur in deprecations that would occur in thousands (for example, deprecations thrown by a debug classloader that check proper typehinting of extending classes), and it may be unlikely that fixing them will occur before next major release and/or with a single issue.

So it is much simpler just to ignore them and then remove the ignore pattern once it is no longer necessary.

symfony/phpunit-bridge and Drupal 11 own DeprecationHandler both achieve that by means of heavily replacing PHPUnit's error handler, which works but may not be a good idea long term.

A feature (note, not necessarily a blunt replacement of the ignore file, could be an event validating whether the single deprecation thrown should be ignored, or similar mechanisms) to allow selected deprecations to be skipped/ignored from the reporting, would help to remove those fillgaps.

mondrake avatar May 23 '24 13:05 mondrake