diff --git a/.travis.yml b/.travis.yml index 7c505dc..4df3e48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,9 @@ language: php matrix: include: - - php: 5.3 - dist: precise - - php: 5.4 - - php: 5.5 - - php: 5.6 - - php: 7.0 - php: 7.1 - php: 7.2 + - php: 7.3 - php: nightly fast_finish: true allow_failures: @@ -17,15 +12,13 @@ matrix: before_install: - phpenv config-rm xdebug.ini || true - - composer config --global github-oauth.github.com $GITHUB_TOKEN -install: composer install --prefer-dist --no-progress --no-interaction +install: composer install --no-progress --no-interaction script: scripts/travis after_script: scripts/travis-after env: global: - ELOQUENT_PUBLISH_VERSION=7.1 - - secure: "kK6XSHAaOLavtUZthJr3+VpsCedSrf0eJXz+lit/i2weg8g7RrReo2Ta/pWhzS3aP6mHkRKyB4UzMVebuFOoHuJkn+WGgnVUp1YhmL9F9wK4rzJQlGDmcwpSI3v6G69Mzm10o1v4ZVtAlaDD7MzbkTC8bw/Vg2BYeRZ8jFCzI7U=" cache: directories: diff --git a/composer.json b/composer.json index 1e66c91..9ffd0be 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=5.3" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^4" @@ -27,7 +27,7 @@ }, "config": { "platform": { - "php": "5.3.99" + "php": "7.1.99" } } } diff --git a/src/AbstractEnumeration.php b/src/AbstractEnumeration.php index 7838be7..a2637f7 100644 --- a/src/AbstractEnumeration.php +++ b/src/AbstractEnumeration.php @@ -23,8 +23,10 @@ final protected static function initializeMembers() { $reflector = new ReflectionClass(get_called_class()); - foreach ($reflector->getConstants() as $key => $value) { - new static($key, $value); + foreach ($reflector->getReflectionConstants() as $constant) { + if ($constant->isPublic()) { + new static($constant->getName(), $constant->getValue()); + } } } } diff --git a/test/src/MixedAccessibilityEnumeration.php b/test/src/MixedAccessibilityEnumeration.php new file mode 100644 index 0000000..b6900a4 --- /dev/null +++ b/test/src/MixedAccessibilityEnumeration.php @@ -0,0 +1,17 @@ +assertSame($expected, $actual); } + + /** + * Tests that only public constants are included as enumeration members. + */ + public function testMixedAccessibility() + { + $members = MixedAccessibilityEnumeration::members(); + + self::assertCount(2, $members); + self::assertArrayHasKey(MixedAccessibilityEnumeration::IMPLICIT_PUBLIC, $members); + self::assertArrayHasKey(MixedAccessibilityEnumeration::EXPLICIT_PUBLIC, $members); + } }