nikic/PHP-Parser · error · \OutOfBoundsException

Length %d is out of bounds

Error message

Length %d is out of bounds

What it means

Error "Length %d is out of bounds" thrown in nikic/PHP-Parser.

Source

Thrown at lib/PhpParser/Node/Name.php:197

                return new static(\substr($this->name, $pos + 1));
            }
            return null;
        }

        $parts = \explode('\\', $this->name);
        $numParts = \count($parts);

        $realOffset = $offset < 0 ? $offset + $numParts : $offset;
        if ($realOffset < 0 || $realOffset > $numParts) {
            throw new \OutOfBoundsException(sprintf('Offset %d is out of bounds', $offset));
        }

        if (null === $length) {
            $realLength = $numParts - $realOffset;
        } else {
            $realLength = $length < 0 ? $length + $numParts - $realOffset : $length;
            if ($realLength < 0 || $realLength > $numParts - $realOffset) {
                throw new \OutOfBoundsException(sprintf('Length %d is out of bounds', $length));
            }
        }

        if ($realLength === 0) {
            // Empty slice is represented as null
            return null;
        }

        return new static(array_slice($parts, $realOffset, $realLength), $this->attributes);
    }

    /**
     * Concatenate two names, yielding a new Name instance.
     *
     * The type of the generated instance depends on which class this method is called on, for
     * example Name\FullyQualified::concat() will yield a Name\FullyQualified instance.
     *
     * If one of the arguments is null, a new instance of the other name will be returned. If both

View on GitHub (pinned to fbd47f7ebc)

When it happens

Trigger: Thrown at lib/PhpParser/Node/Name.php:197 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/f3717cfad13d786f. Report an issue: GitHub.