[Php71] Skip magic const __LINE__ on BinaryOpBetweenNumberAndStringRector (#200)

This commit is contained in:
Abdul Malik Ikhsan 2021-06-11 06:19:21 +07:00 committed by GitHub
parent 8675bcb12a
commit 932458fd09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?php
namespace Rector\Tests\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector\Fixture;
class SkipMagicConstLine
{
public function run()
{
$value = __LINE__ - 1;
$value = 1 - __LINE__;
}
}

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Expr\BinaryOp\Concat;
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;
@ -102,6 +103,10 @@ CODE_SAMPLE
return false;
}
if ($expr instanceof Line) {
return false;
}
$value = null;
$exprStaticType = $this->getStaticType($expr);