Skip to content

Commit

Permalink
prepare bugfix release 6.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Apr 7, 2022
1 parent 25caa96 commit 07bb648
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.

## [Unreleased]

## [6.4.0] - 2022-04-06
## [6.4.1] - 2022-04-07

<!-- MARKDOWN-RELEASE:START -->
### Fixed

- `progress_bar` extension : did not work since release 6.0.0
- `logger` extension : did not work since release 6.0.0
<!-- MARKDOWN-RELEASE:END -->

## [6.4.0] - 2022-04-06

### Added

- new `rule:list` command to display Compatibility Analyser rules supported
Expand All @@ -22,7 +30,6 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.
### Fixed

- [#213](https://github.com/llaville/php-compatinfo/issues/213) : Static properties accessed through a variable are not detected
<!-- MARKDOWN-RELEASE:END -->

## [6.3.0] - 2022-03-06

Expand Down Expand Up @@ -169,7 +176,8 @@ Experimental
- drop support for PHP 7.3 has ended 6th December 2021.
- file `config/container.php` replaced by `src/Infrastructure/Framework/Symfony/DependencyInjection/ContainerFactory.php`

[unreleased]: https://github.com/llaville/php-compat-info/compare/6.4.0...HEAD
[unreleased]: https://github.com/llaville/php-compat-info/compare/6.4.1...HEAD
[6.4.1]: https://github.com/llaville/php-compat-info/compare/6.4.0...6.4.1
[6.4.0]: https://github.com/llaville/php-compat-info/compare/6.3.0...6.4.0
[6.3.0]: https://github.com/llaville/php-compat-info/compare/6.2.0...6.3.0
[6.2.0]: https://github.com/llaville/php-compat-info/compare/6.1.2...6.2.0
Expand Down
36 changes: 17 additions & 19 deletions src/Application/Extension/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,14 @@ final class Logger implements
{
private LoggerInterface $logger;

/** @var array<string, string> */
private static array $events;

/**
* Logger extension constructor.
*
* @param LoggerInterface $logger
* @param InputInterface $input
*/
public function __construct(LoggerInterface $logger, InputInterface $input)
public function __construct(LoggerInterface $logger)
{
if ($input->hasOption('debug') && $input->getOption('debug')) {
$this->logger = $logger;
self::$events = [
ConsoleEvents::COMMAND => 'onConsoleCommand',
ConsoleEvents::TERMINATE => 'onConsoleTerminate',
ErrorEvent::class => 'onError',
];
} else {
$this->logger = new NullLogger();
self::$events = [];
}
$this->logger = $logger;
}

/**
Expand All @@ -95,19 +81,31 @@ public function getName(): string

/**
* {@inheritDoc}
* @return array<string, string>
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return self::$events;
return [
ConsoleEvents::COMMAND => 'onConsoleCommand',
ConsoleEvents::TERMINATE => 'onConsoleTerminate',
ErrorEvent::class => 'onError',
];
}

/**
* Initialize logger extension, by `analyser:run --debug` command
*
* @param ConsoleCommandEvent $event
* @return void
*/
public function onConsoleCommand(ConsoleCommandEvent $event): void
{
$input = $event->getInput();
$withDebug = $input->hasOption('debug') && $input->getOption('debug');

if (!$withDebug) {
$this->logger = new NullLogger();
}

$context = ['command' => $event->getCommand()->getName()];
$this->logger->info('Start {command} command.', $context);
}
Expand Down
31 changes: 21 additions & 10 deletions src/Application/Extension/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
use Bartlett\CompatInfo\Application\Event\BeforeFileAnalysisInterface;
use Bartlett\CompatInfo\Presentation\Console\Style;

use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Helper\ProgressBar as SymfonyProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Extension that inject progress display at execution.
Expand All @@ -32,21 +33,31 @@ final class ProgressBar implements
BeforeAnalysisInterface,
AfterAnalysisInterface,
BeforeFileAnalysisInterface,
AfterFileAnalysisInterface
AfterFileAnalysisInterface,
EventSubscriberInterface
{
private ?SymfonyProgressBar $progressBar;
private ?SymfonyProgressBar $progressBar = null;

/**
* ProgressBar extension constructor.
*
* @param InputInterface $input
* @param OutputInterface $output
* {@inheritDoc}
*/
public static function getSubscribedEvents(): array
{
return [
ConsoleEvents::COMMAND => 'initProgress',
];
}

/**
* Initialize progress bar extension, by `analyser:run --progress` command
*/
public function __construct(InputInterface $input, OutputInterface $output)
public function initProgress(ConsoleCommandEvent $event): void
{
$io = new Style($input, $output);
$input = $event->getInput();

if ($input->hasOption('progress') && $input->getOption('progress')) {
$output = $event->getOutput();
$io = new Style($input, $output);
$this->progressBar = $io->createProgressBar();
} else {
$this->progressBar = null;
Expand Down

0 comments on commit 07bb648

Please sign in to comment.