Skip to content

Commit

Permalink
[TypeDeclaration] Skip iterable already there in AddReturnTypeDeclara…
Browse files Browse the repository at this point in the history
…tionFromYieldsRector (#5291)
  • Loading branch information
TomasVotruba committed Nov 27, 2023
1 parent 09a962c commit e66754a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 67 deletions.
Expand Up @@ -2,7 +2,7 @@

namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector\Fixture;

$func = function (): iterable {
$func = function () {
yield 1;
};

Expand All @@ -12,7 +12,7 @@ $func = function (): iterable {

namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector\Fixture;

$func = function (): \Iterator {
$func = function (): \Generator {
yield 1;
};

Expand Down

This file was deleted.

This file was deleted.

@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector\Fixture;

final class SkipReturnTypeIterable
{
public function run(): iterable
{
yield from $this->getData();
}

private function getData(): array
{
return [];
}
}
Expand Up @@ -98,7 +98,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
// skip already filled type
if ($node->returnType instanceof Node && $this->isNames(
$node->returnType,
['Iterator', 'Generator', 'Traversable']
['Iterator', 'Generator', 'Traversable', 'iterable']
)) {
return null;
}
Expand Down

0 comments on commit e66754a

Please sign in to comment.