Repository navigation
fix(rector): convert an anonymous class on a project TestCase base - #431
Merged
Merged
Conversation
An anonymous class has no name to reflect, so its ancestry is read from the base it extends; it then follows the same path as a named subclass. It gets no `#[Skip]` on a vendor base, since Testo never discovers an anonymous class. Fixes #428 Assisted-By: Claude Opus 5.5
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…only PHPUnit declares test(rector): cover lifecycle attributes on an anonymous class on a project base Once the base is detached from `TestCase`, an `#[\Override]` on a hook the base does not declare itself, such as `setUp()`, has no parent method left and PHP rejects the class on load. The attribute stays where the base or an interface declares the method. Assisted-By: Claude Opus 5.5
roxblnfk
force-pushed
the
fix/rector-anonymous-on-project-base
branch
from
November 21, 2026 09:41
8e7a8a3 to
cfb3f21
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🔍 What was changed
TestCasethrough a project base (new class extends BaseTestCase) is now converted like a named subclass:parent::hook calls are dropped, others becomeself::/$this->for the skip and expectation rules,extendsstays.PhpunitTestCaseClassresolves ancestry from theextendsname, soisTestCase()and the vendor-base check work without a class name. Named classes resolve the same as before.#[\Testo\Skip]: Testo never discovers it, and itsparent::calls stay valid.LifecycleMethodToTestoRectoralso usesisTestCase(), so such a class now gets lifecycle attributes too, like an anonymous class extendingTestCasedirectly.#[\Override]on a method only PHPUnit declares (asetUp()the base does not override): PHP rejected it on load once the base was detached. It stays where the base or an interface declares the method.Checklist
parent::calls into PHPUnit #428phpunit-to-testoset fixtures addedBridge/RectorandBridge/Rector/Unitsuites pass locallyDocumentation
FEATURE_PARITY.md, the rule docblock and thetesto-migrate-from-phpunitskill mention anonymous classes on a project base.