Skip to content

Incorrect behavior of ChildDoctrineRepositoryClassTypeRector  #8569

@jlherren

Description

@jlherren

Bug Report

Subject Details
Rector version 1.0.3

Rector is adding a generic type as return type declaration:

1 file with changes
===================
1) src/ExtendedEntityRepository.php:34
    ---------- begin diff ----------
@@ @@
      *
      * @return T
      */
-    public function findOneByOrThrow(array $conditions) {
+    public function findOneByOrThrow(array $conditions): ?T {
         $entity = $this->findOneBy($conditions);
         if ($entity === null) {
    ----------- end diff -----------
Applied rules:
 * ChildDoctrineRepositoryClassTypeRector

Minimal PHP Code Causing Issue

The bug doesn't get triggered in the demo sandbox, unfortunately, but here's the code: https://getrector.com/demo/c6a5e684-b19a-4873-8047-cf43b809c207

If need be, I can try to construct a full reproduction repository.

Expected Behaviour

No changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions