xref: /PHP-8.4/ext/zend_test/test.stub.php (revision e643129b)
1<?php
2
3/**
4 * @generate-class-entries static
5 * @generate-legacy-arginfo 80000
6 * @undocumentable
7 */
8namespace {
9    require "Zend/zend_attributes.stub.php";
10
11    /**
12     * @var int
13     * @deprecated
14     */
15    const ZEND_TEST_DEPRECATED = 42;
16
17    /** @var string */
18    const ZEND_CONSTANT_A = "global";
19
20    interface _ZendTestInterface
21    {
22        /** @var int */
23        /** @genstubs-expose-comment-block
24         * "Lorem ipsum"
25         * @see https://www.php.net
26         * @since 8.2
27         */
28        public const DUMMY = 0;
29    }
30
31    /** @alias _ZendTestClassAlias */
32    class _ZendTestClass implements _ZendTestInterface {
33        public const mixed TYPED_CLASS_CONST1 = [];
34        public const int|array TYPED_CLASS_CONST2 = 42;
35        /**
36         * @var int
37         * @cvalue 1
38         */
39        public const int|string TYPED_CLASS_CONST3 = UNKNOWN;
40
41        /**
42         * @deprecated
43         */
44        public const int ZEND_TEST_DEPRECATED = 42;
45
46        #[\Deprecated(message: "custom message")]
47        public const int ZEND_TEST_DEPRECATED_ATTR = 42;
48
49        /** @var mixed */
50        public static $_StaticProp;
51        public static int $staticIntProp = 123;
52
53        public int $intProp = 123;
54        public ?stdClass $classProp = null;
55        public stdClass|Iterator|null $classUnionProp = null;
56        public Traversable&Countable $classIntersectionProp;
57        public readonly int $readonlyProp;
58
59        public static function is_object(): int {}
60
61        /** @deprecated */
62        public function __toString(): string {}
63
64        public function returnsStatic(): static {}
65
66        public function returnsThrowable(): Throwable {}
67
68        static public function variadicTest(string|Iterator ...$elements) : static {}
69
70        public function takesUnionType(stdclass|Iterator $arg): void {}
71    }
72
73    class _ZendTestMagicCall
74    {
75        public function __call(string $name, array $args): mixed {}
76    }
77
78    class _ZendTestMagicCallForward
79    {
80        public function __call(string $name, array $args): mixed {}
81    }
82
83    class _ZendTestChildClass extends _ZendTestClass
84    {
85        public function returnsThrowable(): Exception {}
86    }
87
88    class ZendAttributeTest {
89        /** @var int */
90        #[ZendTestRepeatableAttribute]
91        #[ZendTestRepeatableAttribute]
92        public const TEST_CONST = 1;
93
94        /** @var mixed */
95        #[ZendTestRepeatableAttribute]
96        #[ZendTestPropertyAttribute("testProp")]
97        public $testProp;
98
99        #[ZendTestAttribute]
100        public function testMethod(): bool {}
101    }
102
103    trait _ZendTestTrait {
104        /** @var mixed */
105        public $testProp;
106        public Traversable|Countable $classUnionProp;
107
108        public function testMethod(): bool {}
109    }
110
111    #[Attribute(Attribute::TARGET_ALL)]
112    final class ZendTestAttribute {
113    }
114
115    #[Attribute(Attribute::TARGET_ALL)]
116    final class ZendTestAttributeWithArguments {
117        public readonly mixed $arg;
118
119        public function __construct(mixed $arg) {}
120    }
121
122    #[Attribute(Attribute::TARGET_ALL|Attribute::IS_REPEATABLE)]
123    final class ZendTestRepeatableAttribute {
124    }
125
126    #[Attribute(Attribute::TARGET_PARAMETER)]
127    final class ZendTestParameterAttribute {
128        public string $parameter;
129
130        public function __construct(string $parameter) {}
131    }
132
133    /** @genstubs-expose-comment-block
134     * "Lorem ipsum"
135     * @see https://www.php.net
136     * @since 8.1
137     */
138    #[Attribute(Attribute::TARGET_PROPERTY)]
139    final class ZendTestPropertyAttribute {
140        /** @genstubs-expose-comment-block
141         * "Lorem ipsum"
142         * @see https://www.php.net
143         * @since 8.4
144         */
145        public string $parameter;
146
147        public function __construct(string $parameter) {}
148    }
149
150    class ZendTestClassWithMethodWithParameterAttribute {
151        final public function no_override(
152            #[ZendTestParameterAttribute("value2")]
153            string $parameter
154        ): int {}
155        public function override(
156            #[ZendTestParameterAttribute("value3")]
157            string $parameter
158        ): int {}
159    }
160
161    class ZendTestChildClassWithMethodWithParameterAttribute extends ZendTestClassWithMethodWithParameterAttribute {
162        public function override(
163            #[ZendTestParameterAttribute("value4")]
164            string $parameter
165        ): int {}
166    }
167
168    class ZendTestClassWithPropertyAttribute {
169        // this attribute must be added internally in MINIT
170        #[ZendTestAttribute]
171        public string $attributed;
172    }
173
174    final class ZendTestForbidDynamicCall {
175        public function call(): void {}
176        public static function callStatic(): void {}
177    }
178
179    enum ZendTestUnitEnum {
180        case Foo;
181        case Bar;
182    }
183
184    enum ZendTestStringEnum: string {
185        case Foo = "Test1";
186        case Bar = 'Test2';
187        case Baz = "Test2\\a";
188        case FortyTwo = "42";
189    }
190
191    enum ZendTestIntEnum: int {
192        case Foo = 1;
193        case Bar = 3;
194        case Baz = -1;
195    }
196
197    function zend_test_array_return(): array {}
198
199    /** @genstubs-expose-comment-block
200     * "Lorem ipsum"
201     * @see https://www.php.net
202     * @since 8.3
203     */
204     /**
205     * @internal
206     * @compile-time-eval
207     */
208    function zend_test_nullable_array_return(): null|array {}
209
210    function zend_test_void_return(): void {}
211
212    function zend_test_compile_string(string $source_string, string $filename, int $position): void {}
213
214    /** @deprecated */
215    function zend_test_deprecated(mixed $arg = null): void {}
216
217    #[\Deprecated(message: "custom message")]
218    function zend_test_deprecated_attr(): void {}
219
220    /** @alias zend_test_void_return */
221    function zend_test_aliased(): void {}
222
223    /**
224      * @deprecated
225      * @alias zend_test_void_return
226      */
227    function zend_test_deprecated_aliased(): void {}
228
229    function zend_create_unterminated_string(string $str): string {}
230
231    function zend_terminate_string(string &$str): void {}
232
233    function zend_leak_variable(mixed $variable): void {}
234
235    function zend_leak_bytes(int $bytes = 3): void {}
236
237    function zend_string_or_object(object|string $param): object|string {}
238
239    function zend_string_or_object_or_null(object|string|null $param): object|string|null {}
240
241    /** @param stdClass|string $param */
242    function zend_string_or_stdclass($param): stdClass|string {}
243
244    /** @param stdClass|string|null $param */
245    function zend_string_or_stdclass_or_null($param): stdClass|string|null {}
246
247    function zend_number_or_string(string|int|float $param): string|int|float {}
248
249    function zend_number_or_string_or_null(string|int|float|null $param): string|int|float|null {}
250
251    function zend_iterable(iterable $arg1, ?iterable $arg2 = null): void {}
252
253    function zend_weakmap_attach(object $object, mixed $value): bool {}
254    function zend_weakmap_remove(object $object): bool {}
255    function zend_weakmap_dump(): array {}
256
257    function zend_get_unit_enum(): ZendTestUnitEnum {}
258
259    function zend_test_parameter_with_attribute(
260        #[ZendTestParameterAttribute("value1")]
261        string $parameter
262    ): int {}
263
264    #[ZendTestAttributeWithArguments(arg: "foo")]
265    function zend_test_attribute_with_named_argument(): void {}
266
267    function zend_get_current_func_name(): string {}
268
269    function zend_call_method(object|string $obj_or_class, string $method, mixed $arg1 = UNKNOWN, mixed $arg2 = UNKNOWN): mixed {}
270
271    function zend_object_init_with_constructor(string $class, mixed ...$args): mixed {}
272
273    function zend_test_zend_ini_parse_quantity(string $str): int {}
274    function zend_test_zend_ini_parse_uquantity(string $str): int {}
275
276    function zend_test_zend_ini_str(): string {}
277
278#ifdef ZEND_CHECK_STACK_LIMIT
279    function zend_test_zend_call_stack_get(): ?array {}
280    function zend_test_zend_call_stack_use_all(): int {}
281#endif
282
283    function zend_test_is_string_marked_as_valid_utf8(string $string): bool {}
284
285    function zend_get_map_ptr_last(): int {}
286
287    function zend_test_crash(?string $message = null): void {}
288
289    function zend_test_fill_packed_array(array &$array): void {}
290
291    /** @return resource */
292    function zend_test_create_throwing_resource() {}
293
294    function get_open_basedir(): ?string {}
295
296#if defined(HAVE_LIBXML) && !defined(PHP_WIN32)
297function zend_test_override_libxml_global_state(): void {}
298#endif
299
300    function zend_test_is_pcre_bundled(): bool {}
301
302#if defined(PHP_WIN32)
303    function zend_test_set_fmode(bool $binary): void {}
304#endif
305
306    /** @param resource $stream */
307    function zend_test_cast_fread($stream): void {}
308
309    function zend_test_is_zend_ptr(int $addr): bool {}
310
311    function zend_test_log_err_debug(string $str): void {}
312}
313
314namespace ZendTestNS {
315
316    class Foo {
317        /** @tentative-return-type */
318        public function method(): int {}
319    }
320
321    class UnlikelyCompileError {
322        /* This method signature would create a compile error due to the string
323         * "ZendTestNS\UnlikelyCompileError" in the generated macro call */
324        public function method(): ?UnlikelyCompileError {}
325    }
326
327    class NotUnlikelyCompileError {
328        /* This method signature would create a compile error due to the string
329         * "ZendTestNS\NotUnlikelyCompileError" in the generated macro call */
330        public function method(): ?NotUnlikelyCompileError {}
331    }
332}
333
334namespace ZendTestNS2 {
335
336    /** @var string */
337    const ZEND_CONSTANT_A = "namespaced";
338
339    class Foo {
340        public ZendSubNS\Foo $foo;
341
342        public function method(): void {}
343    }
344
345    function namespaced_func(): bool {}
346
347    /** @deprecated */
348    function namespaced_deprecated_func(): void {}
349
350    /** @alias zend_test_void_return */
351    function namespaced_aliased_func(): void {}
352
353    /**
354     * @deprecated
355     * @alias zend_test_void_return
356     */
357    function namespaced_deprecated_aliased_func(): void {}
358}
359
360namespace ZendTestNS2\ZendSubNS {
361
362    /** @var string */
363    const ZEND_CONSTANT_A = \ZendTestNS2\ZEND_CONSTANT_A;
364
365    class Foo {
366        public function method(): void {}
367    }
368
369    function namespaced_func(): bool {}
370
371    /** @deprecated */
372    function namespaced_deprecated_func(): void {}
373
374    /** @alias zend_test_void_return */
375    function namespaced_aliased_func(): void {}
376
377    /**
378     * @deprecated
379     * @alias zend_test_void_return
380     */
381    function namespaced_deprecated_aliased_func(): void {}
382}
383