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