Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #257

Merged
merged 5 commits into from
Jun 22, 2024
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
5 changes: 0 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"url": "https://github.com/sponsors/yiisoft"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.1",
"ext-mbstring": "*",
Expand Down Expand Up @@ -80,9 +78,6 @@
}
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
},
Comment on lines -83 to -85

Choose a reason for hiding this comment

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

this means somebody installing ^3.0@dev not longer composer can resolve itself. I my personal recommendation would be rename master to 3.0 or 3.x that avoids branch aliases and composer directly know what version a branch suppose to be without you need to handle or update branch aliases.

Copy link
Member

Choose a reason for hiding this comment

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

It was about the first time package splitting. Yii2 -> Yii3
Now just use dev-master if you want to get master upstream.
But I suggest to use tags. Now the package is unstable and there's one way to install it is to use dev-master branch.

Copy link

@alexander-schranz alexander-schranz Jul 2, 2024

Choose a reason for hiding this comment

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

Aware of that, but still a ^3.0@dev would atleast make sure semver is followed. Renaming master -> 3.x or 3.0 would tell composer automatically what future version is and allow projects do ^3.0@dev. Also if you tag in future the 3.0.0 will a branch named 3.0 or 3.x will composer help to install that branch when somebody allow stability dev. With a branch named master without a branch alias composer can not detect the version. Its also one of the cases why example Symfony and we @sulu use minor version names as branches for all our packages as that helps composer with version detection for dev branches.

"config-plugin-options": {
"source-directory": "config"
},
Expand Down
6 changes: 3 additions & 3 deletions config/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
],
'yiisoft/yii-console' => [
'commands' => [
DebugResetCommand::COMMAND_NAME => DebugResetCommand::class,
DebugContainerCommand::COMMAND_NAME => DebugContainerCommand::class,
DebugEventsCommand::COMMAND_NAME => DebugEventsCommand::class,
'debug:reset' => DebugResetCommand::class,
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave it as it is

Copy link
Member

Choose a reason for hiding this comment

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

What is better, strings or constant? And why?
We should use one way in all packages.

Copy link
Member Author

Choose a reason for hiding this comment

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

@xepozz command name is useless with attributes and without attributes Symfony console raises deprecation warning.

Copy link
Member

Choose a reason for hiding this comment

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

I like constants because they already exist in console command classes and it's easy to reference to the names rather than writing the name again and keep them consistent

'debug:container' => DebugContainerCommand::class,
'debug:events' => DebugEventsCommand::class,
],
],
];
5 changes: 3 additions & 2 deletions src/Collector/Console/CommandCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ final class CommandCollector implements SummaryCollectorInterface
private const UNDEFINED_EXIT_CODE = -1;
private array $commands = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/Console/ConsoleAppInfoCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
private float $requestProcessingTimeStarted = 0;
private float $requestProcessingTimeStopped = 0;

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand All @@ -32,12 +33,12 @@
return [];
}
return [
'applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted,

Check warning on line 36 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped + $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; } public function collect(object $event) : void {
'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted,

Check warning on line 37 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted + $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; } public function collect(object $event) : void {
'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped,

Check warning on line 38 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped + $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; } public function collect(object $event) : void {
'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted,

Check warning on line 39 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped + $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; } public function collect(object $event) : void {
'memoryPeakUsage' => memory_get_peak_usage(),

Check warning on line 40 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ArrayItem": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' > memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; } public function collect(object $event) : void {
'memoryUsage' => memory_get_usage(),

Check warning on line 41 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ArrayItem": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' => memory_get_usage()]; + return ['applicationProcessingTime' => $this->applicationProcessingTimeStopped - $this->applicationProcessingTimeStarted, 'preloadTime' => $this->applicationProcessingTimeStarted - $this->requestProcessingTimeStarted, 'applicationEmit' => $this->applicationProcessingTimeStopped - $this->requestProcessingTimeStopped, 'requestProcessingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted, 'memoryPeakUsage' => memory_get_peak_usage(), 'memoryUsage' > memory_get_usage()]; } public function collect(object $event) : void {
];
}

Expand All @@ -64,7 +65,7 @@
$this->applicationProcessingTimeStopped = microtime(true);
}

$this->timelineCollector->collect($this, spl_object_id($event));

Check warning on line 68 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } elseif ($event instanceof ApplicationShutdown) { $this->applicationProcessingTimeStopped = microtime(true); } - $this->timelineCollector->collect($this, spl_object_id($event)); + } public function getSummary() : array {
}

public function getSummary(): array
Expand All @@ -79,7 +80,7 @@
],
'request' => [
'startTime' => $this->requestProcessingTimeStarted,
'processingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted,

Check warning on line 83 in src/Collector/Console/ConsoleAppInfoCollector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "Minus": --- Original +++ New @@ @@ if (!$this->isActive()) { return []; } - return ['console' => ['php' => ['version' => PHP_VERSION], 'request' => ['startTime' => $this->requestProcessingTimeStarted, 'processingTime' => $this->requestProcessingTimeStopped - $this->requestProcessingTimeStarted], 'memory' => ['peakUsage' => memory_get_peak_usage()]]]; + return ['console' => ['php' => ['version' => PHP_VERSION], 'request' => ['startTime' => $this->requestProcessingTimeStarted, 'processingTime' => $this->requestProcessingTimeStopped + $this->requestProcessingTimeStarted], 'memory' => ['peakUsage' => memory_get_peak_usage()]]]; } private function reset() : void {
],
'memory' => [
'peakUsage' => memory_get_peak_usage(),
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/EventCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ final class EventCollector implements SummaryCollectorInterface

private array $events = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
4 changes: 2 additions & 2 deletions src/Collector/EventDispatcherInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
final class EventDispatcherInterfaceProxy implements EventDispatcherInterface
{
public function __construct(
private EventDispatcherInterface $dispatcher,
private EventCollector $collector
private readonly EventDispatcherInterface $dispatcher,
private readonly EventCollector $collector
) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/Collector/ExceptionCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ final class ExceptionCollector implements SummaryCollectorInterface

private ?Throwable $exception = null;

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/HttpClientCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ final class HttpClientCollector implements SummaryCollectorInterface
*/
private array $requests = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function collect(RequestInterface $request, float $startTime, string $line, string $uniqueId): void
Expand Down
6 changes: 4 additions & 2 deletions src/Collector/HttpClientInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

final class HttpClientInterfaceProxy implements ClientInterface
{
public function __construct(private ClientInterface $decorated, private HttpClientCollector $collector)
{
public function __construct(
private readonly ClientInterface $decorated,
private readonly HttpClientCollector $collector
) {
}

public function sendRequest(RequestInterface $request): ResponseInterface
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/LogCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class LogCollector implements SummaryCollectorInterface

private array $messages = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
6 changes: 4 additions & 2 deletions src/Collector/LoggerInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

final class LoggerInterfaceProxy implements LoggerInterface
{
public function __construct(private LoggerInterface $logger, private LogCollector $collector)
{
public function __construct(
private readonly LoggerInterface $logger,
private readonly LogCollector $collector
) {
}

public function emergency(string|Stringable $message, array $context = []): void
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/ServiceCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ final class ServiceCollector implements SummaryCollectorInterface

private array $items = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Collector/ServiceMethodProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ServiceMethodProxy extends ServiceProxy
public function __construct(
string $service,
object $instance,
private array $methods,
private readonly array $methods,
ContainerProxyConfig $config
) {
parent::__construct($service, $instance, $config);
Expand Down
2 changes: 1 addition & 1 deletion src/Collector/ServiceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ServiceProxy extends ObjectProxy
use ProxyLogTrait;

public function __construct(
private string $service,
private readonly string $service,
object $instance,
ContainerProxyConfig $config,
) {
Expand Down
4 changes: 2 additions & 2 deletions src/Collector/Stream/FilesystemStreamCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function __construct(
* - '/' . preg_quote('yii-debug/src/Dumper', '/') . '/'
* - '/ClosureExporter/'
*/
private array $ignoredPathPatterns = [],
private array $ignoredClasses = [],
private readonly array $ignoredPathPatterns = [],
private readonly array $ignoredClasses = [],
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Collector/Stream/HttpStreamCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ final class HttpStreamCollector implements SummaryCollectorInterface
use CollectorTrait;

public function __construct(
private array $ignoredPathPatterns = [],
private array $ignoredClasses = [],
private array $ignoredUrls = []
private readonly array $ignoredPathPatterns = [],
private readonly array $ignoredClasses = [],
private readonly array $ignoredUrls = []
) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/Collector/VarDumperCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ final class VarDumperCollector implements SummaryCollectorInterface

private array $vars = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function collect(mixed $variable, string $line): void
Expand Down
4 changes: 2 additions & 2 deletions src/Collector/VarDumperHandlerInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
final class VarDumperHandlerInterfaceProxy implements HandlerInterface
{
public function __construct(
private HandlerInterface $decorated,
private VarDumperCollector $collector,
private readonly HandlerInterface $decorated,
private readonly VarDumperCollector $collector,
) {
}

Expand Down
5 changes: 3 additions & 2 deletions src/Collector/Web/MiddlewareCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ final class MiddlewareCollector implements SummaryCollectorInterface
private array $beforeStack = [];
private array $afterStack = [];

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/Web/RequestCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ final class RequestCollector implements SummaryCollectorInterface
private ?ServerRequestInterface $request = null;
private ?ResponseInterface $response = null;

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
5 changes: 3 additions & 2 deletions src/Collector/Web/WebAppInfoCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ final class WebAppInfoCollector implements SummaryCollectorInterface
private float $requestProcessingTimeStarted = 0;
private float $requestProcessingTimeStopped = 0;

public function __construct(private TimelineCollector $timelineCollector)
{
public function __construct(
private readonly TimelineCollector $timelineCollector
) {
}

public function getCollected(): array
Expand Down
18 changes: 10 additions & 8 deletions src/Command/DebugContainerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Yiisoft\Yii\Debug\Command;

use Psr\Container\ContainerInterface;
use ReflectionClass;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -21,22 +23,22 @@
use Yiisoft\Yii\Console\ExitCode;
use Yiisoft\Yii\Debug\Debugger;

#[AsCommand(
name: 'debug:container',
description: 'Show information about container',
)]
final class DebugContainerCommand extends Command
{
public const COMMAND_NAME = 'debug:container';
protected static $defaultName = self::COMMAND_NAME;

public function __construct(
private ContainerInterface $container,
private Debugger $debugger,
private readonly ContainerInterface $container,
private readonly Debugger $debugger,
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('Show information about container')
->addArgument('id', InputArgument::IS_ARRAY, 'Service ID')
->addOption('groups', null, InputOption::VALUE_NONE, 'Show groups')
->addOption('group', 'g', InputOption::VALUE_REQUIRED, 'Show group');
Expand Down Expand Up @@ -118,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$groups = array_keys($build);
sort($groups);

$io->table(['Groups'], array_map(fn ($group) => [$group], $groups));
$io->table(['Groups'], array_map(static fn ($group) => [$group], $groups));

return ExitCode::OK;
}
Expand Down Expand Up @@ -156,7 +158,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

private function getConfigBuild(mixed $config): array
{
$reflection = new \ReflectionClass($config);
$reflection = new ReflectionClass($config);
$buildReflection = $reflection->getProperty('build');
$buildReflection->setAccessible(true);
return $buildReflection->getValue($config);
Expand Down
15 changes: 8 additions & 7 deletions src/Command/DebugEventsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Container\ContainerInterface;
use ReflectionClass;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -19,22 +20,22 @@
use Yiisoft\Yii\Console\ExitCode;
use Yiisoft\Yii\Debug\Debugger;

#[AsCommand(
name: 'debug:events',
description: 'Show information about events and listeners',
)]
final class DebugEventsCommand extends Command
{
public const COMMAND_NAME = 'debug:events';
protected static $defaultName = self::COMMAND_NAME;

public function __construct(
private ContainerInterface $container,
private Debugger $debugger,
private readonly ContainerInterface $container,
private readonly Debugger $debugger,
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('Show information about events and listeners')
->addArgument('id', InputArgument::IS_ARRAY, 'Service ID')
->addOption('groups', null, InputOption::VALUE_NONE, 'Show groups')
->addOption('group', 'g', InputOption::VALUE_REQUIRED, 'Show group');
Expand All @@ -52,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$groups = array_keys($build);
sort($groups);

$io->table(['Groups'], array_map(fn ($group) => [$group], $groups));
$io->table(['Groups'], array_map(static fn ($group) => [$group], $groups));

return ExitCode::OK;
}
Expand Down
13 changes: 7 additions & 6 deletions src/Command/DebugResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@

namespace Yiisoft\Yii\Debug\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Yiisoft\Yii\Console\ExitCode;
use Yiisoft\Yii\Debug\Debugger;
use Yiisoft\Yii\Debug\Storage\StorageInterface;

#[AsCommand(
name: 'debug:reset',
description: 'Clear debug data',
)]
final class DebugResetCommand extends Command
{
public const COMMAND_NAME = 'debug:reset';
protected static $defaultName = self::COMMAND_NAME;

public function __construct(
private StorageInterface $storage,
private Debugger $debugger,
private readonly StorageInterface $storage,
private readonly Debugger $debugger,
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription('Clear debug data')
->setHelp('This command clears debug storage data');
}

Expand Down
Loading
Loading