@@ -36,16 +36,19 @@ public function __construct(
3636
3737 public static function create (?Command $ command = null ): self
3838 {
39- $ token = \getenv ('GITHUB_TOKEN ' );
40-
4139 $ systemInfo = SystemInfo::detect ();
42- \is_string (\getenv ('ROADRUNNER_BINARY ' )) and $ systemInfo ->rrExecutable = \getenv ('ROADRUNNER_BINARY ' );
40+ $ roadRunnerBinary = \getenv ('ROADRUNNER_BINARY ' );
41+ if (\is_string ($ roadRunnerBinary )) {
42+ $ systemInfo ->rrExecutable = $ roadRunnerBinary ;
43+ }
44+
45+ $ token = \getenv ('GITHUB_TOKEN ' );
4346
4447 return new self (
4548 new TestOutputStyle (new ArgvInput (), new ConsoleOutput ()),
4649 new Downloader (new Filesystem (), HttpClient::create ([
4750 'headers ' => [
48- 'authorization ' => $ token ? 'token ' . $ token : null ,
51+ 'authorization ' => \is_string ( $ token) ? 'token ' . $ token : null ,
4952 ],
5053 ])),
5154 $ systemInfo ,
@@ -122,7 +125,7 @@ public function startTemporalServer(
122125 $ this ->io ->info ('Running command: ' . $ this ->serializeProcess ($ this ->temporalServerProcess ));
123126 $ this ->temporalServerProcess ->start ();
124127
125- $ deadline = \microtime (true ) + $ commandTimeout ;
128+ $ deadline = \microtime (true ) + ( float ) $ commandTimeout ;
126129 while (!$ temporalStarted && \microtime (true ) < $ deadline ) {
127130 \usleep (10_000 );
128131 $ check = new Process ([
@@ -162,7 +165,7 @@ public function startTemporalTestServer(int $commandTimeout = 10): void
162165 $ this ->io ->info ('Temporal test server downloaded. ' );
163166 }
164167
165- $ temporalPort = \parse_url ($ this ->command ->address , PHP_URL_PORT );
168+ $ temporalPort = \parse_url (( string ) $ this ->command ->address , PHP_URL_PORT );
166169
167170 $ this ->io ->info ('Starting Temporal test server... ' );
168171 $ this ->temporalTestServerProcess = new Process (
@@ -192,7 +195,7 @@ public function startTemporalTestServer(int $commandTimeout = 10): void
192195 /**
193196 * @param array<string, mixed> $envs
194197 */
195- public function startRoadRunner (?string $ rrCommand = null , int $ commandTimeout = 10 , array $ envs = [], string $ configFile = '.rr.yaml ' ): void
198+ public function startRoadRunner (?array $ rrCommand = null , int $ commandTimeout = 10 , array $ envs = [], string $ configFile = '.rr.yaml ' ): void
196199 {
197200 if (!$ this ->isTemporalRunning () && !$ this ->isTemporalTestRunning ()) {
198201 $ this ->io ->error ([
@@ -202,7 +205,7 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout =
202205 }
203206
204207 $ this ->roadRunnerProcess = new Process (
205- command: $ rrCommand ? \explode ( ' ' , $ rrCommand ) : [$ this ->systemInfo ->rrExecutable , 'serve ' ],
208+ command: $ rrCommand ?? [$ this ->systemInfo ->rrExecutable , 'serve ' ],
206209 env: $ envs ,
207210 );
208211 $ this ->roadRunnerProcess ->setTimeout ($ commandTimeout );
@@ -213,7 +216,7 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout =
213216 $ this ->roadRunnerProcess ->start ();
214217
215218 // wait for roadrunner to start
216- $ deadline = \microtime (true ) + $ commandTimeout ;
219+ $ deadline = \microtime (true ) + ( float ) $ commandTimeout ;
217220 while (!$ roadRunnerStarted && \microtime (true ) < $ deadline ) {
218221 \usleep (10_000 );
219222 $ check = new Process ([$ this ->systemInfo ->rrExecutable , 'workers ' , '-c ' , $ configFile ]);
@@ -289,26 +292,38 @@ public function stopRoadRunner(): void
289292 }
290293 }
291294
295+ /**
296+ * @psalm-assert Process $this->temporalServerProcess
297+ */
292298 public function isTemporalRunning (): bool
293299 {
294300 return $ this ->temporalServerProcess ?->isRunning() === true ;
295301 }
296302
303+ /**
304+ * @psalm-assert Process $this->roadRunnerProcess
305+ */
297306 public function isRoadRunnerRunning (): bool
298307 {
299308 return $ this ->roadRunnerProcess ?->isRunning() === true ;
300309 }
301310
311+ /**
312+ * @psalm-assert Process $this->temporalTestServerProcess
313+ */
302314 public function isTemporalTestRunning (): bool
303315 {
304316 return $ this ->temporalTestServerProcess ?->isRunning() === true ;
305317 }
306318
307- private function serializeProcess (?Process $ temporalServerProcess ): string | array
319+ private function serializeProcess (?Process $ process ): string
308320 {
309- $ reflection = new \ReflectionClass ($ temporalServerProcess );
321+ if ($ process === null ) {
322+ return 'process is not started ' ;
323+ }
324+ $ reflection = new \ReflectionClass ($ process );
310325 $ reflectionProperty = $ reflection ->getProperty ('commandline ' );
311- $ commandLine = $ reflectionProperty ->getValue ($ temporalServerProcess );
326+ $ commandLine = $ reflectionProperty ->getValue ($ process );
312327 return \implode (' ' , $ commandLine );
313328 }
314329}
0 commit comments