phpstan-symfony icon indicating copy to clipboard operation
phpstan-symfony copied to clipboard

Remove reporting of deprecated method calls in tests flagged as `@group legacy`

Open stof opened this issue 1 year ago • 4 comments

symfony/phpunit-bridge defines a convention where adding @group legacy on a test (either by adding it on the method or on the class as PHPUnit considers that a @group added on a class applies to all tests defined in that class) disables the reporting of deprecations in that test, as this test is about covering the legacy behavior (and so using deprecated APIs is expected).

https://github.com/phpstan/phpstan-deprecation-rules/pull/99 has added an extension point allowing to implement such feature. It would be great to provide an implementation of the interface following this convention.

stof avatar Feb 28 '24 18:02 stof

This was initially requested in https://github.com/phpstan/phpstan-deprecation-rules/issues/64, which end up introducing the needed extension point. But solving this entirely actually require using the extension point, not just introducing it.

stof avatar Feb 28 '24 18:02 stof

the implementation is described in the docs https://github.com/phpstan/phpstan-deprecation-rules/compare/7d7840458a6df74a8890a0f1bf192c682148912d...27397cd9b1aff47824d5ccfe7e0c2a4ada8eb6d2#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R56-R81

so your request is to ship this documented default impl with the phpstan-symfony extension?

staabm avatar Mar 05 '24 15:03 staabm

Yes. As this is a Symfony convention, it might make sense to ship it in phpstan-symfony automatically.

stof avatar Mar 05 '24 16:03 stof

Note that the shipped implementation should be a little more involved IMO:

  • it should check the class docblock as well (as groups might be defined at the class level too)
  • it should probably apply only in classes extending PHPUnit\Framework\TestCase as this @group legacy has an effect only in tests.

stof avatar Mar 05 '24 16:03 stof