xref: /PHP-8.2/ext/random/random.stub.php (revision 7517cf3b)
1<?php
2
3/** @generate-class-entries */
4
5namespace {
6    /**
7     * @var int
8     * @cvalue MT_RAND_MT19937
9     */
10    const MT_RAND_MT19937 = UNKNOWN;
11    /**
12     * @var int
13     * @cvalue MT_RAND_PHP
14     */
15    const MT_RAND_PHP = UNKNOWN;
16
17    function lcg_value(): float {}
18
19    function mt_srand(int $seed = UNKNOWN, int $mode = MT_RAND_MT19937): void {}
20
21    /** @alias mt_srand */
22    function srand(int $seed = UNKNOWN, int $mode = MT_RAND_MT19937): void {}
23
24    function rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
25
26    function mt_rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
27
28    function mt_getrandmax(): int {}
29
30    /** @alias mt_getrandmax */
31    function getrandmax(): int {}
32
33    /** @refcount 1 */
34    function random_bytes(int $length): string {}
35
36    function random_int(int $min, int $max): int {}
37}
38
39namespace Random\Engine
40{
41    /**
42     * @strict-properties
43     */
44    final class Mt19937 implements \Random\Engine
45    {
46        public function __construct(int|null $seed = null, int $mode = MT_RAND_MT19937) {}
47
48        public function generate(): string {}
49
50        public function __serialize(): array {}
51
52        public function __unserialize(array $data): void {}
53
54        public function __debugInfo(): array {}
55    }
56
57    /**
58     * @strict-properties
59     */
60    final class PcgOneseq128XslRr64 implements \Random\Engine
61    {
62        public function __construct(string|int|null $seed = null) {}
63
64        /** @implementation-alias Random\Engine\Mt19937::generate */
65        public function generate(): string {}
66
67        public function jump(int $advance): void {}
68
69        /** @implementation-alias Random\Engine\Mt19937::__serialize */
70        public function __serialize(): array {}
71
72        /** @implementation-alias Random\Engine\Mt19937::__unserialize */
73        public function __unserialize(array $data): void {}
74
75        /** @implementation-alias Random\Engine\Mt19937::__debugInfo */
76        public function __debugInfo(): array {}
77    }
78
79    /**
80     * @strict-properties
81     */
82    final class Xoshiro256StarStar implements \Random\Engine
83    {
84        public function __construct(string|int|null $seed = null) {}
85
86        /** @implementation-alias Random\Engine\Mt19937::generate */
87        public function generate(): string {}
88
89        public function jump(): void {}
90
91        public function jumpLong(): void {}
92
93        /** @implementation-alias Random\Engine\Mt19937::__serialize */
94        public function __serialize(): array {}
95
96        /** @implementation-alias Random\Engine\Mt19937::__unserialize */
97        public function __unserialize(array $data): void {}
98
99        /** @implementation-alias Random\Engine\Mt19937::__debugInfo */
100        public function __debugInfo(): array {}
101    }
102
103    /**
104     * @strict-properties
105     * @not-serializable
106     */
107    final class Secure implements \Random\CryptoSafeEngine
108    {
109        /** @implementation-alias Random\Engine\Mt19937::generate */
110        public function generate(): string {}
111    }
112}
113
114namespace Random
115{
116    interface Engine
117    {
118        public function generate(): string;
119    }
120
121    interface CryptoSafeEngine extends Engine
122    {
123    }
124
125    /**
126     * @strict-properties
127     */
128    final class Randomizer
129    {
130        public readonly Engine $engine;
131
132        public function __construct(?Engine $engine = null) {}
133
134        public function nextInt(): int {}
135
136        public function getInt(int $min, int $max): int {}
137
138        public function getBytes(int $length): string {}
139
140        public function shuffleArray(array $array): array {}
141
142        public function shuffleBytes(string $bytes): string {}
143
144        public function pickArrayKeys(array $array, int $num): array {}
145
146        public function __serialize(): array {}
147
148        public function __unserialize(array $data): void {}
149    }
150
151    /**
152     * @strict-properties
153     */
154    class RandomError extends \Error
155    {
156    }
157
158    /**
159     * @strict-properties
160     */
161    class BrokenRandomEngineError extends RandomError
162    {
163    }
164
165    /**
166     * @strict-properties
167     */
168    class RandomException extends \Exception
169    {
170    }
171}
172