facebook / facebook/hhvm

ReflectionTypeConstant::getAssignedTypeText() does not handle namespaces correctly

Open
#7,367 2 comments 0 reactions 0 assignees View on GitHub
probably easy
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

### HHVM Version

3.15.0
### Standalone code, or other way to reproduce the problem

``` Hack
{
}

class Baz {
const type TMyType = Bar;
}

$tc = (new \ReflectionClass(Baz::class))->getTypeConstant('TMyType');
var_dump($tc->getAssignedTypeText());
```
### Expected result

```
string(30) "\Herp\Derp\Bar<\Herp\Derp\Foo>"
```
### Actual result

```
string(28) "Herp\Derp\Bar"
```

This is problematic because it can't be used in namespaced code, or easily converted to a format that is usable in namespaced code - this is fine:

``` Hack
$what
): void {
}
```

... but this isn't:

``` Hack
$what
): void {
}
```

```
$ hh_client
footest.php:6:3,15: Unbound name: MyOtherNamespace\Herp\Derp\Bar (an object type) (Naming[2049])
footest.php:6:3,15: Unbound name: MyOtherNamespace\Herp\Derp\Bar (an object type) (Naming[2049])
footest.php:6:17,29: Unbound name: MyOtherNamespace\Herp\Derp\Foo (an object type) (Naming[2049])
footest.php:6:17,29: Unbound name: MyOtherNamespace\Herp\Derp\Foo (an object type) (Naming[2049])
```

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.