@@ -23,10 +23,10 @@ class ProcessHelperTest extends TestCase
23
23
/**
24
24
* @dataProvider provideCommandsAndOutput
25
25
*/
26
- public function testVariousProcessRuns ($ expected , $ cmd , $ verbosity , $ error )
26
+ public function testVariousProcessRuns (string $ expected , Process | string | array $ cmd , int $ verbosity , ? string $ error )
27
27
{
28
28
if (\is_string ($ cmd )) {
29
- $ cmd = method_exists ( Process::class, ' fromShellCommandline ' ) ? Process:: fromShellCommandline ( $ cmd ) : new Process ($ cmd );
29
+ $ cmd = Process::fromShellCommandline ($ cmd );
30
30
}
31
31
32
32
$ helper = new ProcessHelper ();
@@ -49,7 +49,7 @@ public function testPassedCallbackIsExecuted()
49
49
$ this ->assertTrue ($ executed );
50
50
}
51
51
52
- public static function provideCommandsAndOutput ()
52
+ public static function provideCommandsAndOutput (): array
53
53
{
54
54
$ successOutputVerbose = <<<'EOT'
55
55
RUN php -r "echo 42;"
@@ -99,7 +99,6 @@ public static function provideCommandsAndOutput()
99
99
$ args = new Process (['php ' , '-r ' , 'echo 42; ' ]);
100
100
$ args = $ args ->getCommandLine ();
101
101
$ successOutputProcessDebug = str_replace ("'php' '-r' 'echo 42;' " , $ args , $ successOutputProcessDebug );
102
- $ fromShellCommandline = method_exists (Process::class, 'fromShellCommandline ' ) ? [Process::class, 'fromShellCommandline ' ] : fn ($ cmd ) => new Process ($ cmd );
103
102
104
103
return [
105
104
['' , 'php -r "echo 42;" ' , StreamOutput::VERBOSITY_VERBOSE , null ],
@@ -113,18 +112,18 @@ public static function provideCommandsAndOutput()
113
112
[$ syntaxErrorOutputVerbose .$ errorMessage .\PHP_EOL , 'php -r "fwrite(STDERR, \'error message \');usleep(50000);fwrite(STDOUT, \'out message \');exit(252);" ' , StreamOutput::VERBOSITY_VERY_VERBOSE , $ errorMessage ],
114
113
[$ syntaxErrorOutputDebug .$ errorMessage .\PHP_EOL , 'php -r "fwrite(STDERR, \'error message \');usleep(500000);fwrite(STDOUT, \'out message \');exit(252);" ' , StreamOutput::VERBOSITY_DEBUG , $ errorMessage ],
115
114
[$ 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 ],
117
116
[$ 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 ],
119
118
];
120
119
}
121
120
122
- private function getOutputStream ($ verbosity )
121
+ private function getOutputStream ($ verbosity ): StreamOutput
123
122
{
124
123
return new StreamOutput (fopen ('php://memory ' , 'r+ ' , false ), $ verbosity , false );
125
124
}
126
125
127
- private function getOutput (StreamOutput $ output )
126
+ private function getOutput (StreamOutput $ output ): string
128
127
{
129
128
rewind ($ output ->getStream ());
130
129
0 commit comments