Skip to content

[TypeDeclaration] Add TypedPropertyFromGetRepositorySetUpRector#8124

Merged
TomasVotruba merged 1 commit into
mainfrom
typed-property-from-get-repository-setup
Jun 30, 2026
Merged

[TypeDeclaration] Add TypedPropertyFromGetRepositorySetUpRector#8124
TomasVotruba merged 1 commit into
mainfrom
typed-property-from-get-repository-setup

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Mirrors #8120, but hooks into $this->em->getRepository() instead of container->get().

When a private test-case property is assigned via an entity manager getRepository() call inside setUp() and has a @var object type, inline that @var type into a native property type declaration.

 final class SomeTest extends TestCase
 {
-    /**
-     * @var SomeEntityRepository
-     */
-    private $someEntityRepository;
+    private SomeEntityRepository $someEntityRepository;

     protected function setUp(): void
     {
         $this->someEntityRepository = $this->em->getRepository(SomeEntity::class);
     }
 }

Registered in TypeDeclarationLevel right after TypedPropertyFromContainerGetSetUpRector and before TypedPropertyFromAssignsRector.

@TomasVotruba TomasVotruba merged commit 3680b8e into main Jun 30, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the typed-property-from-get-repository-setup branch June 30, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant