Skip to content

Commit

Permalink
Updated Rector to commit 685fe90cb8752c2a288ee982d03d15d8df6b59f2
Browse files Browse the repository at this point in the history
rectorphp/rector-src@685fe90 Make SimplifyUselessVariableRector run without scope (#4791)
  • Loading branch information
TomasVotruba committed Aug 14, 2023
1 parent 8216388 commit 5b1b83e
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Return_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Type\MixedType;
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Core\NodeAnalyzer\CallAnalyzer;
use Rector\Core\NodeAnalyzer\VariableAnalyzer;
use Rector\Core\PhpParser\Node\AssignAndBinaryMap;
use Rector\Core\Rector\AbstractScopeAwareRector;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\SimplifyUselessVariableRectorTest
*/
final class SimplifyUselessVariableRector extends AbstractScopeAwareRector
final class SimplifyUselessVariableRector extends AbstractRector
{
/**
* @readonly
Expand Down Expand Up @@ -73,7 +71,7 @@ public function getNodeTypes() : array
/**
* @param StmtsAwareInterface $node
*/
public function refactorWithScope(Node $node, Scope $scope) : ?Node
public function refactor(Node $node) : ?Node
{
$stmts = $node->stmts;
if ($stmts === null) {
Expand All @@ -88,7 +86,7 @@ public function refactorWithScope(Node $node, Scope $scope) : ?Node
continue;
}
$previousStmt = $stmts[$key - 1];
if ($this->shouldSkipStmt($stmt, $previousStmt, $scope)) {
if ($this->shouldSkipStmt($stmt, $previousStmt)) {
return null;
}
if ($this->hasSomeComment($previousStmt)) {
Expand Down Expand Up @@ -120,15 +118,11 @@ private function processSimplifyUselessVariable(StmtsAwareInterface $stmtsAware,
unset($stmtsAware->stmts[$key - 1]);
return $stmtsAware;
}
private function shouldSkipStmt(Return_ $return, Stmt $previousStmt, Scope $scope) : bool
private function shouldSkipStmt(Return_ $return, Stmt $previousStmt) : bool
{
if (!$return->expr instanceof Variable) {
return \true;
}
$functionReflection = $scope->getFunction();
if ($functionReflection instanceof FunctionReflection && $functionReflection->returnsByReference()->yes()) {
return \true;
}
if ($return->getAttribute(AttributeKey::IS_BYREF_RETURN) === \true) {
return \true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2fe68ad7649faf0ebec883dcdeb91ee6118297ce';
public const PACKAGE_VERSION = '685fe90cb8752c2a288ee982d03d15d8df6b59f2';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-14 13:42:14';
public const RELEASE_DATE = '2023-08-14 15:27:05';
/**
* @var int
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Parameter/SimpleParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function provideArrayParameter(string $name) : array
{
$parameter = self::$parameters[$name] ?? [];
Assert::isArray($parameter);
$arrayIsList = function (array $array) : bool {
$arrayIsListFunction = function (array $array) : bool {
if (\function_exists('array_is_list')) {
return \array_is_list($array);
}
Expand All @@ -60,7 +60,7 @@ public static function provideArrayParameter(string $name) : array
}
return \true;
};
if ($arrayIsList($parameter)) {
if ($arrayIsListFunction($parameter)) {
// remove duplicates
$uniqueParameters = \array_unique($parameter);
return \array_values($uniqueParameters);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

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

return ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a::getLoader();
return ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239::getLoader();
10 changes: 5 additions & 5 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 ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a
class ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239
{
private static $loader;

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

spl_autoload_register(array('ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitef003b203866411843a8ebe2ebc6e04a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit9c580ee581ac8dff49b345ac114fb239', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
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 ComposerStaticInitef003b203866411843a8ebe2ebc6e04a
class ComposerStaticInit9c580ee581ac8dff49b345ac114fb239
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -2959,9 +2959,9 @@ class ComposerStaticInitef003b203866411843a8ebe2ebc6e04a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitef003b203866411843a8ebe2ebc6e04a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9c580ee581ac8dff49b345ac114fb239::$classMap;

}, null, ClassLoader::class);
}
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1917,12 +1917,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411"
"reference": "51f273773c748e34c3418cdc569992b5de00128f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
"reference": "47f72d5d2b747a73cf30bee2c798dc9cf21e3411",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/51f273773c748e34c3418cdc569992b5de00128f",
"reference": "51f273773c748e34c3418cdc569992b5de00128f",
"shasum": ""
},
"require": {
Expand All @@ -1948,7 +1948,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-08-13T11:39:42+00:00",
"time": "2023-08-14T14:00:50+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
Loading

0 comments on commit 5b1b83e

Please sign in to comment.