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