Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,23 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

- php: nightly
fast_finish: true
allow_failures:
- php: nightly

before_install:
- phpenv config-rm xdebug.ini || true
- composer config --global github-oauth.github.com $GITHUB_TOKEN
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For whatever reason, this configuration setting is not available in the PHP 7.3 build. It should be removed anyway, however, since the invalid token was causing Composer to choke every time it tried to check out a package, stalling the build for longer than necessary.

Not sure what this was doing here in the first place, considering one does not need a token to download public packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be the case that Composer would hit GitHub API rate limits when running under Travis CI because of the fact that GitHub counted every request coming from every composer install under Travis CI against the same rate limit quota. The workaround was to supply a personal GitHub token.

In 2016 a change was made to GitHub's infrastructure to remove the rate limit, so it's no longer necessary: composer/composer#4884 (comment)

I think you can probably get rid of the secure environment variable in .travis.yml now too (it contains 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:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": ">=5.3"
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^4"
Expand All @@ -27,7 +27,7 @@
},
"config": {
"platform": {
"php": "5.3.99"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to update this instead of deleting it. The new value should be 7.1.99.

Having it here ensures that even if I run composer update under PHP 7.3, the lock file will only ever store dependencies that are at least compatible with PHP 7.1, which is important for running the 7.1 tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libraries shouldn't have a lock file to begin with. I didn't remove the lock file because I'm trying to keep this PR as focused as possible, but if you insist, I will put this back in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate it. I'm aware of the arguments against committing lock files, but it's not something I want to change in this PR, if at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it's done.

"php": "7.1.99"
}
}
}
6 changes: 4 additions & 2 deletions src/AbstractEnumeration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
}
17 changes: 17 additions & 0 deletions test/src/MixedAccessibilityEnumeration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use Eloquent\Enumeration\AbstractEnumeration;

/**
* An enumeration whose members have different accessibility levels.
*
* @method static IMPLICIT_PUBLIC()
* @method static EXPLICIT_PUBLIC()
*/
final class MixedAccessibilityEnumeration extends AbstractEnumeration
{
const IMPLICIT_PUBLIC = 'IMPLICIT_PUBLIC';
public const EXPLICIT_PUBLIC = 'EXPLICIT_PUBLIC';
protected const PROTECTED = 'PROTECTED';
private const PRIVATE = 'PRIVATE';
}
12 changes: 12 additions & 0 deletions test/suite/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,16 @@ public function testPlanetExampleScriptOutput()

$this->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);
}
}