Updated Rector to commit 805b7b7d39fcd989873452ddbbd57e2a76150022

805b7b7d39 [Performance] Do not traverse current and children on context check Break_ and If_ (#4271)
This commit is contained in:
Tomas Votruba 2023-06-18 06:22:16 +00:00
parent 10dcb93b50
commit b326a57561
6 changed files with 27 additions and 14 deletions

View File

@ -4,12 +4,16 @@ declare (strict_types=1);
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Do_;
use PhpParser\Node\Stmt\For_;
use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\While_;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitorAbstract;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface;
@ -28,7 +32,10 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
public function enterNode(Node $node) : ?Node
{
if ($node instanceof For_ || $node instanceof Foreach_ || $node instanceof While_ || $node instanceof Do_) {
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node->stmts, static function (Node $subNode) {
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node->stmts, static function (Node $subNode) : ?int {
if ($subNode instanceof Class_ || $subNode instanceof FunctionLike && !$subNode instanceof ArrowFunction) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if ($subNode instanceof If_ || $subNode instanceof Break_) {
$subNode->setAttribute(AttributeKey::IS_IN_LOOP, \true);
}

View File

@ -4,7 +4,10 @@ declare (strict_types=1);
namespace Rector\Php70\Rector\Break_;
use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Switch_;
use PhpParser\NodeTraverser;
@ -83,7 +86,10 @@ CODE_SAMPLE
public function refactor(Node $node)
{
if ($node instanceof Switch_) {
$this->traverseNodesWithCallable($node->cases, static function (Node $subNode) {
$this->traverseNodesWithCallable($node->cases, static function (Node $subNode) : ?int {
if ($subNode instanceof Class_ || $subNode instanceof FunctionLike && !$subNode instanceof ArrowFunction) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}
if (!$subNode instanceof Break_) {
return null;
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'fc423fd69f9a96932ae62d09c6f01812678651cc';
public const PACKAGE_VERSION = '805b7b7d39fcd989873452ddbbd57e2a76150022';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-18 12:57:12';
public const RELEASE_DATE = '2023-06-18 13:18:11';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710
class ComposerAutoloaderInit470ad92e04ebe7807935539568e0c68f
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit470ad92e04ebe7807935539568e0c68f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit470ad92e04ebe7807935539568e0c68f', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbcd345f54a340521d99a0a0b7daad710::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit470ad92e04ebe7807935539568e0c68f::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitbcd345f54a340521d99a0a0b7daad710::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit470ad92e04ebe7807935539568e0c68f::$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 ComposerStaticInitbcd345f54a340521d99a0a0b7daad710
class ComposerStaticInit470ad92e04ebe7807935539568e0c68f
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3095,9 +3095,9 @@ class ComposerStaticInitbcd345f54a340521d99a0a0b7daad710
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbcd345f54a340521d99a0a0b7daad710::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbcd345f54a340521d99a0a0b7daad710::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbcd345f54a340521d99a0a0b7daad710::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit470ad92e04ebe7807935539568e0c68f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit470ad92e04ebe7807935539568e0c68f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit470ad92e04ebe7807935539568e0c68f::$classMap;
}, null, ClassLoader::class);
}