Skip to content

Commit

Permalink
Updated Rector to commit 805b7b7d39fcd989873452ddbbd57e2a76150022
Browse files Browse the repository at this point in the history
rectorphp/rector-src@805b7b7 [Performance] Do not traverse current and children on context check Break_ and If_ (#4271)
  • Loading branch information
TomasVotruba committed Jun 18, 2023
1 parent 10dcb93 commit b326a57
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
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;
Expand All @@ -28,7 +32,10 @@ public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTrave
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
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;
Expand Down Expand Up @@ -83,7 +86,10 @@ public function getNodeTypes() : array
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;
}
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 = '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
*/
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 ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710::getLoader();
return ComposerAutoloaderInit470ad92e04ebe7807935539568e0c68f::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 ComposerAutoloaderInitbcd345f54a340521d99a0a0b7daad710
class ComposerAutoloaderInit470ad92e04ebe7807935539568e0c68f
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
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;
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 ComposerStaticInitbcd345f54a340521d99a0a0b7daad710
class ComposerStaticInit470ad92e04ebe7807935539568e0c68f
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b326a57

Please sign in to comment.