Updated Rector to commit b8b1155ffe068cfb0a1a702dfd00e21bf711c46d

b8b1155ffe try polyfill is_list
This commit is contained in:
Tomas Votruba 2023-06-06 22:03:07 +00:00
parent 515eba1ef3
commit 104c8b43d1
7 changed files with 49 additions and 42 deletions

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit4062e991fac87b34772d073acdecfb6a::getLoader();
return ComposerAutoloaderInitbe589ca49a688c18b0ab940e8d069855::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit4062e991fac87b34772d073acdecfb6a
class ComposerAutoloaderInitbe589ca49a688c18b0ab940e8d069855
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit4062e991fac87b34772d073acdecfb6a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit4062e991fac87b34772d073acdecfb6a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitbe589ca49a688c18b0ab940e8d069855', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit4062e991fac87b34772d073acdecfb6a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitbe589ca49a688c18b0ab940e8d069855', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4062e991fac87b34772d073acdecfb6a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitbe589ca49a688c18b0ab940e8d069855::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit4062e991fac87b34772d073acdecfb6a::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitbe589ca49a688c18b0ab940e8d069855::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit4062e991fac87b34772d073acdecfb6a
class ComposerStaticInitbe589ca49a688c18b0ab940e8d069855
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3050,9 +3050,9 @@ class ComposerStaticInit4062e991fac87b34772d073acdecfb6a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4062e991fac87b34772d073acdecfb6a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4062e991fac87b34772d073acdecfb6a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4062e991fac87b34772d073acdecfb6a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitbe589ca49a688c18b0ab940e8d069855::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbe589ca49a688c18b0ab940e8d069855::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbe589ca49a688c18b0ab940e8d069855::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1917,12 +1917,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "392f969e8166ba3329193e761bb0a35069d39deb"
"reference": "54ab96770c47510317ed9ba5439153921e636d1a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/392f969e8166ba3329193e761bb0a35069d39deb",
"reference": "392f969e8166ba3329193e761bb0a35069d39deb",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/54ab96770c47510317ed9ba5439153921e636d1a",
"reference": "54ab96770c47510317ed9ba5439153921e636d1a",
"shasum": ""
},
"require": {
@ -1946,7 +1946,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-06-06T16:14:50+00:00",
"time": "2023-06-06T20:51:41+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 08503e7'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 392f969'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 134c91c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 36d3cb5'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 08503e7'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 54ab967'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 134c91c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 36d3cb5'));
private function __construct()
{
}

View File

@ -26,7 +26,6 @@ use Rector\Core\NodeManipulator\BinaryOpManipulator;
use Rector\Core\NodeManipulator\IfManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeAnalyzer\CoalesceAnalyzer;
use Rector\PostRector\Collector\NodesToAddCollector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -51,17 +50,11 @@ final class DowngradeThrowExprRector extends AbstractRector
* @var \Rector\Core\NodeManipulator\BinaryOpManipulator
*/
private $binaryOpManipulator;
/**
* @readonly
* @var \Rector\PostRector\Collector\NodesToAddCollector
*/
private $nodesToAddCollector;
public function __construct(IfManipulator $ifManipulator, CoalesceAnalyzer $coalesceAnalyzer, BinaryOpManipulator $binaryOpManipulator, NodesToAddCollector $nodesToAddCollector)
public function __construct(IfManipulator $ifManipulator, CoalesceAnalyzer $coalesceAnalyzer, BinaryOpManipulator $binaryOpManipulator)
{
$this->ifManipulator = $ifManipulator;
$this->coalesceAnalyzer = $coalesceAnalyzer;
$this->binaryOpManipulator = $binaryOpManipulator;
$this->nodesToAddCollector = $nodesToAddCollector;
}
public function getRuleDefinition() : RuleDefinition
{
@ -82,17 +75,14 @@ CODE_SAMPLE
*/
public function getNodeTypes() : array
{
return [Expression::class, Return_::class, Coalesce::class];
return [Expression::class, Return_::class];
}
/**
* @param Expression|Return_|Coalesce $node
* @param Expression|Return_ $node
* @return Node|Node[]|null
*/
public function refactor(Node $node)
{
if ($node instanceof Coalesce) {
return $this->refactorDirectCoalesce($node);
}
if ($node instanceof Return_) {
return $this->refactorReturn($node);
}
@ -100,7 +90,10 @@ CODE_SAMPLE
return null;
}
if ($node->expr instanceof Assign) {
return $this->refactorAssign($node, $node->expr);
$resultNode = $this->refactorAssign($node->expr);
if ($resultNode !== null) {
return $resultNode;
}
}
if ($node->expr instanceof Coalesce) {
return $this->refactorCoalesce($node->expr, null);
@ -108,12 +101,12 @@ CODE_SAMPLE
if ($node->expr instanceof Ternary) {
return $this->refactorTernary($node->expr, null);
}
return null;
return $this->refactorDirectCoalesce($node);
}
/**
* @return If_|Expression|Stmt[]|null
*/
private function refactorAssign(Expression $expression, Assign $assign)
private function refactorAssign(Assign $assign)
{
if (!$this->hasThrowInAssignExpr($assign)) {
return null;
@ -127,7 +120,7 @@ CODE_SAMPLE
if ($assign->expr instanceof Ternary) {
return $this->refactorTernary($assign->expr, $assign);
}
return $expression;
return null;
}
/**
* @return If_|Stmt[]|null
@ -212,16 +205,30 @@ CODE_SAMPLE
}
return new Identical($coalesce->left, $this->nodeFactory->createNull());
}
private function refactorDirectCoalesce(Coalesce $coalesce) : ?Expr
/**
* @return Stmt[]|null
*/
private function refactorDirectCoalesce(Expression $expression) : ?array
{
if (!$coalesce->right instanceof Throw_) {
return null;
/** @var Coalesce[] $coalesces */
$coalesces = $this->betterNodeFinder->findInstanceOf($expression, Coalesce::class);
foreach ($coalesces as $coalesce) {
if (!$coalesce->right instanceof Throw_) {
continue;
}
// add condition if above
$throwExpr = $coalesce->right;
$throw = new Stmt\Throw_($throwExpr->expr);
$if = new If_(new Identical($coalesce->left, new ConstFetch(new Name('null'))), ['stmts' => [$throw]]);
// replace coalsese with left :)
$this->traverseNodesWithCallable($expression, static function (Node $node) : ?Expr {
if (!$node instanceof Coalesce) {
return null;
}
return $node->left;
});
return [$if, $expression];
}
// add condition if above
$throwExpr = $coalesce->right;
$throw = new Stmt\Throw_($throwExpr->expr);
$if = new If_(new Identical($coalesce->left, new ConstFetch(new Name('null'))), ['stmts' => [$throw]]);
$this->nodesToAddCollector->addNodeBeforeNode($if, $coalesce);
return $coalesce->left;
return null;
}
}