44
55use  App \Factories \ConfigurationResolverFactory ;
66use  LaravelZero \Framework \Exceptions \ConsoleException ;
7+ use  PhpCsFixer \Console \ConfigurationResolver ;
78use  PhpCsFixer \Runner \Runner ;
9+ use  Symfony \Component \Console \Input \InputInterface ;
10+ use  Symfony \Component \Console \Input \InputOption ;
811
912class  FixCode
1013{
@@ -45,8 +48,10 @@ public function execute()
4548            $ this progress ->subscribe ();
4649        }
4750
51+         $ method$ this input ->getOption ('parallel ' ) ? 'fixParallel '  : 'fixSequential ' ;
52+ 
4853        /** @var array<string, array{appliedFixers: array<int, string>, diff: string}> $changes */ 
49-         $ changesnew  Runner (
54+         $ changesfn  () =>  $ this ->{ $ method }())-> call ( new  Runner (
5055            $ resolvergetFinder (),
5156            $ resolvergetFixers (),
5257            $ resolvergetDiffer (),
@@ -56,9 +61,34 @@ public function execute()
5661            $ resolverisDryRun (),
5762            $ resolvergetCacheManager (),
5863            $ resolvergetDirectory (),
59-             $ resolvershouldStopOnViolation ()
60-         ))->fix ();
64+             $ resolvershouldStopOnViolation (),
65+             $ resolvergetParallelConfig (),
66+             $ this getInput ($ resolver
67+         ));
6168
6269        return  tap ([$ totalFiles$ changesfn  () => $ this progress ->unsubscribe ());
6370    }
71+ 
72+     /** 
73+      * Gets the input for the PHP CS Fixer Runner. 
74+      */ 
75+     private  function  getInput (ConfigurationResolver $ resolverInputInterface 
76+     {
77+         // @phpstan-ignore-next-line 
78+         $ definitionfn  () => $ this definition )->call ($ this input );
79+ 
80+         $ definitionaddOptions ([
81+             new  InputOption ('stop-on-violation ' , null , InputOption::VALUE_REQUIRED , '' ),
82+             new  InputOption ('allow-risky ' , null , InputOption::VALUE_REQUIRED , '' ),
83+             new  InputOption ('rules ' , null , InputOption::VALUE_REQUIRED , '' ),
84+             new  InputOption ('using-cache ' , null , InputOption::VALUE_REQUIRED , '' ),
85+         ]);
86+ 
87+         $ this input ->setOption ('stop-on-violation ' , $ resolvershouldStopOnViolation ());
88+         $ this input ->setOption ('allow-risky ' , $ resolvergetRiskyAllowed () ? 'yes '  : 'no ' );
89+         $ this input ->setOption ('rules ' , json_encode ($ resolvergetRules ()));
90+         $ this input ->setOption ('using-cache ' , $ resolvergetUsingCache () ? 'yes '  : 'no ' );
91+ 
92+         return  $ this input ;
93+     }
6494}
0 commit comments