Skip to content

Commit

Permalink
[Php71] Skip magic const __LINE__ on BinaryOpBetweenNumberAndStringRe…
Browse files Browse the repository at this point in the history
…ctor (#200)
  • Loading branch information
samsonasik committed Jun 10, 2021
1 parent 8675bcb commit 932458f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\Tests\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector\Fixture;

class SkipMagicConstLine
{
public function run()
{
$value = __LINE__ - 1;
$value = 1 - __LINE__;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\MagicConst\Line;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\Constant\ConstantStringType;
use Rector\Core\Rector\AbstractRector;
Expand Down Expand Up @@ -102,6 +103,10 @@ private function isStringOrStaticNonNumbericString(Expr $expr): bool
return false;
}

if ($expr instanceof Line) {
return false;
}

$value = null;
$exprStaticType = $this->getStaticType($expr);

Expand Down

0 comments on commit 932458f

Please sign in to comment.