1 | <?php |
||
8 | trait ConstantTrait |
||
9 | { |
||
10 | /** |
||
11 | * @type ReflectionConstant[] |
||
12 | */ |
||
13 | protected $constants = []; |
||
14 | |||
15 | /** |
||
16 | * Gets the interfaces, without inherited ones. |
||
17 | * |
||
18 | * Must be implemented by classes using this trait |
||
19 | * |
||
20 | * @return ReflectionInterface[] |
||
21 | */ |
||
22 | abstract public function getSelfInterfaces(); |
||
23 | |||
24 | /** |
||
25 | * Gets the filename of the file in which the class has been defined. |
||
26 | * |
||
27 | * Must be implemented by classes using this trait. |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | abstract public function getFileName(); |
||
32 | |||
33 | /** |
||
34 | * Gets defined constants from an entity, including inherited ones. |
||
35 | * |
||
36 | * @return ReflectionConstant[] |
||
37 | */ |
||
38 | 36 | public function getConstants() |
|
58 | |||
59 | /** |
||
60 | * Gets defined constants from an entity, without inherited ones. |
||
61 | * |
||
62 | * @return ReflectionConstant[] |
||
63 | */ |
||
64 | 48 | public function getSelfConstants() |
|
73 | |||
74 | /** |
||
75 | * Gets defined constant. |
||
76 | * |
||
77 | * @param string $constantSearchedName Name of the constant |
||
78 | * |
||
79 | * @see http://php.net/manual/en/reflectionclass.getconstant.php#113642 Why returning false if the constant does no exists ? |
||
80 | * It could be the value of the constant... Should throw a \ReflectionException ? |
||
81 | * |
||
82 | * @return mixed Value of the constant, false if constant not found |
||
83 | */ |
||
84 | 12 | public function getConstant($constantSearchedName) |
|
94 | |||
95 | /** |
||
96 | * Checks if constant is defined. |
||
97 | * |
||
98 | * @param string $constantSearchedName Name of the constant |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | 12 | public function hasConstant($constantSearchedName) |
|
112 | |||
113 | /** |
||
114 | * Add a constant to an entity. |
||
115 | * |
||
116 | * @param ReflectionConstant $constant |
||
117 | */ |
||
118 | 741 | public function addConstant(ReflectionConstant $constant) |
|
126 | } |
||
127 |