diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c646d9..640398e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,36 +6,36 @@ on: - cron: "0 0 * * *" jobs: - php82: - name: PHP 8.2 + php83: + name: PHP 8.3 runs-on: ubuntu-24.04 steps: - name: checkout uses: actions/checkout@v4 - name: composer test - uses: docker://ghcr.io/chubbyphp/ci-php82:latest + uses: docker://ghcr.io/chubbyphp/ci-php83:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - php83: - name: PHP 8.3 + php84: + name: PHP 8.4 runs-on: ubuntu-24.04 steps: - name: checkout uses: actions/checkout@v4 - name: composer test - uses: docker://ghcr.io/chubbyphp/ci-php83:latest + uses: docker://ghcr.io/chubbyphp/ci-php84:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - php84: - name: PHP 8.4 + php85: + name: PHP 8.5 runs-on: ubuntu-24.04 steps: - name: checkout uses: actions/checkout@v4 - name: composer test - uses: docker://ghcr.io/chubbyphp/ci-php84:latest + uses: docker://ghcr.io/chubbyphp/ci-php85:latest env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 19ba81e..85172b8 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -12,10 +12,8 @@ /** @var array $config */ $config = require __DIR__ . '/vendor/chubbyphp/chubbyphp-dev-helper/phpcs.php'; -// drop onces code is >= 8.0 -unset($config['rules']['phpdoc_to_return_type']); - return (new PhpCsFixer\Config) + ->setUnsupportedPhpVersionAllowed(true) ->setIndent($config['indent']) ->setLineEnding($config['lineEnding']) ->setRules($config['rules']) diff --git a/composer.json b/composer.json index 25ca245..cdd8f74 100644 --- a/composer.json +++ b/composer.json @@ -14,17 +14,17 @@ } ], "require": { - "php": "^8.2", + "php": "^8.3", "psr/container": "^2.0.2" }, "require-dev": { "chubbyphp/chubbyphp-dev-helper": "dev-master", - "chubbyphp/chubbyphp-mock": "^2.0", - "infection/infection": "^0.29.13", - "php-coveralls/php-coveralls": "^2.7.0", + "chubbyphp/chubbyphp-mock": "^2.0.1", + "infection/infection": "^0.31.9", + "php-coveralls/php-coveralls": "^2.9", "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan": "^2.1.6", - "phpunit/phpunit": "^11.5.10" + "phpstan/phpstan": "^2.1.32", + "phpunit/phpunit": "^12.4.5" }, "autoload": { "psr-4": { "Chubbyphp\\Container\\": "src/" } @@ -45,7 +45,7 @@ } }, "scripts": { - "fix:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache", + "fix:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --cache-file=build/phpcs.cache", "test": [ "@test:lint", "@test:unit", @@ -54,7 +54,7 @@ "@test:static-analysis", "@test:cs" ], - "test:cs": "mkdir -p build && PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache", + "test:cs": "mkdir -p build && vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --cache-file=build/phpcs.cache", "test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=100 --verbose --coverage=build/phpunit", "test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-directory=build/phpunit", "test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log", diff --git a/src/Container.php b/src/Container.php index 1333823..e58237a 100644 --- a/src/Container.php +++ b/src/Container.php @@ -89,10 +89,7 @@ public function prototypeFactory(string $id, callable $factory): ContainerInterf return $this; } - /** - * @return mixed - */ - public function get(string $id) + public function get(string $id): mixed { if (isset($this->prototypeFactories[$id])) { return $this->createFromPrototypeFactory($id); @@ -106,10 +103,7 @@ public function has(string $id): bool return isset($this->factories[$id]) || isset($this->prototypeFactories[$id]); } - /** - * @return mixed - */ - private function createFromFactory(string $id) + private function createFromFactory(string $id): mixed { if (!isset($this->factories[$id])) { throw NotFoundException::create($id); @@ -122,10 +116,7 @@ private function createFromFactory(string $id) } } - /** - * @return mixed - */ - private function createFromPrototypeFactory(string $id) + private function createFromPrototypeFactory(string $id): mixed { try { return ($this->prototypeFactories[$id])($this); diff --git a/src/Exceptions/ExistsException.php b/src/Exceptions/ExistsException.php index dda849b..c402c04 100644 --- a/src/Exceptions/ExistsException.php +++ b/src/Exceptions/ExistsException.php @@ -8,8 +8,9 @@ final class ExistsException extends \LogicException implements ContainerExceptionInterface { - public const TYPE_FACTORY = 'factory'; - public const TYPE_PROTOTYPE_FACTORY = 'prototype factory'; + public const string TYPE_FACTORY = 'factory'; + + public const string TYPE_PROTOTYPE_FACTORY = 'prototype factory'; private function __construct(string $message, int $code, ?\Throwable $previous = null) { diff --git a/src/Factory.php b/src/Factory.php index 400ea61..3d1fe88 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -24,10 +24,7 @@ public function __construct(callable $previousFactory, callable $factory) $this->factory = $factory; } - /** - * @return mixed - */ - public function __invoke(ContainerInterface $container) + public function __invoke(ContainerInterface $container): mixed { return ($this->factory)($container, $this->previousFactory); } diff --git a/src/MinimalContainer.php b/src/MinimalContainer.php index 32f0370..eedbf51 100644 --- a/src/MinimalContainer.php +++ b/src/MinimalContainer.php @@ -52,10 +52,7 @@ public function factory(string $id, callable $factory): ContainerInterface return $this; } - /** - * @return mixed - */ - public function get(string $id) + public function get(string $id): mixed { return $this->services[$id] ?? $this->services[$id] = $this->createFromFactory($id); } @@ -65,10 +62,7 @@ public function has(string $id): bool return isset($this->factories[$id]); } - /** - * @return mixed - */ - private function createFromFactory(string $id) + private function createFromFactory(string $id): mixed { if (!isset($this->factories[$id])) { throw NotFoundException::create($id); diff --git a/src/Parameter.php b/src/Parameter.php index 78e4c37..43ca44c 100644 --- a/src/Parameter.php +++ b/src/Parameter.php @@ -11,10 +11,7 @@ final class Parameter */ public function __construct(private $parameter) {} - /** - * @return mixed - */ - public function __invoke() + public function __invoke(): mixed { return $this->parameter; } diff --git a/tests/Unit/ContainerTest.php b/tests/Unit/ContainerTest.php index 2463bf1..ec1c34e 100644 --- a/tests/Unit/ContainerTest.php +++ b/tests/Unit/ContainerTest.php @@ -8,14 +8,14 @@ use Chubbyphp\Container\Exceptions\ContainerException; use Chubbyphp\Container\Exceptions\ExistsException; use Chubbyphp\Container\Exceptions\NotFoundException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; /** - * @covers \Chubbyphp\Container\Container - * * @internal */ +#[CoversClass(Container::class)] final class ContainerTest extends TestCase { /** @@ -120,7 +120,7 @@ public function testFactoryReplace(): void { $container = new Container(); - $container->factory('id', static function (): void { + $container->factory('id', static function (): never { throw new \Exception('should not be called!'); }); @@ -249,7 +249,7 @@ public function testPrototypeFactoryReplace(): void { $container = new Container(); - $container->prototypeFactory('id', static function (): void { + $container->prototypeFactory('id', static function (): never { throw new \Exception('should not be called!'); }); diff --git a/tests/Unit/Exceptions/ContainerExceptionTest.php b/tests/Unit/Exceptions/ContainerExceptionTest.php index b51dfbc..d0bb756 100644 --- a/tests/Unit/Exceptions/ContainerExceptionTest.php +++ b/tests/Unit/Exceptions/ContainerExceptionTest.php @@ -5,13 +5,13 @@ namespace Chubbyphp\Tests\Container\Unit\Exceptions; use Chubbyphp\Container\Exceptions\ContainerException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** - * @covers \Chubbyphp\Container\Exceptions\ContainerException - * * @internal */ +#[CoversClass(ContainerException::class)] final class ContainerExceptionTest extends TestCase { public function testConstruct(): void diff --git a/tests/Unit/Exceptions/ExistsExceptionTest.php b/tests/Unit/Exceptions/ExistsExceptionTest.php index 2742f76..fe08728 100644 --- a/tests/Unit/Exceptions/ExistsExceptionTest.php +++ b/tests/Unit/Exceptions/ExistsExceptionTest.php @@ -5,13 +5,14 @@ namespace Chubbyphp\Tests\Container\Unit\Exceptions; use Chubbyphp\Container\Exceptions\ExistsException; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; /** - * @covers \Chubbyphp\Container\Exceptions\ExistsException - * * @internal */ +#[CoversClass(ExistsException::class)] final class ExistsExceptionTest extends TestCase { public function testConstruct(): void @@ -22,9 +23,7 @@ public function testConstruct(): void new ExistsException('test', 0); } - /** - * @dataProvider provideCreateCases - */ + #[DataProvider('provideCreateCases')] public function testCreate(string $type): void { $exception = ExistsException::create('id', $type); diff --git a/tests/Unit/Exceptions/NotFoundExceptionTest.php b/tests/Unit/Exceptions/NotFoundExceptionTest.php index 2b007e5..a4df076 100644 --- a/tests/Unit/Exceptions/NotFoundExceptionTest.php +++ b/tests/Unit/Exceptions/NotFoundExceptionTest.php @@ -5,13 +5,13 @@ namespace Chubbyphp\Tests\Container\Unit\Exceptions; use Chubbyphp\Container\Exceptions\NotFoundException; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** - * @covers \Chubbyphp\Container\Exceptions\NotFoundException - * * @internal */ +#[CoversClass(NotFoundException::class)] final class NotFoundExceptionTest extends TestCase { public function testConstruct(): void diff --git a/tests/Unit/FactoryTest.php b/tests/Unit/FactoryTest.php index c262a5e..ce90a9e 100644 --- a/tests/Unit/FactoryTest.php +++ b/tests/Unit/FactoryTest.php @@ -7,14 +7,14 @@ use Chubbyphp\Container\Factory; use Chubbyphp\Mock\MockMethod\WithReturn; use Chubbyphp\Mock\MockObjectBuilder; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; /** - * @covers \Chubbyphp\Container\Factory - * * @internal */ +#[CoversClass(Factory::class)] final class FactoryTest extends TestCase { public function testInvoke(): void diff --git a/tests/Unit/MinimalContainerTest.php b/tests/Unit/MinimalContainerTest.php index 6734b5e..017691b 100644 --- a/tests/Unit/MinimalContainerTest.php +++ b/tests/Unit/MinimalContainerTest.php @@ -7,14 +7,14 @@ use Chubbyphp\Container\Exceptions\ContainerException; use Chubbyphp\Container\Exceptions\NotFoundException; use Chubbyphp\Container\MinimalContainer; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; /** - * @covers \Chubbyphp\Container\MinimalContainer - * * @internal */ +#[CoversClass(MinimalContainer::class)] final class MinimalContainerTest extends TestCase { /** @@ -104,7 +104,7 @@ public function testFactoryReplace(): void { $container = new MinimalContainer(); - $container->factory('id', static function (): void { + $container->factory('id', static function (): never { throw new \Exception('should not be called!'); }); diff --git a/tests/Unit/ParameterTest.php b/tests/Unit/ParameterTest.php index bb57ee8..c33a628 100644 --- a/tests/Unit/ParameterTest.php +++ b/tests/Unit/ParameterTest.php @@ -5,18 +5,17 @@ namespace Chubbyphp\Tests\Container\Unit; use Chubbyphp\Container\Parameter; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; /** - * @covers \Chubbyphp\Container\Parameter - * * @internal */ +#[CoversClass(Parameter::class)] final class ParameterTest extends TestCase { - /** - * @dataProvider provideInvokeCases - */ + #[DataProvider('provideInvokeCases')] public function testInvoke(mixed $data): void { $parameter = new Parameter($data);