PHP 8.2.31
Preview: DefineFuncCallAnalyzer.php Size: 1.10 KB
/opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-downgrade-php/src/NodeAnalyzer/DefineFuncCallAnalyzer.php

<?php

declare (strict_types=1);
namespace Rector\NodeAnalyzer;

use PhpParser\Node\Expr;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Scalar\String_;
use Rector\NodeNameResolver\NodeNameResolver;
final class DefineFuncCallAnalyzer
{
    /**
     * @readonly
     * @var \Rector\NodeNameResolver\NodeNameResolver
     */
    private $nodeNameResolver;
    public function __construct(NodeNameResolver $nodeNameResolver)
    {
        $this->nodeNameResolver = $nodeNameResolver;
    }
    /**
     * @param string[] $constants
     */
    public function isDefinedWithConstants(Expr $expr, array $constants) : bool
    {
        if (!$expr instanceof FuncCall) {
            return \false;
        }
        if (!$this->nodeNameResolver->isName($expr, 'defined')) {
            return \false;
        }
        if ($expr->isFirstClassCallable()) {
            return \false;
        }
        $firstArg = $expr->getArgs()[0];
        if (!$firstArg->value instanceof String_) {
            return \false;
        }
        $string = $firstArg->value;
        return \in_array($string->value, $constants, \true);
    }
}

Directory Contents

Dirs: 0 × Files: 3

Name Size Perms Modified Actions
696 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.10 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
4.69 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).