Skip to content

Commit b4b479a

Browse files
committed
wip
1 parent d870434 commit b4b479a

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function make(): ConsoleApplication
2121
$constraintCommand = new ConstraintCommand;
2222

2323
$app->addCommands([
24-
new ComposerCommand($constraintCommand),
24+
new ComposerCommand,
2525
$constraintCommand,
2626
]);
2727

src/Console/ComposerCommand.php

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

55
namespace TypistTech\PhpMatrix\Console;
66

7+
use Symfony\Component\Console\Application;
78
use Symfony\Component\Console\Attribute\Argument;
89
use Symfony\Component\Console\Attribute\AsCommand;
910
use Symfony\Component\Console\Command\Command;
@@ -19,14 +20,9 @@ class ComposerCommand extends Command
1920
{
2021
use PrintErrorTrait;
2122

22-
public function __construct(
23-
private readonly ConstraintCommand $constraintCommand,
24-
) {
25-
parent::__construct();
26-
}
27-
2823
public function __invoke(
2924
SymfonyStyle $io,
25+
Application $application,
3026
#[Argument(description: 'Path to composer.json file.')]
3127
string $path = './composer.json',
3228
#[SourceOption]
@@ -37,12 +33,13 @@ public function __invoke(
3733
try {
3834
$composer = Composer::fromFile($path);
3935

40-
return $this->constraintCommand->__invoke(
41-
$io,
42-
$composer->requiredPhpConstraint(),
43-
$source,
44-
$mode,
45-
);
36+
return $application->get('constraint')
37+
->__invoke(
38+
$io,
39+
$composer->requiredPhpConstraint(),
40+
$source,
41+
$mode,
42+
);
4643
} catch (ExceptionInterface $e) {
4744
$this->printError(
4845
$io,

src/Console/PrintErrorTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ trait PrintErrorTrait
1010
{
1111
private function printError(SymfonyStyle $io, string $message): void
1212
{
13-
$io
14-
->getErrorStyle()
13+
$io->getErrorStyle()
1514
->error($message);
1615
}
1716
}

0 commit comments

Comments
 (0)