Skip to content

Commit

Permalink
Updated Rector to commit 4be1f2a
Browse files Browse the repository at this point in the history
rectorphp/rector-src@4be1f2a [DowngradePhp80] Allow Truthy with Ternary on DowngradeThrowExprRector (#539)
  • Loading branch information
TomasVotruba committed Jul 29, 2021
1 parent d162a45 commit e5958f3
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 211 deletions.
382 changes: 191 additions & 191 deletions preload.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
namespace Rector\DowngradePhp80\Rector\Expression;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\Coalesce;
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\Isset_;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Expr\Throw_;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\If_;
use Rector\Core\NodeAnalyzer\CoalesceAnalyzer;
use Rector\Core\NodeManipulator\BinaryOpManipulator;
use Rector\Core\NodeManipulator\IfManipulator;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand All @@ -31,10 +34,15 @@ final class DowngradeThrowExprRector extends \Rector\Core\Rector\AbstractRector
* @var \Rector\Core\NodeAnalyzer\CoalesceAnalyzer
*/
private $coalesceAnalyzer;
public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\CoalesceAnalyzer $coalesceAnalyzer)
/**
* @var \Rector\Core\NodeManipulator\BinaryOpManipulator
*/
private $binaryOpManipulator;
public function __construct(\Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\Core\NodeAnalyzer\CoalesceAnalyzer $coalesceAnalyzer, \Rector\Core\NodeManipulator\BinaryOpManipulator $binaryOpManipulator)
{
$this->ifManipulator = $ifManipulator;
$this->coalesceAnalyzer = $coalesceAnalyzer;
$this->binaryOpManipulator = $binaryOpManipulator;
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
Expand Down Expand Up @@ -95,8 +103,25 @@ private function processAssign(\PhpParser\Node\Stmt\Expression $expression, \Php
if ($assign->expr instanceof \PhpParser\Node\Expr\Throw_) {
return new \PhpParser\Node\Stmt\Expression($assign->expr);
}
if ($assign->expr instanceof \PhpParser\Node\Expr\Ternary) {
return $this->processTernary($assign, $assign->expr);
}
return $expression;
}
private function processTernary(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\Ternary $ternary) : ?\PhpParser\Node\Stmt\If_
{
if (!$ternary->else instanceof \PhpParser\Node\Expr\Throw_) {
return null;
}
$inversedTernaryCond = $this->binaryOpManipulator->inverseNode($ternary->cond);
if (!$inversedTernaryCond instanceof \PhpParser\Node\Expr) {
return null;
}
$if = $this->ifManipulator->createIfExpr($inversedTernaryCond, new \PhpParser\Node\Stmt\Expression($ternary->else));
$assign->expr = $ternary->if === null ? $ternary->cond : $ternary->if;
$this->addNodeAfterNode(new \PhpParser\Node\Stmt\Expression($assign), $if);
return $if;
}
private function processCoalesce(\PhpParser\Node\Expr\Assign $assign, \PhpParser\Node\Expr\BinaryOp\Coalesce $coalesce) : ?\PhpParser\Node\Stmt\If_
{
if (!$coalesce->right instanceof \PhpParser\Node\Expr\Throw_) {
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '6e73a1f069afe9609437b2d4848ab323f03d0d20';
public const PACKAGE_VERSION = '4be1f2aee76f877575465e4234054e60db24944a';
/**
* @var string
*/
public const RELEASE_DATE = '2021-07-29 09:16:05';
public const RELEASE_DATE = '2021-07-29 11:56:43';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210729\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitc87132382a4bb65142243642edd4101b::getLoader();
return ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitc87132382a4bb65142243642edd4101b
class ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2
{
private static $loader;

Expand All @@ -22,15 +22,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitc87132382a4bb65142243642edd4101b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitc87132382a4bb65142243642edd4101b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInitc87132382a4bb65142243642edd4101b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -42,19 +42,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitc87132382a4bb65142243642edd4101b::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirec87132382a4bb65142243642edd4101b($fileIdentifier, $file);
composerRequire3996bdffc40725c5d7c283d383d6c8c2($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequirec87132382a4bb65142243642edd4101b($fileIdentifier, $file)
function composerRequire3996bdffc40725c5d7c283d383d6c8c2($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitc87132382a4bb65142243642edd4101b
class ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -3852,9 +3852,9 @@ class ComposerStaticInitc87132382a4bb65142243642edd4101b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc87132382a4bb65142243642edd4101b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc87132382a4bb65142243642edd4101b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc87132382a4bb65142243642edd4101b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit3996bdffc40725c5d7c283d383d6c8c2::$classMap;

}, null, ClassLoader::class);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210729\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitc87132382a4bb65142243642edd4101b', false) && !interface_exists('ComposerAutoloaderInitc87132382a4bb65142243642edd4101b', false) && !trait_exists('ComposerAutoloaderInitc87132382a4bb65142243642edd4101b', false)) {
spl_autoload_call('RectorPrefix20210729\ComposerAutoloaderInitc87132382a4bb65142243642edd4101b');
if (!class_exists('ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2', false) && !interface_exists('ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2', false) && !trait_exists('ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2', false)) {
spl_autoload_call('RectorPrefix20210729\ComposerAutoloaderInit3996bdffc40725c5d7c283d383d6c8c2');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210729\Doctrine\Inflector\Inflector');
Expand Down Expand Up @@ -3308,9 +3308,9 @@ function print_node() {
return \RectorPrefix20210729\print_node(...func_get_args());
}
}
if (!function_exists('composerRequirec87132382a4bb65142243642edd4101b')) {
function composerRequirec87132382a4bb65142243642edd4101b() {
return \RectorPrefix20210729\composerRequirec87132382a4bb65142243642edd4101b(...func_get_args());
if (!function_exists('composerRequire3996bdffc40725c5d7c283d383d6c8c2')) {
function composerRequire3996bdffc40725c5d7c283d383d6c8c2() {
return \RectorPrefix20210729\composerRequire3996bdffc40725c5d7c283d383d6c8c2(...func_get_args());
}
}
if (!function_exists('parseArgs')) {
Expand Down

0 comments on commit e5958f3

Please sign in to comment.