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