@@ -23,10 +23,10 @@ class ProcessHelperTest extends TestCase
2323 /**
2424 * @dataProvider provideCommandsAndOutput
2525 */
26- public function testVariousProcessRuns ($ expected , $ cmd , $ verbosity , $ error )
26+ public function testVariousProcessRuns (string $ expected , Process | string | array $ cmd , int $ verbosity , ? string $ error )
2727 {
2828 if (\is_string ($ cmd )) {
29- $ cmd = method_exists ( Process::class, ' fromShellCommandline ' ) ? Process:: fromShellCommandline ( $ cmd ) : new Process ($ cmd );
29+ $ cmd = Process::fromShellCommandline ($ cmd );
3030 }
3131
3232 $ helper = new ProcessHelper ();
@@ -49,7 +49,7 @@ public function testPassedCallbackIsExecuted()
4949 $ this ->assertTrue ($ executed );
5050 }
5151
52- public static function provideCommandsAndOutput ()
52+ public static function provideCommandsAndOutput (): array
5353 {
5454 $ successOutputVerbose = <<<'EOT'
5555 RUN php -r "echo 42;"
@@ -99,7 +99,6 @@ public static function provideCommandsAndOutput()
9999 $ args = new Process (['php ' , '-r ' , 'echo 42; ' ]);
100100 $ args = $ args ->getCommandLine ();
101101 $ successOutputProcessDebug = str_replace ("'php' '-r' 'echo 42;' " , $ args , $ successOutputProcessDebug );
102- $ fromShellCommandline = method_exists (Process::class, 'fromShellCommandline ' ) ? [Process::class, 'fromShellCommandline ' ] : fn ($ cmd ) => new Process ($ cmd );
103102
104103 return [
105104 ['' , 'php -r "echo 42;" ' , StreamOutput::VERBOSITY_VERBOSE , null ],
@@ -113,18 +112,18 @@ public static function provideCommandsAndOutput()
113112 [$ syntaxErrorOutputVerbose .$ errorMessage .\PHP_EOL , 'php -r "fwrite(STDERR, \'error message \');usleep(50000);fwrite(STDOUT, \'out message \');exit(252);" ' , StreamOutput::VERBOSITY_VERY_VERBOSE , $ errorMessage ],
114113 [$ syntaxErrorOutputDebug .$ errorMessage .\PHP_EOL , 'php -r "fwrite(STDERR, \'error message \');usleep(500000);fwrite(STDOUT, \'out message \');exit(252);" ' , StreamOutput::VERBOSITY_DEBUG , $ errorMessage ],
115114 [$ successOutputProcessDebug , ['php ' , '-r ' , 'echo 42; ' ], StreamOutput::VERBOSITY_DEBUG , null ],
116- [$ successOutputDebug , $ fromShellCommandline ('php -r "echo 42;" ' ), StreamOutput::VERBOSITY_DEBUG , null ],
115+ [$ successOutputDebug , Process:: fromShellCommandline ('php -r "echo 42;" ' ), StreamOutput::VERBOSITY_DEBUG , null ],
117116 [$ successOutputProcessDebug , [new Process (['php ' , '-r ' , 'echo 42; ' ])], StreamOutput::VERBOSITY_DEBUG , null ],
118- [$ successOutputPhp , [$ fromShellCommandline ('php -r ' .$ PHP ), 'PHP ' => 'echo 42; ' ], StreamOutput::VERBOSITY_DEBUG , null ],
117+ [$ successOutputPhp , [Process:: fromShellCommandline ('php -r ' .$ PHP ), 'PHP ' => 'echo 42; ' ], StreamOutput::VERBOSITY_DEBUG , null ],
119118 ];
120119 }
121120
122- private function getOutputStream ($ verbosity )
121+ private function getOutputStream ($ verbosity ): StreamOutput
123122 {
124123 return new StreamOutput (fopen ('php://memory ' , 'r+ ' , false ), $ verbosity , false );
125124 }
126125
127- private function getOutput (StreamOutput $ output )
126+ private function getOutput (StreamOutput $ output ): string
128127 {
129128 rewind ($ output ->getStream ());
130129
0 commit comments