| @@ 306-319 (lines=14) @@ | ||
| 303 | $constants = []; |
|
| 304 | $reflection = new \ReflectionClass(static::class); |
|
| 305 | ||
| 306 | if (PHP_VERSION_ID >= 70100) { |
|
| 307 | // Since PHP-7.1 visibility modifiers are allowed for class constants |
|
| 308 | // for enumerations we are only interested in public once. |
|
| 309 | foreach ($reflection->getReflectionConstants() as $refl_constant) { |
|
| 310 | if ($refl_constant->isPublic()) { |
|
| 311 | $constants[$refl_constant->getName()] = $refl_constant->getValue(); |
|
| 312 | } |
|
| 313 | } |
|
| 314 | } else { |
|
| 315 | // In PHP < 7.1 all class constants were public by definition |
|
| 316 | foreach ($reflection->getConstants() as $constant => $constant_value) { |
|
| 317 | $constants[$constant] = $constant_value; |
|
| 318 | } |
|
| 319 | } |
|
| 320 | ||
| 321 | $bit = 1; |
|
| 322 | foreach ($constants as $constant => $constant_value) { |
|
| @@ 185-198 (lines=14) @@ | ||
| 182 | $constants = []; |
|
| 183 | $reflection = new \ReflectionClass($class); |
|
| 184 | ||
| 185 | if (PHP_VERSION_ID >= 70100) { |
|
| 186 | // Since PHP-7.1 visibility modifiers are allowed for class constants |
|
| 187 | // for enumerations we are only interested in public once. |
|
| 188 | foreach ($reflection->getReflectionConstants() as $refl_constant) { |
|
| 189 | if ($refl_constant->isPublic()) { |
|
| 190 | $constants[$refl_constant->getName()] = $refl_constant->getValue(); |
|
| 191 | } |
|
| 192 | } |
|
| 193 | } else { |
|
| 194 | // In PHP < 7.1 all class constants were public by definition |
|
| 195 | foreach ($reflection->getConstants() as $constant => $constant_value) { |
|
| 196 | $constants[$constant] = $constant_value; |
|
| 197 | } |
|
| 198 | } |
|
| 199 | ||
| 200 | foreach ($constants as $constant => $constant_value) { |
|
| 201 | self::$constants[$class][$constant] = $constant_value; |
|