Skip to content

Commit

Permalink
Updated Rector to commit 47fa234379b7b9f28081e8bc6e683628f8d53f2b
Browse files Browse the repository at this point in the history
rectorphp/rector-src@47fa234 [CodeQuality] Add Variable support on class arg on InlineIsAInstanceOfRector (#3261)
  • Loading branch information
TomasVotruba committed Jan 2, 2023
1 parent b8f374d commit 0fc42c2
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function removeByType(string $typeToRemove) : void
{
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (Node $node) use($typeToRemove) : ?int {
if ($node instanceof PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) {
if ($node instanceof PhpDocTagNode && $node->value instanceof $typeToRemove) {
// keep special annotation for tools
if (\strncmp($node->name, '@psalm-', \strlen('@psalm-')) === 0) {
return null;
Expand All @@ -280,7 +280,7 @@ public function removeByType(string $typeToRemove) : void
$this->markAsChanged();
return PhpDocNodeTraverser::NODE_REMOVE;
}
if (!\is_a($node, $typeToRemove, \true)) {
if (!$node instanceof $typeToRemove) {
return null;
}
$this->markAsChanged();
Expand Down Expand Up @@ -401,7 +401,7 @@ private function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagV
{
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
if (\is_a($phpDocTagValueNode, $tagValueNodeType, \true)) {
if ($phpDocTagValueNode instanceof $tagValueNodeType) {
return $name;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function findByType(PhpDocNode $phpDocNode, string $desiredType) : array
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$foundNodes = [];
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', static function (Node $node) use(&$foundNodes, $desiredType) : Node {
if (!\is_a($node, $desiredType, \true)) {
if (!$node instanceof $desiredType) {
return $node;
}
/** @var TNode $node */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function findParent(Node $node, callable $callable, array $allowedTypes)
return \true;
}
foreach ($parentNestingBreakTypes as $parentNestingBreakType) {
if (!\is_a($node, $parentNestingBreakType, \true)) {
if (!$node instanceof $parentNestingBreakType) {
continue;
}
$this->isBreakingNodeFoundFirst = \true;
Expand Down
4 changes: 2 additions & 2 deletions packages/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function isNullableTypeOfSpecificType(Node $node, string $desiredType) :
return \false;
}
$bareType = TypeCombinator::removeNull($nodeType);
return \is_a($bareType, $desiredType, \true);
return $bareType instanceof $desiredType;
}
public function getFullyQualifiedClassName(TypeWithClassName $typeWithClassName) : string
{
Expand Down Expand Up @@ -308,7 +308,7 @@ private function isMatchingUnionType(Type $resolvedType, ObjectType $requiredObj
private function resolveByNodeTypeResolvers(Node $node) : ?Type
{
foreach ($this->nodeTypeResolvers as $nodeClass => $nodeTypeResolver) {
if (!\is_a($node, $nodeClass, \true)) {
if (!$node instanceof $nodeClass) {
continue;
}
return $nodeTypeResolver->resolve($node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getNodeClasses() : array
public function resolve(Node $node) : Type
{
foreach (self::CAST_CLASS_TO_TYPE_MAP as $castClass => $typeClass) {
if (\is_a($node, $castClass, \true)) {
if ($node instanceof $castClass) {
return new $typeClass();
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/PhpDocParser/NodeValue/NodeValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function resolveByNode(Expr $expr)
}
// these values cannot be resolved in reliable way
foreach (self::UNRESOLVABLE_TYPES as $unresolvableType) {
if (\is_a($expr, $unresolvableType, \true)) {
if ($expr instanceof $unresolvableType) {
throw new ConstExprEvaluationException('The node "%s" value is not possible to resolve. Provide different one.');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\Type\Generic\GenericClassStringType;
use PHPStan\Type\ObjectType;
Expand Down Expand Up @@ -66,6 +67,12 @@ public function refactor(Node $node) : ?Node
if (!$this->isFirstObjectType($firstArgValue)) {
return null;
}
/**
* instanceof with Variable is ok, while on FuncCal with instanceof cause fatal error, see https://3v4l.org/IHb30
*/
if ($args[1]->value instanceof Variable) {
return new Instanceof_($firstArgValue, $args[1]->value);
}
$className = $this->resolveClassName($args[1]->value);
if ($className === null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/Rector/Cast/RecastingRemovalRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function refactor(Node $node) : ?Node
return null;
}
$sameNodeType = self::CAST_CLASS_TO_NODE_TYPE[$nodeClass];
if (!\is_a($nodeType, $sameNodeType, \true)) {
if (!$nodeType instanceof $sameNodeType) {
return null;
}
if ($this->shouldSkip($node->expr)) {
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/SideEffect/SideEffectNodeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function detect(Expr $expr) : bool
return \false;
}
foreach (self::SIDE_EFFECT_NODE_TYPES as $sideEffectNodeType) {
if (\is_a($expr, $sideEffectNodeType, \true)) {
if ($expr instanceof $sideEffectNodeType) {
return \false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class AlwaysStrictBoolExprAnalyzer
public function isStrictBoolExpr(Expr $expr) : bool
{
foreach (self::BOOL_TYPE_NODES as $boolTypeNode) {
if (\is_a($expr, $boolTypeNode, \true)) {
if ($expr instanceof $boolTypeNode) {
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 = 'cba980b719f48eb580f8afcf4e3843843436ba35';
public const PACKAGE_VERSION = '47fa234379b7b9f28081e8bc6e683628f8d53f2b';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-01-02 12:48:53';
public const RELEASE_DATE = '2023-01-02 12:54:27';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion src/NodeAnalyzer/CallAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function isObjectCall(Expr $expr) : bool
return $isObjectCallLeft || $isObjectCallRight;
}
foreach (self::OBJECT_CALL_TYPES as $objectCallType) {
if (\is_a($expr, $objectCallType, \true)) {
if ($expr instanceof $objectCallType) {
return \true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NodeManipulator/BinaryOpManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function normalizeCondition($condition) : callable
return $condition;
}
return static function (Node $node) use($condition) : bool {
return \is_a($node, $condition, \true);
return $node instanceof $condition;
};
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/NodeManipulator/IfManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,6 @@ private function hasOnlyStmtOfType(If_ $if, string $desiredType) : bool
if (\count($stmts) !== 1) {
return \false;
}
return \is_a($stmts[0], $desiredType);
return $stmts[0] instanceof $desiredType;
}
}
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 ComposerAutoloaderInit698705ff76bcaee632e92c2b89a6b858::getLoader();
return ComposerAutoloaderInit72bf78bd619f9883efa43bdc150df9dd::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 ComposerAutoloaderInit698705ff76bcaee632e92c2b89a6b858
class ComposerAutoloaderInit72bf78bd619f9883efa43bdc150df9dd
{
private static $loader;

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

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

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

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

$filesToLoad = \Composer\Autoload\ComposerStaticInit698705ff76bcaee632e92c2b89a6b858::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit72bf78bd619f9883efa43bdc150df9dd::$files;
$requireFile = 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 ComposerStaticInit698705ff76bcaee632e92c2b89a6b858
class ComposerStaticInit72bf78bd619f9883efa43bdc150df9dd
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3062,9 +3062,9 @@ class ComposerStaticInit698705ff76bcaee632e92c2b89a6b858
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit698705ff76bcaee632e92c2b89a6b858::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit698705ff76bcaee632e92c2b89a6b858::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit698705ff76bcaee632e92c2b89a6b858::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit72bf78bd619f9883efa43bdc150df9dd::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit72bf78bd619f9883efa43bdc150df9dd::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit72bf78bd619f9883efa43bdc150df9dd::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit 0fc42c2

Please sign in to comment.