mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
[PHP 7.3] Register existing ContinueToBreakInSwitchRector in PHP 5.2 set to PHP 7.3 config set (#5820)
Co-authored-by: kaizen-ci <info@kaizen-ci.org>
This commit is contained in:
parent
2e3a9e7166
commit
28e1e1f3f4
@ -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;
|
||||
@ -46,4 +47,5 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services->set(StringifyStrNeedlesRector::class);
|
||||
$services->set(JsonThrowOnErrorRector::class);
|
||||
$services->set(RegexDashEscapeRector::class);
|
||||
$services->set(ContinueToBreakInSwitchRector::class);
|
||||
};
|
||||
|
@ -22,6 +22,9 @@ final class Php74Test extends AbstractPropertyFetchTypeResolverTest
|
||||
$this->doTestFileInfo($smartFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<mixed, SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/FixturePhp74');
|
||||
|
@ -22,6 +22,9 @@ final class Php80Test extends AbstractPropertyFetchTypeResolverTest
|
||||
$this->doTestFileInfo($smartFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<mixed, SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/FixturePhp80');
|
||||
|
@ -18,6 +18,9 @@ final class PropertyFetchTypeResolverTest extends AbstractPropertyFetchTypeResol
|
||||
$this->doTestFileInfo($smartFileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<mixed, SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return StaticFixtureFinder::yieldDirectoryExclusively(__DIR__ . '/Fixture');
|
||||
|
@ -10,6 +10,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
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;
|
||||
@ -176,6 +177,13 @@ CODE_SAMPLE
|
||||
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);
|
||||
|
||||
|
@ -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('...')];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;
|
||||
|
||||
use Iterator;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class SomeIterator
|
||||
{
|
||||
public function someMethod(): Iterator
|
||||
{
|
||||
return self::someIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Iterator<array<int, SmartFileInfo>>
|
||||
*/
|
||||
public static function someIterator(): Iterator
|
||||
{
|
||||
yield [100 => new SmartFileInfo('...')];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\TypeDeclaration\Tests\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;
|
||||
|
||||
use Iterator;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class SomeIterator
|
||||
{
|
||||
/**
|
||||
* @return Iterator<mixed, \Symplify\SmartFileSystem\SmartFileInfo[]>
|
||||
*/
|
||||
public function someMethod(): Iterator
|
||||
{
|
||||
return self::someIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Iterator<array<int, SmartFileInfo>>
|
||||
*/
|
||||
public static function someIterator(): Iterator
|
||||
{
|
||||
yield [100 => new SmartFileInfo('...')];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user