Add $filter parameter for ReflectionClass::(getConstants|getReflectionConstants)

This solves [#79628](https://bugs.php.net/79628).

Similar to `ReflectionClass::getMethods()` and `ReflectionClass::getProperties()`,
this new `$filter` argument allows the filtering of constants defined in a class by
their visibility.

For that, we create three new constants for `ReflectionClassConstant`:

  * `IS_PUBLIC`
  * `IS_PROTECTED`
  * `IS_PRIVATE`

Closes GH-5649.
This commit is contained in:
Gabriel Caruso 2020-05-31 00:17:31 +02:00
parent 84492f5b50
commit 7439941d55
No known key found for this signature in database
GPG key ID: 4B385A6EE6C9678D
8 changed files with 188 additions and 22 deletions

View file

@ -263,10 +263,10 @@ class ReflectionClass implements Reflector
public function hasConstant(string $name) {}
/** @return array|null */
public function getConstants() {}
public function getConstants(int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {}
/** @return ReflectionClassConstant[] */
public function getReflectionConstants() {}
public function getReflectionConstants(int $filter = ReflectionClassConstant::IS_PUBLIC | ReflectionClassConstant::IS_PROTECTED | ReflectionClassConstant::IS_PRIVATE) {}
/** @return mixed */
public function getConstant(string $name) {}