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