mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-30 07:50:53 +00:00
7e7a2f067a
476cfb00cb
disable fallback for now
20 lines
691 B
PHP
20 lines
691 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Php74\Tokenizer;
|
|
|
|
use PhpParser\Node\Expr\Ternary;
|
|
use Rector\ValueObject\Application\File;
|
|
final class ParenthesizedNestedTernaryAnalyzer
|
|
{
|
|
public function isParenthesized(File $file, Ternary $ternary) : bool
|
|
{
|
|
$oldTokens = $file->getOldTokens();
|
|
$startTokenPos = $ternary->getStartTokenPos();
|
|
$endTokenPos = $ternary->getEndTokenPos();
|
|
$hasOpenParentheses = isset($oldTokens[$startTokenPos]) && $oldTokens[$startTokenPos] === '(';
|
|
$hasCloseParentheses = isset($oldTokens[$endTokenPos]) && $oldTokens[$endTokenPos] === ')';
|
|
return $hasOpenParentheses || $hasCloseParentheses;
|
|
}
|
|
}
|