Expose attribute getters to the runtime
commitd43a8b9eca253be63f8379a2aec97f8cc818c1ee
authorJeff Hemphill <jhemphill@fb.com>
Tue, 11 Aug 2020 17:50:17 +0000 (11 10:50 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 11 Aug 2020 17:56:49 +0000 (11 10:56 -0700)
tree33a45b8b29c27bbc3e8d58132c2bb2f45010fcf7
parent2ba031f23cdeb8ccd443cba387b84e8e3c0819d3
Expose attribute getters to the runtime

Summary:
This diff exposes two new functions to userspace:

```
namespace HH\Facts {

/**
 * Get all attributes on the given type.
 *
 * Throw InvalidOperationException if Facts is not enabled.
 */
<<__Native>>
function type_attributes(
  classname<mixed> $type,
): vec<classname<\HH\ClassAttribute>>;

/**
 * Get all parameters for the given attribute on the given type.
 *
 * Throw InvalidOperationException if Facts is not enabled.
 */
<<__Native>>
function type_attribute_parameters(
  classname<mixed> $type,
  classname<\HH\ClassAttribute> $attribute,
): vec<dynamic>;

} // namespace HH\Facts
```

This allows us to get the attributes of a class without actually loading the unit which defines the class.

Reviewed By: dneiter

Differential Revision: D23006450

fbshipit-source-id: 3309e8af7f36f0c443c23a1cf8916af31f0ad74d
hphp/runtime/base/autoload-map.h