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