facebook / facebook/hhvm

Invalid default value in a reflection of internal functions

Open
#3,138 3 comments 0 reactions 0 assignees View on GitHub
low-pri php5 incompatibility
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

Default values of some arguments of internal functions are variable. For example arguments of `gmmktime` function depend on actual time. The methods `ReflectionParameter::isDefaultValueAvailable()` and `ReflectionParameter::getDefaultValue()` are poorly implemented in HHVM.

http://3v4l.org/t8M6E

``` php
$ref = new ReflectionFunction('gmmktime');
$params = $ref->getParameters();
$param = reset($params);

var_dump($param->isOptional(), $param->isDefaultValueAvailable());
if ($param->isDefaultValueAvailable()) {
var_dump($param->getDefaultValue());
}
```

HHVM

```
bool(true)
bool(true) # should be false
int(2147483647) # absolutely wrong value
```

PHP

```
bool(true)
bool(false)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.