Skip to content

Commit

Permalink
[DeadCode] Skip @return positive-int|0 on RemoveUselessReturnTagRector (
Browse files Browse the repository at this point in the history
#6576)

* [DeadCode] Skip @return positive-int|0 on RemoveUselessReturnTagRector

* fix
  • Loading branch information
samsonasik authored Dec 12, 2024
1 parent 96110a9 commit 362e9b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector\Fixture;

class SkipPositiveIntOrZero
{
/**
* @return positive-int|0
*/
function foo(): int
{
return rand(0, 1) ? 10 : 0;
}
}
16 changes: 1 addition & 15 deletions src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,7 @@ private function createUnionOrSingleType(array $types): Type
return $types[0];
}

$unionType = new UnionType($types);

if ($unionType->isFloat()->yes()) {
return new IntegerType();
}

if ($unionType->isString()->yes()) {
return new StringType();
}

if ($unionType->isInteger()->yes()) {
return new IntegerType();
}

return $unionType;
return new UnionType($types);
}

private function removeValueFromConstantType(Type $type): Type
Expand Down

0 comments on commit 362e9b5

Please sign in to comment.