Updated Rector to commit 6ebab94b971a930457c8e217dcb699c671ad617b

6ebab94b97 Add related polyfill interface to other PHP 8.0/7.3 rules (#5389)
This commit is contained in:
Tomas Votruba 2023-12-25 00:55:45 +00:00
parent 8775d2e083
commit 3f2b3edab8
6 changed files with 34 additions and 6 deletions

View File

@ -9,14 +9,16 @@ use PhpParser\Node\Name;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Core\ValueObject\PolyfillPackage;
use Rector\Php71\IsArrayAndDualCheckToAble;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Rector\VersionBonding\Contract\RelatedPolyfillInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\Php73\Rector\BinaryOr\IsCountableRector\IsCountableRectorTest
*/
final class IsCountableRector extends AbstractRector implements MinPhpVersionInterface
final class IsCountableRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
{
/**
* @readonly
@ -64,6 +66,10 @@ CODE_SAMPLE
{
return PhpVersionFeature::IS_COUNTABLE;
}
public function providePolyfillPackage() : string
{
return PolyfillPackage::PHP_73;
}
private function shouldSkip() : bool
{
return !$this->reflectionProvider->hasFunction(new Name('is_countable'), null);

View File

@ -13,7 +13,9 @@ use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Core\ValueObject\PolyfillPackage;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Rector\VersionBonding\Contract\RelatedPolyfillInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -24,7 +26,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*
* @see \Rector\Tests\Php73\Rector\FuncCall\ArrayKeyFirstLastRector\ArrayKeyFirstLastRectorTest
*/
final class ArrayKeyFirstLastRector extends AbstractRector implements MinPhpVersionInterface
final class ArrayKeyFirstLastRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
{
/**
* @readonly
@ -89,6 +91,10 @@ CODE_SAMPLE
{
return PhpVersionFeature::ARRAY_KEY_FIRST_LAST;
}
public function providePolyfillPackage() : string
{
return PolyfillPackage::PHP_73;
}
private function processArrayKeyFirstLast(StmtsAwareInterface $stmtsAware, bool $hasChanged, int $jumpToKey = 0) : ?StmtsAwareInterface
{
if ($stmtsAware->stmts === null) {

View File

@ -17,7 +17,9 @@ use PhpParser\Node\Scalar\LNumber;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Core\ValueObject\PolyfillPackage;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Rector\VersionBonding\Contract\RelatedPolyfillInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -25,7 +27,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*
* @see \Rector\Tests\Php80\Rector\NotIdentical\StrContainsRector\StrContainsRectorTest
*/
final class StrContainsRector extends AbstractRector implements MinPhpVersionInterface
final class StrContainsRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
{
/**
* @readonly
@ -98,6 +100,10 @@ CODE_SAMPLE
}
return $funcCall;
}
public function providePolyfillPackage() : string
{
return PolyfillPackage::PHP_80;
}
/**
* @param \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical|\PhpParser\Node\Expr\BinaryOp\Equal|\PhpParser\Node\Expr\BinaryOp\NotEqual $expr
*/

View File

@ -11,7 +11,9 @@ use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Identifier;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\Core\ValueObject\PolyfillPackage;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Rector\VersionBonding\Contract\RelatedPolyfillInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -19,7 +21,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*
* @see \Rector\Tests\Php80\Rector\Ternary\GetDebugTypeRector\GetDebugTypeRectorTest
*/
final class GetDebugTypeRector extends AbstractRector implements MinPhpVersionInterface
final class GetDebugTypeRector extends AbstractRector implements MinPhpVersionInterface, RelatedPolyfillInterface
{
public function provideMinPhpVersion() : int
{
@ -70,6 +72,10 @@ CODE_SAMPLE
$firstExpr = $getClassFuncCallOrClassConstFetchClass instanceof FuncCall ? $getClassFuncCallOrClassConstFetchClass->getArgs()[0]->value : $getClassFuncCallOrClassConstFetchClass->class;
return $this->nodeFactory->createFuncCall('get_debug_type', [$firstExpr]);
}
public function providePolyfillPackage() : string
{
return PolyfillPackage::PHP_80;
}
private function shouldSkip(Ternary $ternary) : bool
{
if (!$ternary->cond instanceof FuncCall) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ebb2d2df55887c25f74af39b400194039dff78d4';
public const PACKAGE_VERSION = '6ebab94b971a930457c8e217dcb699c671ad617b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-12-24 13:50:17';
public const RELEASE_DATE = '2023-12-25 00:53:36';
/**
* @var int
*/

View File

@ -12,4 +12,8 @@ final class PolyfillPackage
* @var string
*/
public const PHP_80 = 'symfony/polyfill-php80';
/**
* @var string
*/
public const PHP_73 = 'symfony/polyfill-php73';
}