nikic/PHP-Parser · error · \InvalidArgumentException

Can only dump nodes and arrays.

Error message

Can only dump nodes and arrays.

What it means

Error "Can only dump nodes and arrays." thrown in nikic/PHP-Parser.

Source

Thrown at lib/PhpParser/NodeDumper.php:158

            foreach ($node as $key => $value) {
                $this->res .= "$this->nl    " . $key . ': ';
                $this->dumpRecursive($value);
            }
            $this->res .= "$this->nl)";
        } elseif ($node instanceof Comment) {
            $this->res .= \str_replace("\n", $this->nl, $node->getReformattedText());
        } elseif (\is_string($node)) {
            $this->res .= \str_replace("\n", $this->nl, $node);
        } elseif (\is_int($node) || \is_float($node)) {
            $this->res .= $node;
        } elseif (null === $node) {
            $this->res .= 'null';
        } elseif (false === $node) {
            $this->res .= 'false';
        } elseif (true === $node) {
            $this->res .= 'true';
        } else {
            throw new \InvalidArgumentException('Can only dump nodes and arrays.');
        }
        if ($indent) {
            $this->nl = \substr($this->nl, 0, -4);
        }
    }

    protected function dumpFlags(int $flags): string {
        $strs = [];
        if ($flags & Modifiers::PUBLIC) {
            $strs[] = 'PUBLIC';
        }
        if ($flags & Modifiers::PROTECTED) {
            $strs[] = 'PROTECTED';
        }
        if ($flags & Modifiers::PRIVATE) {
            $strs[] = 'PRIVATE';
        }
        if ($flags & Modifiers::ABSTRACT) {

View on GitHub (pinned to fbd47f7ebc)

When it happens

Trigger: Thrown at lib/PhpParser/NodeDumper.php:158 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/2f6783915b9eacbe. Report an issue: GitHub.