Updated Rector to commit ed433a87a3e746547b2a22ece373a4bbebf5823d

ed433a87a3 [TypeDeclaration] Skip assign in if condition on BinaryOpNullableToInstanceofRector (#6629)
This commit is contained in:
Tomas Votruba 2024-12-25 10:35:55 +00:00
parent 0c1978cd37
commit b24cfd9322
4 changed files with 21 additions and 9 deletions

View File

@ -1808,12 +1808,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "bd24ae11a0cf94b05b78fb0adbb1cae05f4e2e3d"
"reference": "a4a69edbc895a78a49f53898d2b1f570f791661f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/bd24ae11a0cf94b05b78fb0adbb1cae05f4e2e3d",
"reference": "bd24ae11a0cf94b05b78fb0adbb1cae05f4e2e3d",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/a4a69edbc895a78a49f53898d2b1f570f791661f",
"reference": "a4a69edbc895a78a49f53898d2b1f570f791661f",
"shasum": ""
},
"require": {
@ -1834,7 +1834,7 @@
"tomasvotruba\/class-leak": "^1.2",
"tracy\/tracy": "^2.10"
},
"time": "2024-12-23T14:02:30+00:00",
"time": "2024-12-25T10:32:20+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f740789'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 183795c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main bd24ae1'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 29a1abf'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f740789'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 183795c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main a4a69ed'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 29a1abf'));
private function __construct()
{
}

View File

@ -14,6 +14,7 @@ use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use Rector\PHPUnit\NodeAnalyzer\IdentifierManipulator;
@ -78,7 +79,7 @@ final class AssertEqualsToSameRector extends AbstractRector
return null;
}
$args = $node->getArgs();
if (!isset($args[0])) {
if (!isset($args[0], $args[1])) {
return null;
}
$firstArgValue = $args[0]->value;
@ -88,12 +89,23 @@ final class AssertEqualsToSameRector extends AbstractRector
if ($this->shouldSkipConstantArrayType($firstArgValue)) {
return null;
}
if ($this->isName($node->name, 'assertEquals')) {
$firstArgType = $this->nodeTypeResolver->getNativeType($args[0]->value);
$secondArgType = $this->nodeTypeResolver->getNativeType($args[1]->value);
// loose comparison
if ($firstArgType instanceof IntegerType && ($secondArgType instanceof FloatType || $secondArgType instanceof MixedType)) {
return null;
}
if ($firstArgType instanceof FloatType && ($secondArgType instanceof IntegerType || $secondArgType instanceof MixedType)) {
return null;
}
}
$hasChanged = $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP);
return $hasChanged ? $node : null;
}
private function shouldSkipConstantArrayType(Expr $expr) : bool
{
$type = $this->getType($expr);
$type = $this->nodeTypeResolver->getNativeType($expr);
if (!$type instanceof ConstantArrayType) {
return \false;
}
@ -137,7 +149,7 @@ final class AssertEqualsToSameRector extends AbstractRector
if ($expr instanceof InterpolatedString) {
return \true;
}
$valueNodeType = $this->nodeTypeResolver->getType($expr);
$valueNodeType = $this->nodeTypeResolver->getNativeType($expr);
return $this->isScalarType($valueNodeType);
}
}