phalcon/cphalcon · error · InvalidRandomInput

Input number must be a positive integer

Error message

Input number must be a positive integer

What it means

Error "Input number must be a positive integer" thrown in phalcon/cphalcon.

Source

Thrown at phalcon/Encryption/Security/Random.zep:274

    }

    /**
     * Generates a random number between 0 and $len
     *
     * Returns an integer: 0 <= result <= $len.
     *
     *```php
     * $random = new \Phalcon\Encryption\Security\Random();
     *
     * echo $random->number(16); // 8
     *```
     * @throws Exception If secure random number generator is not available,
     *                   unexpected partial read or $len <= 0
     */
    public function number(int len) -> int
    {
        if unlikely len <= 0 {
            throw new InvalidRandomInput();
        }

        return random_int(0, len);
    }

    /**
     * Generates a v4 random UUID (Universally Unique IDentifier)
     *
     * The version 4 UUID is purely random (except the version). It does not
     * contain meaningful information such as MAC address, time, etc. See RFC
     * 4122 for details of UUID.
     *
     * Delegates to `Phalcon\Encryption\Security\Uuid::v4()`. For other UUID
     * versions or object-based access use that class directly.
     *
     *```php
     * $random = new \Phalcon\Encryption\Security\Random();
     *

View on GitHub (pinned to b7419de9cd)

When it happens

Trigger: Thrown at phalcon/Encryption/Security/Random.zep:274 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/098bdbd5c21fc390. Report an issue: GitHub.