Skip to content
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
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"Rector\\Celebrity\\": "rules/celebrity/src",
"Rector\\ChangesReporting\\": "packages/changes-reporting/src",
"Rector\\CodeQuality\\": "rules/code-quality/src",
"Rector\\Extension\\": "packages/extension/src",
"Rector\\Reporting\\": "packages/reporting/src",
"Rector\\CodingStyle\\": "rules/coding-style/src",
"Rector\\ConsoleDiffer\\": "packages/console-differ/src",
Expand Down
2 changes: 2 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ services:
Symplify\PackageBuilder\Strings\StringFormatConverter: null

OndraM\CiDetector\CiDetector: null

Symfony\Component\EventDispatcher\EventDispatcherInterface: '@Rector\Core\EventDispatcher\AutowiredEventDispatcher'
7 changes: 0 additions & 7 deletions packages/extension/config/config.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions packages/extension/src/Contract/FinishingExtensionInterface.php

This file was deleted.

10 changes: 0 additions & 10 deletions packages/extension/src/Contract/ReportingExtensionInterface.php

This file was deleted.

33 changes: 0 additions & 33 deletions packages/extension/src/Runner/ReportingExtensionRunner.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

declare(strict_types=1);

namespace Rector\Reporting\Extension;
namespace Rector\Reporting\EventSibscriber;

use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
use Rector\Core\Configuration\Configuration;
use Rector\Extension\Contract\ReportingExtensionInterface;
use Rector\Core\EventDispatcher\Event\AfterReportEvent;
use Rector\Reporting\DataCollector\ReportCollector;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class GenericReportMessageReportingExtension implements ReportingExtensionInterface
final class PrintReportCollectorEventSubscriber implements EventSubscriberInterface
{
/**
* @var ReportCollector
Expand All @@ -37,7 +38,15 @@ public function __construct(
$this->symfonyStyle = $symfonyStyle;
}

public function run(): void
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [AfterReportEvent::class => 'printReportCollector'];
}

public function printReportCollector(): void
{
if ($this->shouldSkip()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

declare(strict_types=1);

namespace Rector\Doctrine\Extension;
namespace Rector\Doctrine\EventSubscriber;

use Nette\Utils\FileSystem;
use Nette\Utils\Json;
use Rector\Core\EventDispatcher\Event\AfterProcessEvent;
use Rector\Doctrine\Collector\UuidMigrationDataCollector;
use Rector\Extension\Contract\FinishingExtensionInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class ReportEntitiesWithAddedPropertiesFinishExtension implements FinishingExtensionInterface
final class ReportEntitiesWithAddedPropertiesEventSubscriber implements EventSubscriberInterface
{
/**
* @var UuidMigrationDataCollector
Expand All @@ -30,7 +31,7 @@ public function __construct(
$this->symfonyStyle = $symfonyStyle;
}

public function run(): void
public function reportEntities(): void
{
$this->generatePropertiesJsonWithFileName(
'uuid-migration-new-column-properties.json',
Expand All @@ -43,6 +44,11 @@ public function run(): void
);
}

public static function getSubscribedEvents(): array
{
return [AfterProcessEvent::class => 'reportEntities'];
}

/**
* @param mixed[] $data
*/
Expand Down
13 changes: 7 additions & 6 deletions src/Application/RectorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor;
use Rector\Core\Configuration\Configuration;
use Rector\Core\Extension\FinishingExtensionRunner;
use Rector\Core\EventDispatcher\Event\AfterProcessEvent;
use Rector\FileSystemRector\FileSystemFileProcessor;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
use Symplify\SmartFileSystem\SmartFileInfo;
use Throwable;
Expand Down Expand Up @@ -75,9 +76,9 @@ final class RectorApplication
private $nodeScopeResolver;

/**
* @var FinishingExtensionRunner
* @var EventDispatcherInterface
*/
private $finishingExtensionRunner;
private $eventDispatcher;

public function __construct(
SymfonyStyle $symfonyStyle,
Expand All @@ -88,7 +89,7 @@ public function __construct(
RemovedAndAddedFilesCollector $removedAndAddedFilesCollector,
RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor,
NodeScopeResolver $nodeScopeResolver,
FinishingExtensionRunner $finishingExtensionRunner
EventDispatcherInterface $eventDispatcher
) {
$this->symfonyStyle = $symfonyStyle;
$this->fileSystemFileProcessor = $fileSystemFileProcessor;
Expand All @@ -98,7 +99,7 @@ public function __construct(
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
$this->removedAndAddedFilesProcessor = $removedAndAddedFilesProcessor;
$this->nodeScopeResolver = $nodeScopeResolver;
$this->finishingExtensionRunner = $finishingExtensionRunner;
$this->eventDispatcher = $eventDispatcher;
}

/**
Expand Down Expand Up @@ -150,7 +151,7 @@ public function runOnFileInfos(array $fileInfos): void
$this->removedAndAddedFilesProcessor->run();

// 5. various extensions on finish
$this->finishingExtensionRunner->run();
$this->eventDispatcher->dispatch(new AfterProcessEvent());
}

/**
Expand Down
21 changes: 11 additions & 10 deletions src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
use Rector\Core\Configuration\Configuration;
use Rector\Core\Configuration\Option;
use Rector\Core\Console\Output\OutputFormatterCollector;
use Rector\Core\EventDispatcher\Event\AfterReportEvent;
use Rector\Core\FileSystem\FilesFinder;
use Rector\Core\Guard\RectorGuard;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
use Rector\Core\Stubs\StubLoader;
use Rector\Core\Yaml\YamlProcessor;
use Rector\Extension\Runner\ReportingExtensionRunner;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symplify\PackageBuilder\Console\Command\CommandNaming;
use Symplify\PackageBuilder\Console\ShellCode;
use Symplify\SmartFileSystem\SmartFileInfo;
Expand Down Expand Up @@ -65,11 +66,6 @@ final class ProcessCommand extends AbstractCommand
*/
private $outputFormatterCollector;

/**
* @var ReportingExtensionRunner
*/
private $reportingExtensionRunner;

/**
* @var RectorNodeTraverser
*/
Expand Down Expand Up @@ -100,6 +96,11 @@ final class ProcessCommand extends AbstractCommand
*/
private $symfonyStyle;

/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;

public function __construct(
FilesFinder $phpFilesFinder,
AdditionalAutoloader $additionalAutoloader,
Expand All @@ -108,13 +109,13 @@ public function __construct(
Configuration $configuration,
RectorApplication $rectorApplication,
OutputFormatterCollector $outputFormatterCollector,
ReportingExtensionRunner $reportingExtensionRunner,
RectorNodeTraverser $rectorNodeTraverser,
StubLoader $stubLoader,
YamlProcessor $yamlProcessor,
ChangedFilesDetector $changedFilesDetector,
UnchangedFilesFilter $unchangedFilesFilter,
SymfonyStyle $symfonyStyle
SymfonyStyle $symfonyStyle,
EventDispatcherInterface $eventDispatcher
) {
$this->filesFinder = $phpFilesFinder;
$this->additionalAutoloader = $additionalAutoloader;
Expand All @@ -123,7 +124,6 @@ public function __construct(
$this->configuration = $configuration;
$this->rectorApplication = $rectorApplication;
$this->outputFormatterCollector = $outputFormatterCollector;
$this->reportingExtensionRunner = $reportingExtensionRunner;
$this->rectorNodeTraverser = $rectorNodeTraverser;
$this->stubLoader = $stubLoader;
$this->yamlProcessor = $yamlProcessor;
Expand All @@ -133,6 +133,7 @@ public function __construct(

$this->changedFilesDetector = $changedFilesDetector;
$this->symfonyStyle = $symfonyStyle;
$this->eventDispatcher = $eventDispatcher;
}

protected function configure(): void
Expand Down Expand Up @@ -234,7 +235,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$outputFormatter = $this->outputFormatterCollector->getByName($outputFormat);
$outputFormatter->report($this->errorAndDiffCollector);

$this->reportingExtensionRunner->run();
$this->eventDispatcher->dispatch(new AfterReportEvent());

// invalidate affected files
$this->invalidateAffectedCacheFiles();
Expand Down
11 changes: 11 additions & 0 deletions src/EventDispatcher/Event/AfterProcessEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Core\EventDispatcher\Event;

use Symfony\Contracts\EventDispatcher\Event;

final class AfterProcessEvent extends Event
{
}
11 changes: 11 additions & 0 deletions src/EventDispatcher/Event/AfterReportEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Core\EventDispatcher\Event;

use Symfony\Contracts\EventDispatcher\Event;

final class AfterReportEvent extends Event
{
}
30 changes: 0 additions & 30 deletions src/Extension/FinishingExtensionRunner.php

This file was deleted.