Updated Rector to commit 112e490e3ca0d5949c97189c31fd4aef8833cfc1

112e490e3c Remove PARENT_NODE from CatchExceptionNameMatchingTypeRector (#3929)
This commit is contained in:
Tomas Votruba 2023-05-22 14:09:12 +00:00
parent ed0c750f6e
commit 215231b596
6 changed files with 20 additions and 28 deletions

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\NodeTypeResolver\Node;
use PHPStan\Analyser\Scope;
/**
* @enum
*/
@ -18,6 +19,7 @@ final class AttributeKey
*/
public const VIRTUAL_NODE = 'virtual_node';
/**
* Contains @see Scope
* @var string
*/
public const SCOPE = 'scope';

View File

@ -7,15 +7,12 @@ use RectorPrefix202305\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Catch_;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\TryCatch;
use PHPStan\Analyser\Scope;
use PHPStan\Type\ObjectType;
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\Rector\AbstractRector;
use Rector\Naming\Naming\AliasNameResolver;
use Rector\Naming\Naming\PropertyNaming;
@ -97,6 +94,11 @@ CODE_SAMPLE
if ($this->shouldSkip($stmt)) {
continue;
}
// variable defined first only resolvable by Scope pulled from Stmt
$scope = $stmt->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
continue;
}
/** @var TryCatch $stmt */
$catch = $stmt->catches[0];
/** @var Variable $catchVar */
@ -115,11 +117,6 @@ CODE_SAMPLE
if ($oldVariableName === $newVariableName) {
continue;
}
// variable defined first only resolvable by Scope pulled from Stmt
$scope = $stmt->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
continue;
}
$isFoundInPrevious = $scope->hasVariableType($newVariableName)->yes();
if ($isFoundInPrevious) {
return null;
@ -153,14 +150,7 @@ CODE_SAMPLE
return \true;
}
$catch = $stmt->catches[0];
if (!$catch->var instanceof Variable) {
return \true;
}
$parentNode = $stmt->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof FileWithoutNamespace || $parentNode instanceof Namespace_) {
return \false;
}
return !$parentNode instanceof FunctionLike;
return !$catch->var instanceof Variable;
}
/**
* @param Stmt[] $stmts

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '26b32be535516bf80da94b85b2172b2ac64f9a7c';
public const PACKAGE_VERSION = '112e490e3ca0d5949c97189c31fd4aef8833cfc1';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-22 13:53:32';
public const RELEASE_DATE = '2023-05-22 15:04:39';
/**
* @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 ComposerAutoloaderInitf4f87a222c2fea7e474c3b0896bc69ba::getLoader();
return ComposerAutoloaderInit040f96abad6093fd2fa49efc3bc742c5::getLoader();

View File

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