Skip to content

Commit

Permalink
Merge pull request #70 from kbond/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
kbond authored Oct 9, 2024
2 parents d7b8de2 + b60bcf5 commit fb3fbf5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 35 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/DocblockConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
38 changes: 38 additions & 0 deletions tests/Fixture/Command/BaseServiceSubscriberTraitCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/*
* This file is part of the zenstruck/console-extra package.
*
* (c) Kevin Bond <kevinbond@gmail.com>
*
* 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 <kevinbond@gmail.com>
*/
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;
}
49 changes: 18 additions & 31 deletions tests/Fixture/Command/ServiceSubscriberTraitCommand.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
<?php

/*
* This file is part of the zenstruck/console-extra package.
*
* (c) Kevin Bond <kevinbond@gmail.com>
*
* 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 <kevinbond@gmail.com>
*/
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__);
}
}
}

0 comments on commit fb3fbf5

Please sign in to comment.