Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jan 6, 2025
1 parent 9de51c4 commit 616bfed
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\Fixture;

class OnAssign
{
public function run(?\DateTimeImmutable $param)
{
if (null === ($paramValue = $param)) {
return 'no';
}

return $paramValue;
}
}

?>
-----
<?php

namespace Rector\Tests\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector\Fixture;

class OnAssign
{
public function run(?\DateTimeImmutable $param)
{
if (!($paramValue = $param) instanceof \DateTimeImmutable) {
return 'no';
}

return $paramValue;
}
}

?>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Expr\BooleanNot;
Expand Down Expand Up @@ -87,11 +86,7 @@ private function processConvertToExclusiveType(
ObjectType $objectType,
Expr $expr,
Identical|NotIdentical $binaryOp
): BooleanNot|Instanceof_|null {
if ($expr instanceof Assign) {
return null;
}

): BooleanNot|Instanceof_ {
$fullyQualifiedType = $objectType instanceof ShortenedObjectType || $objectType instanceof AliasedObjectType
? $objectType->getFullyQualifiedName()
: $objectType->getClassName();
Expand Down

0 comments on commit 616bfed

Please sign in to comment.