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
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

-
name: 'Check Active Classes'
run: vendor/bin/class-leak check bin src tests --ansi
run: vendor/bin/class-leak check bin src tests --ansi --skip-type="Rector\Monitor\Compare\Contract\ComparatorInterface"

-
name: 'Run "Compare Projects" command'
Expand Down
4 changes: 2 additions & 2 deletions bin/monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use Rector\Monitor\Console\MonitorConsoleApplication;
use Rector\Monitor\DependencyInjection\ContainerFactory;
use Symfony\Component\Console\Application;

$scoperAutoloadFilepath = __DIR__ . '/../vendor/scoper-autoload.php';
if (file_exists($scoperAutoloadFilepath)) {
Expand All @@ -30,5 +30,5 @@
$containerFactory = new ContainerFactory();
$container = $containerFactory->create();

$application = $container->make(Application::class);
$application = $container->make(MonitorConsoleApplication::class);
exit($application->run());
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"require": {
"php": ">=8.3",
"composer/semver": "^3.4",
"illuminate/container": "12.40.*",
"entropy/entropy": "dev-main",
"nette/neon": "^3.4",
"nette/utils": "^4.1",
"symfony/console": "^6.4",
"symfony/filesystem": "^7.4",
"symfony/console": "^6.4",
"symfony/finder": "^7.4",
"symfony/process": "^7.4",
"webmozart/assert": "^1.12"
Expand Down
2 changes: 1 addition & 1 deletion src/Analyze/RuleProcessor/TooLowPackagesRulesProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Rector\Monitor\ValueObject\ComposerJson;

/**
* @see \Rector\Monitor\Tests\RuleProcessor\TooLowPackagesRulesProcessor\TooLowPackagesRulesProcessorTest
* @see \Rector\Monitor\Tests\Analyze\RuleProcessor\TooLowPackagesRulesProcessor\TooLowPackagesRulesProcessorTest
*/
final class TooLowPackagesRulesProcessor implements RuleProcessorInterface
{
Expand Down
61 changes: 0 additions & 61 deletions src/Compare/DependencyInjection/ContainerFactory.php

This file was deleted.

55 changes: 17 additions & 38 deletions src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@

namespace Rector\Monitor\DependencyInjection;

use Illuminate\Container\Container;
use Rector\Monitor\Analyze\Command\AnalyzeCommand;
use Entropy\Container\Container;
use Rector\Monitor\Compare\Command\CompareProjectsCommand;
use Rector\Monitor\Compare\Comparator\ComposerAutoloadComparator;
use Rector\Monitor\Compare\Comparator\MutuallyMissingPackagesComparator;
use Rector\Monitor\Compare\Comparator\PHPStanExtensionsComparator;
use Rector\Monitor\Compare\Comparator\PHPStanLevelComparator;
use Rector\Monitor\Compare\Comparator\PHPStanPathsComparator;
use Rector\Monitor\Compare\Comparator\SymfonyConfigFilesComparator;
use Rector\Monitor\Compare\Contract\ComparatorInterface;
use Rector\Monitor\Console\MonitorConsoleApplication;
use Rector\Monitor\Matrix\Command\MatrixCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand All @@ -30,36 +23,31 @@ public function create(): Container
{
$container = new Container();

// console
$container->singleton(Application::class, function (Container $container): MonitorConsoleApplication {
$container->service(MonitorConsoleApplication::class, function (
Container $container
): MonitorConsoleApplication {
$monitorConsoleApplication = new MonitorConsoleApplication('Rector Monitor');

$commandClasses = [AnalyzeCommand::class, MatrixCommand::class, CompareProjectsCommand::class];

// register commands
foreach ($commandClasses as $commandClass) {
$command = $container->make($commandClass);
$monitorConsoleApplication->add($command);
}
$commands = $container->findByContract(Command::class);
$monitorConsoleApplication->addCommands($commands);

// remove basic command to make output clear
$this->hideDefaultCommands($monitorConsoleApplication);

return $monitorConsoleApplication;
});

$this->registerComparator($container, ComposerAutoloadComparator::class);
$this->registerComparator($container, MutuallyMissingPackagesComparator::class);
$this->registerComparator($container, SymfonyConfigFilesComparator::class);
$this->registerComparator($container, PHPStanExtensionsComparator::class);
$this->registerComparator($container, PHPStanPathsComparator::class);
$this->registerComparator($container, PHPStanLevelComparator::class);

$container->when(CompareProjectsCommand::class)
->needs('$comparators')
->giveTagged(ComparatorInterface::class);
$container->service(
CompareProjectsCommand::class,
function (Container $container): CompareProjectsCommand {
return new CompareProjectsCommand(
$container->make(SymfonyStyle::class),
$container->findByContract(ComparatorInterface::class)
);
}
);

$container->singleton(
$container->service(
SymfonyStyle::class,
static fn (): SymfonyStyle => new SymfonyStyle(new ArrayInput([]), new ConsoleOutput())
);
Expand All @@ -76,13 +64,4 @@ public function hideDefaultCommands(Application $application): void
$application->get('help')
->setHidden(true);
}

/**
* @param class-string<ComparatorInterface> $comparatorClass
*/
private function registerComparator(Container $container, string $comparatorClass): void
{
$container->singleton($comparatorClass);
$container->tag($comparatorClass, ComparatorInterface::class);
}
}
2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rector\Monitor\Tests;

use Illuminate\Container\Container;
use Entropy\Container\Container;
use PHPUnit\Framework\TestCase;
use Rector\Monitor\DependencyInjection\ContainerFactory;

Expand Down