Skip to content

Commit

Permalink
Updated Rector to commit d49ace3c33ae8e662791fd1bb82e1467a0a48530
Browse files Browse the repository at this point in the history
rectorphp/rector-src@d49ace3 [CodeQuality] Skip compare nullable object on UseIdenticalOverEqualWithSameTypeRector (#6474)
  • Loading branch information
TomasVotruba committed Nov 22, 2024
1 parent 1e9b8ef commit 97ae544
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1750,12 +1750,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
"reference": "08149e6a9a8d2ffded202a8cd97831221f38adbe"
"reference": "e7d904cb17bcb69829929b3542e40f6e0f0da64c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/08149e6a9a8d2ffded202a8cd97831221f38adbe",
"reference": "08149e6a9a8d2ffded202a8cd97831221f38adbe",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/e7d904cb17bcb69829929b3542e40f6e0f0da64c",
"reference": "e7d904cb17bcb69829929b3542e40f6e0f0da64c",
"shasum": ""
},
"require": {
Expand All @@ -1773,7 +1773,7 @@
"tomasvotruba\/class-leak": "^1.0",
"tracy\/tracy": "^2.10"
},
"time": "2024-11-22T17:26:03+00:00",
"time": "2024-11-22T17:36:00+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
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 02ae401'), '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 08149e6'), '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 a506b2c'), '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 ecf4d7d'));
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 02ae401'), '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 e7d904c'), '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 a506b2c'), '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 ecf4d7d'));
private function __construct()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class ColumnPropertyTypeResolver
* @param array<string, Type> $doctrineTypeToScalarType
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/basic-mapping.html#doctrine-mapping-types
*/
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, AttributeFinder $attributeFinder, array $doctrineTypeToScalarType = null)
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, TypeFactory $typeFactory, AttributeFinder $attributeFinder, ?array $doctrineTypeToScalarType = null)
{
$doctrineTypeToScalarType ??= [
'tinyint' => new BooleanType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ private function replaceNewInParams($functionLike)
} else {
$assign = new AssignCoalesce($param->var, $default);
}
// recheck after
if ($isConstructor) {
$param->type = $this->ensureNullableType($param->type);
}
$stmts[] = new Expression($assign);
$param->default = $this->nodeFactory->createNull();
}
Expand All @@ -177,23 +181,17 @@ private function ensureNullableType($type)
return new NullableType($type);
}
if ($type instanceof UnionType) {
if (!$this->hasNull($type)) {
$type->types[] = new Name('null');
foreach ($type->types as $typeChild) {
if (!$typeChild instanceof Identifier) {
continue;
}
if ($typeChild->toLowerString() === 'null') {
return $type;
}
}
$type->types[] = new Identifier('null');
return $type;
}
throw new ShouldNotHappenException();
}
private function hasNull(UnionType $unionType) : bool
{
foreach ($unionType->types as $type) {
if (!$type instanceof Identifier) {
continue;
}
if ($type->toLowerString() === 'null') {
return \true;
}
}
return \false;
}
}

0 comments on commit 97ae544

Please sign in to comment.