phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Provide a way to stop execution at a particular deprecation

Open nicolas-grekas opened this issue 1 year ago • 2 comments

Deprecation are sometimes hard to track. Figuring the exact stack trace for one particular deprecation is really useful to understand how it comes up and fix it.

It would be awesome to have a command line option (or similar) to tell phpunit to stop and display its stacktrace when a specific deprecation occurs. The match would happen by checking the deprecation message.

For example:

phpunit --stop-on-deprecation="part of the deprecation message"

For sinpiration this capability exists when using Symfony's phpunit-brigde, as documented at https://symfony.com/doc/current/components/phpunit_bridge.html#configuration

nicolas-grekas avatar Sep 18 '24 10:09 nicolas-grekas

Is this not two separate things?

  • Display full stack trace (without frames from PHPUnit and its dependencies) for deprecations
  • Support --stop-on-deprecation="part of the deprecation message"

sebastianbergmann avatar Sep 18 '24 11:09 sebastianbergmann

It could be, but displaying stacktraces for deprecations standalone is not useful nor actionable: deprecations are best reported grouped, which means without stacktraces. On the other side, stopping on one specific deprecation without the stacktrace just asking to run the command again to make it display the stacktrace. Thus combined behavior is the most useful and actionable.

nicolas-grekas avatar Sep 18 '24 12:09 nicolas-grekas