betterNodeFinder = $betterNodeFinder; $this->nodeNameResolver = $nodeNameResolver; $this->valueResolver = $valueResolver; } public function detect(\PhpParser\Node\Expr $expr, string $functionName) : bool { /** @var If_|null $firstParentIf */ $firstParentIf = $this->betterNodeFinder->findParentType($expr, \PhpParser\Node\Stmt\If_::class); if (!$firstParentIf instanceof \PhpParser\Node\Stmt\If_) { return \false; } if (!$firstParentIf->cond instanceof \PhpParser\Node\Expr\FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($firstParentIf->cond, 'function_exists')) { return \false; } /** @var FuncCall $functionExists */ $functionExists = $firstParentIf->cond; return $this->valueResolver->isValue($functionExists->args[0]->value, $functionName); } }