xref: /PHP-8.2/ext/reflection/tests/bug38217.phpt (revision f8d79582)
1--TEST--
2Bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory)
3--FILE--
4<?php
5
6class ObjectOne {
7    public function __construct() {
8    }
9}
10
11$class= new ReflectionClass('ObjectOne');
12var_dump($class->newInstanceArgs());
13
14class ObjectTwo {
15    public function __construct($var) {
16        var_dump($var);
17    }
18}
19
20$class= new ReflectionClass('ObjectTwo');
21try {
22    var_dump($class->newInstanceArgs());
23} catch (Throwable $e) {
24    echo "Exception: " . $e->getMessage() . "\n";
25}
26var_dump($class->newInstanceArgs(array('test')));
27
28
29echo "Done\n";
30?>
31--EXPECTF--
32object(ObjectOne)#%d (0) {
33}
34Exception: Too few arguments to function ObjectTwo::__construct(), 0 passed and exactly 1 expected
35string(4) "test"
36object(ObjectTwo)#%d (0) {
37}
38Done
39