isIdExpr($expr); } /** @phpstan-assert-if-true Node\Scalar\String_ $expr */ protected function isScalarString(Node $expr): bool { return $expr instanceof Node\Scalar\String_; } /** @phpstan-assert-if-true Expr\FuncCall $expr */ protected function isFuncCallExpr(Node $expr): bool { return $expr instanceof Expr\FuncCall; } protected function isStdRefCall(Node $expr): bool { return $this->isStaticCall($expr) && $this->isStdClassExpr($expr->class) && $this->isIdExpr($expr->name) && strtolower($expr->name->toString()) === 'ref'; } protected function isStdClassExpr(Node $expr): bool { return $this->isNameExpr($expr) && !$expr instanceof Node\Name\Relative && strtolower(ltrim($expr->toString(), '\\')) === 'std'; } /** @phpstan-assert-if-true Expr\MethodCall $expr */ protected function isMethodCall(Node $expr): bool { return $expr instanceof Expr\MethodCall; } /** @phpstan-assert-if-true Expr\StaticCall $expr */ protected function isStaticCall(Node $expr): bool { return $expr instanceof Expr\StaticCall; } /** @phpstan-assert-if-true Node\Scalar $expr */ protected function isScalar(Node $expr): bool { return $expr instanceof Node\Scalar; } /** @phpstan-assert-if-true Node\Scalar\Int_ $expr */ protected function isScalarInt(Node $expr): bool { return $expr instanceof Node\Scalar\Int_; } /** @phpstan-assert-if-true Expr\ConstFetch $expr */ protected function isScalarBool(Node $expr): bool { return $expr instanceof Expr\ConstFetch and in_array(strtolower($expr->name->toString()), ['true', 'false']); } /** @phpstan-assert-if-true Expr\Match_ $expr */ protected function isMatchExpr(Node $expr): bool { return $expr instanceof Expr\Match_; } /** @phpstan-assert-if-true Expr\Assign $expr */ protected function isAssignExpr(Node $expr): bool { return $expr instanceof Expr\Assign; } /** @phpstan-assert-if-true Expr\FuncCall|Expr\MethodCall|Expr\StaticCall $expr */ protected function isCallExpr(Node $expr): bool { return $expr instanceof Expr\FuncCall or $expr instanceof Expr\MethodCall or $expr instanceof Expr\StaticCall; } /** @phpstan-assert-if-true VariadicPlaceholder $expr */ protected function isPlaceholderExpr(Node $expr): bool { return $expr instanceof VariadicPlaceholder; } /** @phpstan-assert-if-true Node\Stmt\Return_ $expr */ protected function isReturnExpr(Node $expr): bool { return $expr instanceof Node\Stmt\Return_; } /** @phpstan-assert-if-true Node\Stmt\Break_ $expr */ protected function isBreakExpr(Node $expr): bool { return $expr instanceof Node\Stmt\Break_; } /** @phpstan-assert-if-true Node\Stmt\Continue_ $expr */ protected function isContinueExpr(Node $expr): bool { return $expr instanceof Node\Stmt\Continue_; } protected function isThrowExpr(Node $expr): bool { if ($expr instanceof Node\Stmt\Expression) { $expr = $expr->expr; } return $expr instanceof Expr\Throw_; } protected function isExitExpr(Node $expr): bool { if ($expr instanceof Node\Stmt\Expression) { $expr = $expr->expr; } return $expr instanceof Expr\Exit_; } /** @phpstan-assert-if-true Expr\Array_ $expr */ protected function isEmptyArray(Node $expr): bool { return $expr instanceof Expr\Array_ && count($expr->items) === 0; } /** @phpstan-assert-if-true Expr\ConstFetch $expr */ protected function isNull(Node $expr): bool { return $expr instanceof Expr\ConstFetch && strcasecmp($expr->name->toString(), 'null') === 0; } }