Skip to content

Commit

Permalink
[PHP 7.3] Register existing ContinueToBreakInSwitchRector in PHP 5.2 …
Browse files Browse the repository at this point in the history
…set to PHP 7.3 config set (rectorphp#5820)

Co-authored-by: kaizen-ci <[email protected]>
  • Loading branch information
samsonasik and kaizen-ci authored Mar 11, 2021
1 parent 2e3a9e7 commit 28e1e1f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 52 deletions.
2 changes: 2 additions & 0 deletions config/set/php73.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
use Rector\Php73\Rector\BooleanOr\IsCountableRector;
use Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector;
use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector;
Expand Down Expand Up @@ -46,4 +47,5 @@
$services->set(StringifyStrNeedlesRector::class);
$services->set(JsonThrowOnErrorRector::class);
$services->set(RegexDashEscapeRector::class);
$services->set(ContinueToBreakInSwitchRector::class);
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function test(SmartFileInfo $smartFileInfo): void
$this->doTestFileInfo($smartFileInfo);
}

/**
* @return Iterator<mixed, SmartFileInfo>
*/
public function provideData(): Iterator
{
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/FixturePhp74');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function test(SmartFileInfo $smartFileInfo): void
$this->doTestFileInfo($smartFileInfo);
}

/**
* @return Iterator<mixed, SmartFileInfo>
*/
public function provideData(): Iterator
{
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/FixturePhp80');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public function test(SmartFileInfo $smartFileInfo): void
$this->doTestFileInfo($smartFileInfo);
}

/**
* @return Iterator<mixed, SmartFileInfo>
*/
public function provideData(): Iterator
{
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/Fixture');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\Type\ArrayType;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\IterableType;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -176,6 +177,13 @@ public function refactor(Node $node): ?Node
return null;
}

if ($inferredReturnType instanceof GenericObjectType && $currentReturnType instanceof MixedType) {
$types = $inferredReturnType->getTypes();
if ($types[0] instanceof MixedType && $types[1] instanceof ArrayType) {
return null;
}
}

$this->phpDocTypeChanger->changeReturnType($phpDocInfo, $inferredReturnType);
$this->returnTagRemover->removeReturnTagIfUseless($phpDocInfo, $node);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;

use Iterator;
use Symplify\SmartFileSystem\SmartFileInfo;

final class SkipSomeIterator
{
public function someMethod(): Iterator
{
return self::someIterator();
}

/**
* @return \Iterator<array<int, SmartFileInfo>>
*/
public static function someIterator(): Iterator
{
yield [100 => new SmartFileInfo('...')];
}
}

?>

This file was deleted.

0 comments on commit 28e1e1f

Please sign in to comment.