xref: /php-src/ext/zend_test/test.stub.php (revision f2e199e8)
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        /** @var mixed */
42        public static $_StaticProp;
43        public static int $staticIntProp = 123;
44
45        public int $intProp = 123;
46        public ?stdClass $classProp = null;
47        public stdClass|Iterator|null $classUnionProp = null;
48        public Traversable&Countable $classIntersectionProp;
49        public readonly int $readonlyProp;
50
51        public static function is_object(): int {}
52
53        /** @deprecated */
54        public function __toString(): string {}
55
56        public function returnsStatic(): static {}
57
58        public function returnsThrowable(): Throwable {}
59
60        static public function variadicTest(string|Iterator ...$elements) : static {}
61
62        public function takesUnionType(stdclass|Iterator $arg): void {}
63    }
64
65    class _ZendTestMagicCall
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    /** @genstubs-expose-comment-block
114     * "Lorem ipsum"
115     * @see https://www.php.net
116     * @since 8.1
117     */
118    #[Attribute(Attribute::TARGET_PROPERTY)]
119    final class ZendTestPropertyAttribute {
120        /** @genstubs-expose-comment-block
121         * "Lorem ipsum"
122         * @see https://www.php.net
123         * @since 8.4
124         */
125        public string $parameter;
126
127        public function __construct(string $parameter) {}
128    }
129
130    class ZendTestClassWithMethodWithParameterAttribute {
131        final public function no_override(
132            #[ZendTestParameterAttribute("value2")]
133            string $parameter
134        ): int {}
135        public function override(
136            #[ZendTestParameterAttribute("value3")]
137            string $parameter
138        ): int {}
139    }
140
141    class ZendTestChildClassWithMethodWithParameterAttribute extends ZendTestClassWithMethodWithParameterAttribute {
142        public function override(
143            #[ZendTestParameterAttribute("value4")]
144            string $parameter
145        ): int {}
146    }
147
148    class ZendTestClassWithPropertyAttribute {
149        // this attribute must be added internally in MINIT
150        #[ZendTestAttribute]
151        public string $attributed;
152    }
153
154    final class ZendTestForbidDynamicCall {
155        public function call(): void {}
156        public static function callStatic(): void {}
157    }
158
159    enum ZendTestUnitEnum {
160        case Foo;
161        case Bar;
162    }
163
164    enum ZendTestStringEnum: string {
165        case Foo = "Test1";
166        case Bar = 'Test2';
167        case Baz = "Test2\\a";
168        case FortyTwo = "42";
169    }
170
171    enum ZendTestIntEnum: int {
172        case Foo = 1;
173        case Bar = 3;
174        case Baz = -1;
175    }
176
177    function zend_test_array_return(): array {}
178
179    /** @genstubs-expose-comment-block
180     * "Lorem ipsum"
181     * @see https://www.php.net
182     * @since 8.3
183     */
184     /**
185     * @internal
186     * @compile-time-eval
187     */
188    function zend_test_nullable_array_return(): null|array {}
189
190    function zend_test_void_return(): void {}
191
192    function zend_test_compile_string(string $source_string, string $filename, int $position): void {}
193
194    /** @deprecated */
195    function zend_test_deprecated(mixed $arg = null): void {}
196
197    /** @alias zend_test_void_return */
198    function zend_test_aliased(): void {}
199
200    /**
201      * @deprecated
202      * @alias zend_test_void_return
203      */
204    function zend_test_deprecated_aliased(): void {}
205
206    function zend_create_unterminated_string(string $str): string {}
207
208    function zend_terminate_string(string &$str): void {}
209
210    function zend_leak_variable(mixed $variable): void {}
211
212    function zend_leak_bytes(int $bytes = 3): void {}
213
214    function zend_string_or_object(object|string $param): object|string {}
215
216    function zend_string_or_object_or_null(object|string|null $param): object|string|null {}
217
218    /** @param stdClass|string $param */
219    function zend_string_or_stdclass($param): stdClass|string {}
220
221    /** @param stdClass|string|null $param */
222    function zend_string_or_stdclass_or_null($param): stdClass|string|null {}
223
224    function zend_number_or_string(string|int|float $param): string|int|float {}
225
226    function zend_number_or_string_or_null(string|int|float|null $param): string|int|float|null {}
227
228    function zend_iterable(iterable $arg1, ?iterable $arg2 = null): void {}
229
230    function zend_weakmap_attach(object $object, mixed $value): bool {}
231    function zend_weakmap_remove(object $object): bool {}
232    function zend_weakmap_dump(): array {}
233
234    function zend_get_unit_enum(): ZendTestUnitEnum {}
235
236    function zend_test_parameter_with_attribute(
237        #[ZendTestParameterAttribute("value1")]
238        string $parameter
239    ): int {}
240
241    function zend_get_current_func_name(): string {}
242
243    function zend_call_method(object|string $obj_or_class, string $method, mixed $arg1 = UNKNOWN, mixed $arg2 = UNKNOWN): mixed {}
244
245    function zend_test_zend_ini_parse_quantity(string $str): int {}
246    function zend_test_zend_ini_parse_uquantity(string $str): int {}
247
248    function zend_test_zend_ini_str(): string {}
249
250#ifdef ZEND_CHECK_STACK_LIMIT
251    function zend_test_zend_call_stack_get(): ?array {}
252    function zend_test_zend_call_stack_use_all(): int {}
253#endif
254
255    function zend_test_is_string_marked_as_valid_utf8(string $string): bool {}
256
257    function zend_get_map_ptr_last(): int {}
258
259    function zend_test_crash(?string $message = null): void {}
260
261    function zend_test_fill_packed_array(array &$array): void {}
262
263    /** @return resource */
264    function zend_test_create_throwing_resource() {}
265
266    function get_open_basedir(): ?string {}
267
268#if defined(HAVE_LIBXML) && !defined(PHP_WIN32)
269function zend_test_override_libxml_global_state(): void {}
270#endif
271
272    function zend_test_is_pcre_bundled(): bool {}
273}
274
275namespace ZendTestNS {
276
277    class Foo {
278        /** @tentative-return-type */
279        public function method(): int {}
280    }
281
282    class UnlikelyCompileError {
283        /* This method signature would create a compile error due to the string
284         * "ZendTestNS\UnlikelyCompileError" in the generated macro call */
285        public function method(): ?UnlikelyCompileError {}
286    }
287
288    class NotUnlikelyCompileError {
289        /* This method signature would create a compile error due to the string
290         * "ZendTestNS\NotUnlikelyCompileError" in the generated macro call */
291        public function method(): ?NotUnlikelyCompileError {}
292    }
293}
294
295namespace ZendTestNS2 {
296
297    /** @var string */
298    const ZEND_CONSTANT_A = "namespaced";
299
300    class Foo {
301        public ZendSubNS\Foo $foo;
302
303        public function method(): void {}
304    }
305
306    function namespaced_func(): bool {}
307
308    /** @deprecated */
309    function namespaced_deprecated_func(): void {}
310
311    /** @alias zend_test_void_return */
312    function namespaced_aliased_func(): void {}
313
314    /**
315     * @deprecated
316     * @alias zend_test_void_return
317     */
318    function namespaced_deprecated_aliased_func(): void {}
319}
320
321namespace ZendTestNS2\ZendSubNS {
322
323    /** @var string */
324    const ZEND_CONSTANT_A = \ZendTestNS2\ZEND_CONSTANT_A;
325
326    class Foo {
327        public function method(): void {}
328    }
329
330    function namespaced_func(): bool {}
331
332    /** @deprecated */
333    function namespaced_deprecated_func(): void {}
334
335    /** @alias zend_test_void_return */
336    function namespaced_aliased_func(): void {}
337
338    /**
339     * @deprecated
340     * @alias zend_test_void_return
341     */
342    function namespaced_deprecated_aliased_func(): void {}
343}
344