diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a95124..524af2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,12 +34,13 @@ jobs: COMPOSER_CACHE_KEY: 'composer-7.2' with: path: vendor - key: ${{ env.COMPOSER_CACHE_KEY }} + key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }} restore-keys: ${{ env.COMPOSER_CACHE_KEY }} - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + run: | + /opt/spaceonfire/bin/select-composer.sh v2 + composer install --prefer-dist --no-progress - name: Check coding standard run: vendor/bin/ecs check --no-progress-bar --no-interaction @@ -58,12 +59,13 @@ jobs: COMPOSER_CACHE_KEY: 'composer-7.2' with: path: vendor - key: ${{ env.COMPOSER_CACHE_KEY }} + key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }} restore-keys: ${{ env.COMPOSER_CACHE_KEY }} - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + run: | + /opt/spaceonfire/bin/select-composer.sh v2 + composer install --prefer-dist --no-progress - name: PHPStan run: vendor/bin/phpstan analyse --no-progress --no-interaction @@ -76,6 +78,7 @@ jobs: - '7.2' - '7.3' - '7.4' + - '8.0' container: spaceonfire/nginx-php-fpm:latest-${{ matrix.php-version }} steps: - name: Checkout @@ -88,18 +91,19 @@ jobs: COMPOSER_CACHE_KEY: 'composer-${{ matrix.php-version }}' with: path: vendor - key: ${{ env.COMPOSER_CACHE_KEY }} + key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }} restore-keys: ${{ env.COMPOSER_CACHE_KEY }} - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + run: | + /opt/spaceonfire/bin/select-composer.sh v2 + composer install --prefer-dist --no-progress - name: PHPUnit run: | apk update docker-php-ext-enable xdebug - vendor/bin/phpunit --no-interaction + php -d xdebug.mode=coverage vendor/bin/phpunit --no-interaction cat build/coverage.txt - name: PHPUnit Artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md index a98afbe..08408ef 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip - Nothing --> +## [2.4.1] - 2020-02-19 + +### Added + +- Support installation on PHP 8 + ## [2.4.0] - 2020-12-19 ### Added diff --git a/composer.json b/composer.json index 9152a68..235801f 100755 --- a/composer.json +++ b/composer.json @@ -26,15 +26,16 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2|^8.0", "psr/container": "^1.0", "spaceonfire/collection": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^8.5", + "phpunit/phpunit": "^8.5|^9.5", + "phpspec/prophecy-phpunit": "^1.1|^2.0", "phpstan/phpstan": "^0.12", "roave/security-advisories": "dev-master", - "symplify/easy-coding-standard-prefixed": "^8.3" + "symplify/easy-coding-standard-prefixed": "^8.3|^9.1" }, "provide": { "psr/container-implementation": "^1.0" @@ -50,7 +51,7 @@ } }, "scripts": { - "test": "phpunit", + "test": "@php -d xdebug.mode=coverage `which phpunit`", "codestyle": "ecs check --ansi", "lint": "phpstan analyze --memory-limit=512M --ansi" }, diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php new file mode 100644 index 0000000..ece1737 --- /dev/null +++ b/tests/AbstractTestCase.php @@ -0,0 +1,20 @@ +invoke(MyClass::class . '::staticMethod')); - $oldReporting = error_reporting(E_ALL ^ E_DEPRECATED); - self::assertSame('foo', $container->invoke([MyClass::class, 'method'])); - error_reporting($oldReporting); - self::assertSame('foo', $container->invoke([new MyClass(), 'method'])); $invokable = new class { @@ -118,7 +113,10 @@ public function __invoke() }; self::assertSame(42, $container->invoke($invokable)); - self::assertSame(42, $container->invoke('intval', ['var' => '42', 'base' => 10])); + self::assertSame(42, $container->invoke('intval', [ + (PHP_VERSION_ID >= 80000 ? 'value' : 'var') => '42', + 'base' => 10, + ])); } public function testResolveDefinitionWithParentContainer(): void diff --git a/tests/Definition/DefinitionAggregateTest.php b/tests/Definition/DefinitionAggregateTest.php index bc1dd4a..3d8bc9f 100755 --- a/tests/Definition/DefinitionAggregateTest.php +++ b/tests/Definition/DefinitionAggregateTest.php @@ -4,11 +4,11 @@ namespace spaceonfire\Container\Definition; -use PHPUnit\Framework\TestCase; +use spaceonfire\Container\AbstractTestCase; use spaceonfire\Container\ContainerInterface; use spaceonfire\Container\Exception\ContainerException; -class DefinitionAggregateTest extends TestCase +class DefinitionAggregateTest extends AbstractTestCase { public function testConstruct(): void { diff --git a/tests/Definition/DefinitionTest.php b/tests/Definition/DefinitionTest.php index 3151dfd..91cd9db 100755 --- a/tests/Definition/DefinitionTest.php +++ b/tests/Definition/DefinitionTest.php @@ -4,16 +4,17 @@ namespace spaceonfire\Container\Definition; -use PHPUnit\Framework\TestCase; use Prophecy\Argument as ArgumentProphecy; +use spaceonfire\Container\AbstractTestCase; use spaceonfire\Container\Argument\Argument; use spaceonfire\Container\ContainerInterface; use spaceonfire\Container\Exception\ContainerException; use spaceonfire\Container\RawValueHolder; use stdClass; -class DefinitionTest extends TestCase +class DefinitionTest extends AbstractTestCase { + public function testGetters(): void { $foo = new Definition('foo'); diff --git a/tests/Reflection/ReflectionFactoryTest.php b/tests/Reflection/ReflectionFactoryTest.php index 59b3c79..1bd78f2 100755 --- a/tests/Reflection/ReflectionFactoryTest.php +++ b/tests/Reflection/ReflectionFactoryTest.php @@ -4,18 +4,15 @@ namespace spaceonfire\Container\Reflection; -use PHPUnit\Framework\TestCase; +use spaceonfire\Container\AbstractTestCase; use spaceonfire\Container\Argument\ArgumentResolver; use spaceonfire\Container\ContainerInterface; use spaceonfire\Container\Exception\NotFoundException; use spaceonfire\Container\Fixtures\A; use spaceonfire\Container\Fixtures\B; -use spaceonfire\Container\WithContainerMockTrait; -class ReflectionFactoryTest extends TestCase +class ReflectionFactoryTest extends AbstractTestCase { - use WithContainerMockTrait; - /** * @var ReflectionFactory */ diff --git a/tests/Reflection/ReflectionInvokerTest.php b/tests/Reflection/ReflectionInvokerTest.php index 6f7509e..94d28c9 100755 --- a/tests/Reflection/ReflectionInvokerTest.php +++ b/tests/Reflection/ReflectionInvokerTest.php @@ -4,18 +4,15 @@ namespace spaceonfire\Container\Reflection; -use PHPUnit\Framework\TestCase; +use spaceonfire\Container\AbstractTestCase; use spaceonfire\Container\Argument\ArgumentResolver; use spaceonfire\Container\ContainerInterface; use spaceonfire\Container\Fixtures\A; use spaceonfire\Container\Fixtures\B; use spaceonfire\Container\Fixtures\MyClass; -use spaceonfire\Container\WithContainerMockTrait; -class ReflectionInvokerTest extends TestCase +class ReflectionInvokerTest extends AbstractTestCase { - use WithContainerMockTrait; - /** * @var ReflectionInvoker */ @@ -46,16 +43,13 @@ protected function setUp(): void */ public function testInvoker($expect, $callable, $arguments = []): void { - $oldReporting = error_reporting(E_ALL ^ E_DEPRECATED); self::assertSame($expect, ($this->invoker)($callable, $arguments)); - error_reporting($oldReporting); } public function dataProvider(): array { return [ ['bar', MyClass::class . '::staticMethod'], - ['foo', [MyClass::class, 'method']], ['foo', [new MyClass(), 'method']], [42, new class { public function __invoke() @@ -63,7 +57,10 @@ public function __invoke() return 42; } }], - [42, 'intval', ['var' => '42', 'base' => 10]], + [42, 'intval', [ + (PHP_VERSION_ID >= 80000 ? 'value' : 'var') => '42', + 'base' => 10, + ]], ]; } } diff --git a/tests/ReflectionContainerTest.php b/tests/ReflectionContainerTest.php index 1f15605..90b101c 100755 --- a/tests/ReflectionContainerTest.php +++ b/tests/ReflectionContainerTest.php @@ -5,7 +5,6 @@ namespace spaceonfire\Container; use BadMethodCallException; -use PHPUnit\Framework\TestCase; use spaceonfire\Container\Exception\ContainerException; use spaceonfire\Container\Exception\NotFoundException; use spaceonfire\Container\Fixtures\A; @@ -14,7 +13,7 @@ use spaceonfire\Container\Fixtures\B; use spaceonfire\Container\Fixtures\MyClass; -class ReflectionContainerTest extends TestCase +class ReflectionContainerTest extends AbstractTestCase { public function testHas(): void { @@ -44,10 +43,6 @@ public function testInvoke(): void self::assertSame('bar', $container->invoke(MyClass::class . '::staticMethod')); - $oldReporting = error_reporting(E_ALL ^ E_DEPRECATED); - self::assertSame('foo', $container->invoke([MyClass::class, 'method'])); - error_reporting($oldReporting); - self::assertSame('foo', $container->invoke([new MyClass(), 'method'])); $invokable = new class { @@ -58,7 +53,10 @@ public function __invoke() }; self::assertSame(42, $container->invoke($invokable)); - self::assertSame(42, $container->invoke('intval', ['var' => '42', 'base' => 10])); + self::assertSame(42, $container->invoke('intval', [ + (PHP_VERSION_ID >= 80000 ? 'value' : 'var') => '42', + 'base' => 10, + ])); } public function testAdd(): void diff --git a/tests/ServiceProvider/ServiceProviderAggregateTest.php b/tests/ServiceProvider/ServiceProviderAggregateTest.php index dde11fc..471001e 100755 --- a/tests/ServiceProvider/ServiceProviderAggregateTest.php +++ b/tests/ServiceProvider/ServiceProviderAggregateTest.php @@ -4,13 +4,13 @@ namespace spaceonfire\Container\ServiceProvider; -use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use spaceonfire\Container\AbstractTestCase; use spaceonfire\Container\ContainerInterface; use spaceonfire\Container\Definition\Definition; use spaceonfire\Container\Exception\ContainerException; -class ServiceProviderAggregateTest extends TestCase +class ServiceProviderAggregateTest extends AbstractTestCase { private function createAggregate(?ContainerInterface $container = null): ServiceProviderAggregate {