Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Handle deprecated rule sets similarly to deprecated fixers #7288

Conversation

Wirone
Copy link
Member

@Wirone Wirone commented Sep 12, 2023

Fixes #7285.

doc/ruleSets/PER-CS1.0.rst Outdated Show resolved Hide resolved
doc/ruleSets/index.rst Outdated Show resolved Hide resolved
@Wirone Wirone force-pushed the codito/7285-deprecation-contract-for-rulesets branch from 18ad8b1 to ff049a5 Compare December 14, 2023 12:26
@coveralls
Copy link

coveralls commented Dec 14, 2023

Coverage Status

coverage: 94.789% (-0.1%) from 94.917%
when pulling aaadad8 on Wirone:codito/7285-deprecation-contract-for-rulesets
into 7de792f on PHP-CS-Fixer:master.

@@ -2,8 +2,6 @@
Rule set ``@PER-CS1.0``
=======================

**This ruleset is deprecated** in favour of ``@PER-CS2.0``.
Copy link
Member Author

@Wirone Wirone Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because we should not deprecate @PER-CS1.0 which is valid rule set, just like we don't deprecate @PSR1, @PSR2 or @PSR12.

@Wirone Wirone force-pushed the codito/7285-deprecation-contract-for-rulesets branch from 41cad90 to 9ffba27 Compare December 14, 2023 15:42
@Wirone Wirone marked this pull request as ready for review December 14, 2023 15:55
@Wirone Wirone requested a review from keradus December 14, 2023 15:55
Format was taken from fixers' docs, but I decided to not display `risky` attribute next to risky rule sets, because all of them already have this information in their name.
Deprecation warnings can't be handled with PHPUnit's expectation API when they're triggered in the provider. But we can ignore them in Symfony's PHPUnit bridge if we mark test or provider as legacy.

https://symfony.com/doc/current/components/phpunit_bridge.html#mark-tests-as-legacy
Only rulesets that are actually invalid and must be removed should be marked as deprecated. In our case it's `@PER` and `@PER:risky` because the name was invalid and they were re-introduced as `@PER-CS` and `@PER-CS:risky`.

Additionally, the inheritance tree was changed and `@PER` now extends `@PER-CS` instead of `@PER-CS2.0` (deprecated alias ruleset pointing to proper alias ruleset).
Deprecated rulesets are part of several tests' cases, and every time such deprecated ruleset is used, it triggers deprecation notice which causes PHPUnit's failure (require Symfony Bridge's trait included in test case class to work properly).
@Wirone Wirone force-pushed the codito/7285-deprecation-contract-for-rulesets branch from 9ffba27 to aaadad8 Compare December 15, 2023 15:09
@Wirone Wirone merged commit 4c57217 into PHP-CS-Fixer:master Dec 15, 2023
26 checks passed
danog pushed a commit to zoonru/PHP-CS-Fixer that referenced this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TODO: create DeprecatedRuleSetDescriptionInterface, similar to DeprecatedFixerInterface
5 participants