File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44
55namespace TypistTech \PhpMatrix \Console ;
66
7+ use Symfony \Component \Console \Application ;
78use Symfony \Component \Console \Attribute \Argument ;
89use Symfony \Component \Console \Attribute \AsCommand ;
910use 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 ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments