Skip to content

Commit

Permalink
[DeadCode] Skip sub type false => bool on RemoveUselessVarTagRector (#…
Browse files Browse the repository at this point in the history
…5588)

* [DeadCode] Skip sub type false => bool on RemoveUselessVarTagRector

* [DeadCode] Skip sub type false => bool on RemoveUselessVarTagRector

* [ci-review] Rector Rectify

* remove super type

* more fixture

* Fix

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Feb 9, 2024
1 parent 178ce5c commit a43f041
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\Fixture;

class RemoveEqualType
{
/** @var string|false|null */
private static string|false|null $inputArgSeparator = null;
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\Fixture;

class RemoveEqualType
{
private static string|false|null $inputArgSeparator = null;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\Fixture;

class RemoveSuperType
{
/** @var string|bool|null */
private static string|false|null $inputArgSeparator = null;
}

?>
-----
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\Fixture;

class RemoveSuperType
{
private static string|false|null $inputArgSeparator = null;
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Rector\Tests\DeadCode\Rector\Property\RemoveUselessVarTagRector\Fixture;

class SkipSubType
{
/** @var string|false|null */
private static string|bool|null $inputArgSeparator = null;
}
4 changes: 4 additions & 0 deletions src/NodeTypeResolver/TypeComparator/TypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function arePhpParserAndPhpStanPhpDocTypesEqual(
$node
);

if (! $this->areTypesEqual($phpParserNodeType, $phpStanDocType) && $this->isSubtype($phpStanDocType, $phpParserNodeType)) {
return false;
}

// normalize bool union types
$phpParserNodeType = $this->normalizeConstantBooleanType($phpParserNodeType);
$phpStanDocType = $this->normalizeConstantBooleanType($phpStanDocType);
Expand Down

0 comments on commit a43f041

Please sign in to comment.