1--TEST--
2ReflectionClass::getReflectionConstants() with $filter
3--FILE--
4<?php
5class A {
6    public const PUBLIC_CONST = 'BAR';
7    public const ANOTHER_PUBLIC_CONST = 'BAZ';
8    protected const PROTECTED_CONST = 'FOO';
9    private const PRIVATE_CONST = 'QUOZ';
10}
11
12class B {
13  public const PUBLIC_CONST = 'BAR';
14  protected const ANOTHER_PROTECTED_CONST = 'BAZ';
15  protected const PROTECTED_CONST = 'FOO';
16  private const PRIVATE_CONST = 'QUOZ';
17}
18
19class C {
20  public const PUBLIC_CONST = 'BAR';
21  protected const PROTECTED_CONST = 'FOO';
22  private const PRIVATE_CONST = 'QUOZ';
23  private const ANOTHER_PRIVATE_CONST = 'BAZ';
24}
25
26$reflectionClassA = new ReflectionClass(A::class);
27var_dump($reflectionClassA->getReflectionConstants(ReflectionClassConstant::IS_PUBLIC));
28
29$reflectionClassB = new ReflectionClass(B::class);
30var_dump($reflectionClassB->getReflectionConstants(ReflectionClassConstant::IS_PROTECTED));
31
32$reflectionClassC = new ReflectionClass(C::class);
33var_dump($reflectionClassC->getReflectionConstants(ReflectionClassConstant::IS_PRIVATE));
34?>
35--EXPECTF--
36array(2) {
37  [0]=>
38  object(ReflectionClassConstant)#%d (%d) {
39    ["name"]=>
40    string(%d) "PUBLIC_CONST"
41    ["class"]=>
42    string(%d) "A"
43  }
44  [1]=>
45  object(ReflectionClassConstant)#%d (%d) {
46    ["name"]=>
47    string(%d) "ANOTHER_PUBLIC_CONST"
48    ["class"]=>
49    string(%d) "A"
50  }
51}
52array(2) {
53  [0]=>
54  object(ReflectionClassConstant)#%d (%d) {
55    ["name"]=>
56    string(%d) "ANOTHER_PROTECTED_CONST"
57    ["class"]=>
58    string(%d) "B"
59  }
60  [1]=>
61  object(ReflectionClassConstant)#%d (%d) {
62    ["name"]=>
63    string(%d) "PROTECTED_CONST"
64    ["class"]=>
65    string(%d) "B"
66  }
67}
68array(2) {
69  [0]=>
70  object(ReflectionClassConstant)#%d (%d) {
71    ["name"]=>
72    string(%d) "PRIVATE_CONST"
73    ["class"]=>
74    string(%d) "C"
75  }
76  [1]=>
77  object(ReflectionClassConstant)#%d (%d) {
78    ["name"]=>
79    string(%d) "ANOTHER_PRIVATE_CONST"
80    ["class"]=>
81    string(%d) "C"
82  }
83}
84