[php-src] Issue #12371: "internal error" in ReflectionParameter::getDefaultValue on Variable-length argument list
| From: | divinity76 | Date: | Fri, 06 Oct 2023 15:10:18 +0000 |
| Subject: | [php-src] Issue #12371: "internal error" in ReflectionParameter::getDefaultValue on Variable-length argument list | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245509@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12371
Author: divinity76
### Description
The following code:
```php
<?php
declare(strict_types=1);
function f(...$args){
echo "see? arguments are optional.\n";
}
f();
$ref = new ReflectionFunction('f');
var_dump($ref->getParameters()[0]->getDefaultValue());
```
Resulted in this output:
```
see? arguments are optional.
Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value in
/in/gHhJ2:8
Stack trace:
#0 /in/gHhJ2(8): ReflectionParameter->getDefaultValue()
#1 {main}
thrown in /in/gHhJ2 on line 8
```
But I expected this output instead:
```
see? arguments are optional.
array(0) {
}
```
3v4l: https://3v4l.org/gHhJ2
### PHP Version
8.2.11
### Operating System
windows 10