DX: Prevent having deprecated fixers listed as successors of other deprecated fixers #7967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Revived #7960, credits to @kubawerlos.
In terms of this discussion, I believe the point was valid but maybe not articulated correctly. As you can see,
AbstractFixerTestCase::testDeprecatedFixersDoNotHaveDeprecatedSuccessor()
iterates over the result ofDeprecatedFixerInterface::getSuccessorsNames()
and then callsTestCaseUtils::getFixerByName()
(previously this method was a part ofTestCase
). The problem here is thatgetSuccessorsNames()
's return type is defined aslist<string>
and there is not any mechanism that would verify if successors are valid references to existing fixers. For example, when we do:the docs are generated properly, Auto Review tests pass, everything looks OK, but then
testDeprecatedFixersDoNotHaveDeprecatedSuccessor()
fails withTypeError: PhpCsFixer\Tests\Test\TestCaseUtils::getFixerByName(): Return value must be of type PhpCsFixer\Fixer\FixerInterface, null returned
.With the explicit check, as suggested in the original PR, it just looks better and is more descriptive:
PS. Maybe we should have auto-review test that would verify if defined successors are valid fixers? (should be done in separate PR, if needed)