Skip to content

Commit

Permalink
Skip divide in NumericReturnTypeFromStrictScalarReturnsRector (#4298)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 19, 2023
1 parent cc70ba9 commit 41184e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.

This file was deleted.

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

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\NumericReturnTypeFromStrictScalarReturnsRector\Fixture;

final class SkipDivideIntegers
{
public function resolve(int $first, int $second)
{
return $first / $second;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\BinaryOp\BitwiseAnd;
use PhpParser\Node\Expr\BinaryOp\Div;
use PhpParser\Node\Expr\BinaryOp\Minus;
use PhpParser\Node\Expr\BinaryOp\Mod;
use PhpParser\Node\Expr\BinaryOp\Mul;
Expand Down Expand Up @@ -101,7 +100,7 @@ public function refactor(Node $node): ?Node
}

// @see https://chat.openai.com/share/a9e4fb74-5366-4c4c-9998-d6caeb8b5acc
if ($return->expr instanceof Minus || $return->expr instanceof Plus || $return->expr instanceof Mul || $return->expr instanceof Div || $return->expr instanceof Mod || $return->expr instanceof BitwiseAnd || $return->expr instanceof ShiftRight || $return->expr instanceof ShiftLeft) {
if ($return->expr instanceof Minus || $return->expr instanceof Plus || $return->expr instanceof Mul || $return->expr instanceof Mod || $return->expr instanceof BitwiseAnd || $return->expr instanceof ShiftRight || $return->expr instanceof ShiftLeft) {
return $this->refactorBinaryOp($return->expr, $node);
}

Expand Down

0 comments on commit 41184e1

Please sign in to comment.