11<?php namespace lang \reflection ;
22
3- use Traversable ;
3+ use Traversable , ReflectionClassConstant ;
44
55/**
66 * Type constants enumeration and lookup
@@ -15,24 +15,10 @@ class Constants extends Members {
1515 * @return iterable
1616 */
1717 public function getIterator (): Traversable {
18- if (PHP_VERSION_ID >= 70100 ) {
19- foreach ($ this ->reflect ->getReflectionConstants () as $ constant ) {
20- if (0 !== strncmp ($ constant ->name , '__ ' , 2 )) {
21- yield $ constant ->name => new Constant ($ constant );
22- }
18+ foreach ($ this ->reflect ->getReflectionConstants () as $ constant ) {
19+ if (0 !== strncmp ($ constant ->name , '__ ' , 2 )) {
20+ yield $ constant ->name => new Constant ($ constant );
2321 }
24- } else {
25-
26- // PHP 7.0 does not have getReflectionConstants(), enumerate constants
27- // using name and values instead and use ReflectionClassConstant polyfill
28- //
29- // @codeCoverageIgnoreStart
30- foreach ($ this ->reflect ->getConstants () as $ name => $ _ ) {
31- if (0 !== strncmp ($ name , '__ ' , 2 )) {
32- yield $ name => new Constant (new \ReflectionClassConstant ($ this ->reflect ->name , $ name ));
33- }
34- }
35- // @codeCoverageIgnoreEnd
3622 }
3723 }
3824
@@ -44,7 +30,7 @@ public function getIterator(): Traversable {
4430 */
4531 public function named ($ name ) {
4632 return $ this ->reflect ->hasConstant ($ name )
47- ? new Constant (new \ ReflectionClassConstant ($ this ->reflect ->name , $ name ))
33+ ? new Constant (new ReflectionClassConstant ($ this ->reflect ->name , $ name ))
4834 : null
4935 ;
5036 }
0 commit comments