Skip to content

Commit

Permalink
clean-up code and phpDoc blocks of all extension
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Jan 8, 2024
1 parent c5f553a commit 9ea1c7c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 47 deletions.
2 changes: 0 additions & 2 deletions src/Application/Extension/ExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface ExtensionInterface
{
/**
* Returns name of extension (must be unique)
*
* @return string
*/
public function getName(): string;
}
6 changes: 0 additions & 6 deletions src/Application/Extension/ExtensionLoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@ interface ExtensionLoaderInterface
*/
public function getNames(): array;

/**
* @param string $name
* @return bool
*/
public function has(string $name): bool;

/**
* @param string $name
* @return ExtensionInterface
* @throws LogicException
*/
public function get(string $name): ExtensionInterface;
Expand Down
7 changes: 2 additions & 5 deletions src/Application/Extension/FactoryExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,20 @@ public function __construct(iterable $extensions)
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function getNames(): array
{
return array_keys($this->factories);
}

/**
* {@inheritDoc}
*/
public function has(string $name): bool
{
return isset($this->factories[$name]);
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function get(string $name): ExtensionInterface
{
Expand Down
33 changes: 11 additions & 22 deletions src/Application/Extension/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use function get_class;
Expand Down Expand Up @@ -63,24 +62,22 @@ final class Logger implements

/**
* Logger extension constructor.
*
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function getName(): string
{
return 'logger';
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public static function getSubscribedEvents(): array
{
Expand All @@ -93,9 +90,6 @@ public static function getSubscribedEvents(): array

/**
* Initialize logger extension, by `analyser:run --debug` command
*
* @param ConsoleCommandEvent $event
* @return void
*/
public function onConsoleCommand(ConsoleCommandEvent $event): void
{
Expand All @@ -110,26 +104,22 @@ public function onConsoleCommand(ConsoleCommandEvent $event): void
$this->logger->info('Start {command} command.', $context);
}

/**
* @param ConsoleTerminateEvent $event
* @return void
*/
public function onConsoleTerminate(ConsoleTerminateEvent $event): void
{
$context = ['command' => $event->getCommand()->getName()];
$this->logger->info('Terminate {command} command.', $context);
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeAnalyzeFile(BeforeFileAnalysisEvent $event): void
{
$this->logger->notice('Start analysis of file "{file}"', $event->getArguments());
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterAnalyzeFile(AfterFileAnalysisEvent $event): void
{
Expand All @@ -138,15 +128,14 @@ public function afterAnalyzeFile(AfterFileAnalysisEvent $event): void

/**
* @param ErrorEvent<string, string> $event
* @return void
*/
public function onError(ErrorEvent $event): void
{
$this->logger->error('Analysis of file "{file}" failed: {error}', $event->getArguments());
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterAnalysis(AfterAnalysisEvent $event): void
{
Expand All @@ -157,7 +146,7 @@ public function afterAnalysis(AfterAnalysisEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeEnterNode(BeforeProcessNodeEvent $event): void
{
Expand All @@ -174,7 +163,7 @@ public function beforeEnterNode(BeforeProcessNodeEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterLeaveNode(AfterProcessNodeEvent $event): void
{
Expand All @@ -191,31 +180,31 @@ public function afterLeaveNode(AfterProcessNodeEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeSetupSniff(BeforeInitializeSniffEvent $event): void
{
$this->logger->debug(sprintf('setUpBeforeSniff %s', get_class($event->getSubject())));
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterTearDownSniff(AfterInitializeSniffEvent $event): void
{
$this->logger->debug(sprintf('tearDownAfterSniff %s', get_class($event->getSubject())));
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeEnterSniff(BeforeProcessSniffEvent $event): void
{
$this->logger->debug(sprintf('enterSniff %s', get_class($event->getSubject())));
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterLeaveSniff(AfterProcessSniffEvent $event): void
{
Expand Down
20 changes: 8 additions & 12 deletions src/Application/Extension/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ProgressBar implements
private ?SymfonyProgressBar $progressBar = null;

/**
* {@inheritDoc}
* @inheritDoc
*/
public static function getSubscribedEvents(): array
{
Expand All @@ -65,25 +65,23 @@ public function initProgress(ConsoleCommandEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function getName(): string
{
return 'progress_bar';
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeAnalysis(BeforeAnalysisEvent $event): void
{
if ($this->progressBar) {
$this->progressBar->start(count($event->getArgument('queue')));
}
$this->progressBar?->start(count($event->getArgument('queue')));
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterAnalysis(AfterAnalysisEvent $event): void
{
Expand All @@ -94,7 +92,7 @@ public function afterAnalysis(AfterAnalysisEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function beforeAnalyzeFile(BeforeFileAnalysisEvent $event): void
{
Expand All @@ -105,12 +103,10 @@ public function beforeAnalyzeFile(BeforeFileAnalysisEvent $event): void
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function afterAnalyzeFile(AfterFileAnalysisEvent $event): void
{
if ($this->progressBar) {
$this->progressBar->advance();
}
$this->progressBar?->advance();
}
}

0 comments on commit 9ea1c7c

Please sign in to comment.