nikic/PHP-Parser · error · LogicException

Expected string or Expr

Error message

Expected string or Expr

What it means

Error "Expected string or Expr" thrown in nikic/PHP-Parser.

Source

Thrown at lib/PhpParser/BuilderFactory.php:373

        for ($i = 1; $i < $numExprs; $i++) {
            $lastConcat = new Concat($lastConcat, $this->normalizeStringExpr($exprs[$i]));
        }
        return $lastConcat;
    }

    /**
     * @param string|Expr $expr
     */
    private function normalizeStringExpr($expr): Expr {
        if ($expr instanceof Expr) {
            return $expr;
        }

        if (\is_string($expr)) {
            return new String_($expr);
        }

        throw new \LogicException('Expected string or Expr');
    }
}

View on GitHub (pinned to fbd47f7ebc)

When it happens

Trigger: Thrown at lib/PhpParser/BuilderFactory.php:373 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nikic/PHP-Parser@fbd47f7ebc (2026-08-17). Data as JSON: /api/errors/42322c2935d60a09. Report an issue: GitHub.