yiisoft/yii2 · error · yii\base\InvalidArgumentException

Length must be greater than 0.

Error message

Length must be greater than 0.

What it means

Error "Length must be greater than 0." thrown in yiisoft/yii2.

Source

Thrown at framework/db/SqlTokenizer.php:381

        $isKeyword = $this->isKeyword($this->_buffer, $content);
        $this->_currentToken[] = new SqlToken([
            'type' => $isKeyword ? SqlToken::TYPE_KEYWORD : SqlToken::TYPE_TOKEN,
            'content' => is_string($content) ? $content : $this->_buffer,
            'startOffset' => $this->offset - mb_strlen($this->_buffer, 'UTF-8'),
            'endOffset' => $this->offset,
        ]);
        $this->_buffer = '';
    }

    /**
     * Adds the specified length to the current offset.
     * @param int $length
     * @throws InvalidArgumentException
     */
    private function advance($length)
    {
        if ($length <= 0) {
            throw new InvalidArgumentException('Length must be greater than 0.');
        }

        $this->offset += $length;
        $this->_substrings = [];
    }

    /**
     * Returns whether the SQL code is completely traversed.
     * @return bool
     */
    private function isEof()
    {
        return $this->offset >= $this->length;
    }
}

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/db/SqlTokenizer.php:381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/cf0860c2b27d382f. Report an issue: GitHub.