Skip to content

Commit 2e0cde6

Browse files
authored
Fix logical comparision (#265)
* Fix logical comparision * Fix tests and remove redundant import
1 parent dd8086f commit 2e0cde6

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

rules-tests/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector/Fixture/no_isset_on_expr.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class NoIssetOnExpr
2020
{
2121
public function run($backedEnumClassName, $backedEnumValue)
2222
{
23-
if ($backedEnumClassName::tryFrom($backedEnumValue) !== null) {
23+
if ($backedEnumClassName::tryFrom($backedEnumValue) === null) {
2424
throw new \Symfony\Component\DependencyInjection\Exception\RuntimeException(sprintf('Enum value "%s" is not backed by "%s".', $backedEnumValue, $backedEnumClassName));
2525
}
2626
return $backedEnumClassName::tryFrom($backedEnumValue);

rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PhpParser\Node\Expr\Assign;
1212
use PhpParser\Node\Expr\BinaryOp\Coalesce;
1313
use PhpParser\Node\Expr\BinaryOp\Identical;
14-
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
1514
use PhpParser\Node\Expr\BooleanNot;
1615
use PhpParser\Node\Expr\Closure;
1716
use PhpParser\Node\Expr\ConstFetch;
@@ -253,7 +252,7 @@ private function createIf(Coalesce $coalesce, Throw_ $throw): If_
253252
if ($conditionalExpr instanceof Variable || $conditionalExpr instanceof ArrayDimFetch || $conditionalExpr instanceof PropertyFetch) {
254253
$booleanNot = new BooleanNot(new Isset_([$conditionalExpr]));
255254
} else {
256-
$booleanNot = new NotIdentical($conditionalExpr, new ConstFetch(new Name('null')));
255+
$booleanNot = new Identical($conditionalExpr, new ConstFetch(new Name('null')));
257256
}
258257

259258
return new If_($booleanNot, [

0 commit comments

Comments
 (0)