Skip to content

Commit b7db68f

Browse files
committed
try entropy
1 parent e34eccd commit b7db68f

File tree

15 files changed

+58
-103
lines changed

15 files changed

+58
-103
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
# see https://github.com/shivammathur/setup-php
5757
- uses: shivammathur/setup-php@v2
5858
with:
59-
php-version: 8.2
59+
php-version: 8.3
6060
coverage: none
6161

6262
# composer install cache - https://github.com/ramsey/composer-install

.github/workflows/downgraded_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
-
2020
uses: "shivammathur/setup-php@v2"
2121
with:
22-
php-version: 8.2
22+
php-version: 8.3
2323
coverage: none
2424

2525
# invoke patches

bin/jack.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Component\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\Console\Output\ConsoleOutput;
5+
use Entropy\Console\ConsoleApplication;
86
use Rector\Jack\DependencyInjection\ContainerFactory;
97

108
$scoperAutoloadFilepath = __DIR__ . '/../vendor/scoper-autoload.php';
@@ -32,7 +30,7 @@
3230
$containerFactory = new ContainerFactory();
3331
$container = $containerFactory->create();
3432

35-
$application = $container->make(Application::class);
33+
$consoleApplication = $container->make(ConsoleApplication::class);
3634

37-
$exitCode = $application->run(new ArgvInput(), new ConsoleOutput());
35+
$exitCode = $consoleApplication->run($argv);
3836
exit($exitCode);

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
"bin/jack"
77
],
88
"require": {
9-
"php": ">=8.2",
9+
"php": ">=8.3",
1010
"composer/semver": "^3.4",
11-
"illuminate/container": "^12.37",
11+
"entropy/entropy": "dev-main",
1212
"nette/utils": "^4.0",
1313
"symfony/console": "^6.4",
14-
"symfony/finder": "^7.3",
1514
"symfony/process": "^7.3",
1615
"webmozart/assert": "^1.12"
1716
},
@@ -23,7 +22,6 @@
2322
"shipmonk/composer-dependency-analyser": "^1.8",
2423
"phpecs/phpecs": "^2.2",
2524
"symplify/phpstan-extensions": "^12.0",
26-
"symplify/vendor-patches": "^11.5",
2725
"tomasvotruba/class-leak": "^2.0",
2826
"tracy/tracy": "^2.11"
2927
},
@@ -41,7 +39,6 @@
4139
"sort-packages": true,
4240
"platform-check": false,
4341
"allow-plugins": {
44-
"cweagans/composer-patches": true,
4542
"phpstan/extension-installer": true
4643
}
4744
},

src/ComposerProcessor/RaiseToInstalledComposerProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
use Composer\Semver\Comparator;
88
use Composer\Semver\VersionParser;
9+
use Entropy\Attributes\RelatedTest;
910
use Nette\Utils\Json;
1011
use Rector\Jack\Composer\InstalledVersionResolver;
1112
use Rector\Jack\Composer\VersionComparator;
1213
use Rector\Jack\FileSystem\ComposerJsonPackageVersionUpdater;
14+
use Rector\Jack\Tests\ComposerProcessor\RaiseToInstalledComposerProcessor\RaiseToInstalledComposerProcessorTest;
1315
use Rector\Jack\ValueObject\ChangedPackageVersion;
1416
use Rector\Jack\ValueObject\ComposerProcessorResult\ChangedPackageVersionsResult;
1517

16-
/**
17-
* @see \Rector\Jack\Tests\ComposerProcessor\RaiseToInstalledComposerProcessor\RaiseToInstalledComposerProcessorTest
18-
*/
18+
#[RelatedTest(RaiseToInstalledComposerProcessorTest::class)]
1919
final readonly class RaiseToInstalledComposerProcessor
2020
{
2121
public function __construct(

src/DependencyInjection/ContainerFactory.php

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
namespace Rector\Jack\DependencyInjection;
66

7-
use Illuminate\Container\Container;
8-
use Rector\Jack\Console\JackConsoleApplication;
9-
use Symfony\Component\Console\Application;
10-
use Symfony\Component\Finder\Finder;
11-
use Webmozart\Assert\Assert;
7+
use Entropy\Console\CommandRegistry;
8+
use Entropy\Console\Contract\CommandInterface;
9+
use Entropy\Container\Container;
1210

1311
final class ContainerFactory
1412
{
@@ -19,57 +17,12 @@ public function create(): Container
1917
{
2018
$container = new Container();
2119

22-
// console
23-
$container->singleton(Application::class, function (Container $container): Application {
24-
$jackConsoleApplication = new JackConsoleApplication('Rector Jack');
25-
26-
$commandClasses = $this->findCommandClasses();
27-
28-
// register commands
29-
foreach ($commandClasses as $commandClass) {
30-
$command = $container->make($commandClass);
31-
$jackConsoleApplication->add($command);
32-
}
33-
34-
// remove basic command to make output clear
35-
$this->hideDefaultCommands($jackConsoleApplication);
36-
37-
return $jackConsoleApplication;
20+
// @todo avoid need of this
21+
$container->service(CommandRegistry::class, function (Container $container): CommandRegistry {
22+
$commands = $container->findByContract(CommandInterface::class);
23+
return new CommandRegistry($commands);
3824
});
3925

4026
return $container;
4127
}
42-
43-
public function hideDefaultCommands(Application $application): void
44-
{
45-
$application->get('list')
46-
->setHidden(true);
47-
$application->get('completion')
48-
->setHidden(true);
49-
$application->get('help')
50-
->setHidden(true);
51-
}
52-
53-
/**
54-
* @return string[]
55-
*/
56-
private function findCommandClasses(): array
57-
{
58-
$commandFinder = Finder::create()
59-
->files()
60-
->name('*Command.php')
61-
->in(__DIR__ . '/../Command');
62-
63-
$commandClasses = [];
64-
foreach ($commandFinder as $commandFile) {
65-
$commandClass = 'Rector\\Jack\\Command\\' . $commandFile->getBasename('.php');
66-
67-
// make sure it exists
68-
Assert::classExists($commandClass);
69-
70-
$commandClasses[] = $commandClass;
71-
}
72-
73-
return $commandClasses;
74-
}
7528
}

tests/AbstractTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Rector\Jack\Tests;
66

7-
use Illuminate\Container\Container;
7+
use Entropy\Container\Container;
88
use PHPUnit\Framework\TestCase;
99
use Rector\Jack\DependencyInjection\ContainerFactory;
1010

@@ -20,6 +20,7 @@ protected function setUp(): void
2020

2121
/**
2222
* @template TType of object
23+
*
2324
* @param class-string<TType> $type
2425
* @return TType
2526
*/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"illuminate/container": "^12.14 || 13.0"
3+
"symfony/console": "^5.4 || 6.4"
44
}
5-
}
5+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"require": {
3-
"illuminate/container": "^12.14 | 13.0"
3+
"symfony/console": "^5.4 | 6.4"
44
}
5-
}
5+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"require-dev": {
3-
"illuminate/container": "^9.0"
3+
"symfony/console": "^5.4"
44
},
55
"conflict": {
6-
"illuminate/container": "<9.0"
6+
"symfony/console": "<5.4"
77
}
88
}

0 commit comments

Comments
 (0)