diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c8f866..288ed8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,16 +12,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [8.1, 8.2, 8.3 ] + php: [8.1, 8.2, 8.3, 8.4] deps: [highest] - symfony: [6.4.*, 7.0.*] + symfony: [6.4.*, 7.1.*, 7.2.*] include: - php: 8.1 deps: lowest symfony: '*' exclude: - php: 8.1 - symfony: 7.0.* + symfony: 7.1.* + - php: 8.1 + symfony: 7.2.* steps: - uses: zenstruck/.github/actions/php-test-symfony@main with: diff --git a/src/Configuration/DocblockConfiguration.php b/src/Configuration/DocblockConfiguration.php index 0d59b7b..3f14929 100644 --- a/src/Configuration/DocblockConfiguration.php +++ b/src/Configuration/DocblockConfiguration.php @@ -298,6 +298,6 @@ private static function parseOption(string $value): array private static function factory(): DocBlockFactory { - return self::$factory ??= DocBlockFactory::createInstance(); + return self::$factory ??= DocBlockFactory::createInstance(); // @phpstan-ignore-line } } diff --git a/tests/Fixture/Command/BaseServiceSubscriberTraitCommand.php b/tests/Fixture/Command/BaseServiceSubscriberTraitCommand.php new file mode 100644 index 0000000..3656f0e --- /dev/null +++ b/tests/Fixture/Command/BaseServiceSubscriberTraitCommand.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zenstruck\Console\Tests\Fixture\Command; + +use Psr\Log\LoggerInterface; +use Symfony\Component\Routing\RouterInterface; +use Symfony\Contracts\Service\Attribute\SubscribedService; +use Zenstruck\Console\InvokableServiceCommand; +use Zenstruck\Console\IO; + +/** + * @author Kevin Bond + */ +abstract class BaseServiceSubscriberTraitCommand extends InvokableServiceCommand +{ + public function __invoke(IO $io, RouterInterface $router): void + { + $io->comment(\sprintf('IO: %s', \get_debug_type($io))); + $io->comment(\sprintf('RouterInterface: %s', \get_debug_type($router))); + $io->comment(\sprintf('LoggerInterface: %s', \get_debug_type($this->logger()))); + } + + public static function getDefaultName(): string + { + return 'service-subscriber-trait-command'; + } + + abstract protected function logger(): LoggerInterface; +} diff --git a/tests/Fixture/Command/ServiceSubscriberTraitCommand.php b/tests/Fixture/Command/ServiceSubscriberTraitCommand.php index 8c0ba1e..740ce6c 100644 --- a/tests/Fixture/Command/ServiceSubscriberTraitCommand.php +++ b/tests/Fixture/Command/ServiceSubscriberTraitCommand.php @@ -1,45 +1,32 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - namespace Zenstruck\Console\Tests\Fixture\Command; use Psr\Log\LoggerInterface; -use Symfony\Component\Routing\RouterInterface; use Symfony\Contracts\Service\Attribute\SubscribedService; +use Symfony\Contracts\Service\ServiceMethodsSubscriberTrait; use Symfony\Contracts\Service\ServiceSubscriberTrait; -use Zenstruck\Console\InvokableServiceCommand; -use Zenstruck\Console\IO; - -/** - * @author Kevin Bond - */ -final class ServiceSubscriberTraitCommand extends InvokableServiceCommand -{ - use ServiceSubscriberTrait; - public function __invoke(IO $io, RouterInterface $router): void +if (trait_exists(ServiceMethodsSubscriberTrait::class)) { + final class ServiceSubscriberTraitCommand extends BaseServiceSubscriberTraitCommand { - $io->comment(\sprintf('IO: %s', \get_debug_type($io))); - $io->comment(\sprintf('RouterInterface: %s', \get_debug_type($router))); - $io->comment(\sprintf('LoggerInterface: %s', \get_debug_type($this->logger()))); - } + use ServiceMethodsSubscriberTrait; - public static function getDefaultName(): string - { - return 'service-subscriber-trait-command'; + #[SubscribedService] + protected function logger(): LoggerInterface + { + return $this->container->get(__METHOD__); + } } - - #[SubscribedService] - private function logger(): LoggerInterface +} else { + final class ServiceSubscriberTraitCommand extends BaseServiceSubscriberTraitCommand { - return $this->container->get(__METHOD__); + use ServiceSubscriberTrait; + + #[SubscribedService] + protected function logger(): LoggerInterface + { + return $this->container->get(__METHOD__); + } } }