Replacing `$members` generation with reflection/cache
Summary:
The current generation of the `Members()` method for PU (which outputs the list of all PU instances in a PU) is currently not recursively looking into parent classes, where it should. In the following, I don't mention mangling to make things more clear:
If the class is not extending any other, `Members` just return a keyset with all the local information available. We use memoization here.
```
class C {
...
<<__Memoize>>
public static function Members() : keyset<string> {
return keyset[ .. strings based on local PU instances ...];
}
}
```
If the class is extending another one, we look up the hierarchy, which be costly, so here, we also use memoization. The code looks like:
```
class C extends D {
...
<<__Override, __Memoize>>
public static function Members() : keyset<string> {
$result = keyset[ .. strings based on local PU instances ...];
$class = new ReflectionClass(parent::class);
try {
// might throw if the method is not in the parent class
$method = $class->getMethod('Members');
// method is here, call it
$parent_members = $method->invoke(null);
foreach ($parent_members as $p) {
$result[] = $p;
}
} catch (ReflectionException $_) {
// nothing in the parent, only use local info
}
return $result;
}
}
```
This diff also update the name mangling (because it didn't work with properties). Now
```
class C {
enum E {
:Foo (...);
}
}
```
will lead to a property `C::pu$E$Members`.
Reviewed By: francesco-zappa-nardelli
Differential Revision:
D20920121
fbshipit-source-id:
ec9e957521b283553e74d8cdb7d175390cbf6134