Skip to content

Change to wrong return type #2381

@snapshotpl

Description

@snapshotpl
Subject Details
Rector version v0.6.0
PHP version PHP 7.3.12

Current Behaviour

Rector change collectionCallback return type to iterable.

Minimal PHP Code Causing Issue

<?php 
class Query {
private function collectionCallback(): callable
    {
        return function (int $offset, int $itemCountPerPage): iterable {
            $stmt = $this->connection->executeQuery('SELECT * FROM *');

            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                yield EventsEntity::forCollection();
            }
        };
    }
}
    ---------- begin diff ----------
--- Original
+++ New
@@ -24,7 +24,7 @@
         return new Callback($this->collectionCallback(), $this->countCallback());
     }
-    private function collectionCallback(): callable
+    private function collectionCallback(): iterable
     {
         return function (int $offset, int $itemCountPerPage): iterable {
             $sql = 'SELECT id '
    ----------- end diff -----------
Applied rules:
 * Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector
 * Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector

Expected Behaviour

Nothing changed.

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