diff --git a/src/ChildProcess.php b/src/ChildProcess.php index 171210f..e8a2d10 100644 --- a/src/ChildProcess.php +++ b/src/ChildProcess.php @@ -51,6 +51,10 @@ public function all(): array return $hydrated; } + /** + * @param string|string[] $cmd + * @return $this + */ public function start( string|array $cmd, string $alias, @@ -58,10 +62,11 @@ public function start( ?array $env = null, bool $persistent = false ): static { + $cmd = is_array($cmd) ? array_values($cmd) : [$cmd]; $process = $this->client->post('child-process/start', [ 'alias' => $alias, - 'cmd' => (array) $cmd, + 'cmd' => $cmd, 'cwd' => $cwd ?? base_path(), 'env' => $env, 'persistent' => $persistent, @@ -70,11 +75,17 @@ public function start( return $this->fromRuntimeProcess($process); } + /** + * @param string|string[] $cmd + * @return $this + */ public function php(string|array $cmd, string $alias, ?array $env = null, ?bool $persistent = false): self { + $cmd = is_array($cmd) ? array_values($cmd) : [$cmd]; + $process = $this->client->post('child-process/start-php', [ 'alias' => $alias, - 'cmd' => (array) $cmd, + 'cmd' => $cmd, 'cwd' => $cwd ?? base_path(), 'env' => $env, 'persistent' => $persistent, @@ -83,9 +94,15 @@ public function php(string|array $cmd, string $alias, ?array $env = null, ?bool return $this->fromRuntimeProcess($process); } + /** + * @param string|string[] $cmd + * @return $this + */ public function artisan(string|array $cmd, string $alias, ?array $env = null, ?bool $persistent = false): self { - $cmd = ['artisan', ...(array) $cmd]; + $cmd = is_array($cmd) ? array_values($cmd) : [$cmd]; + + $cmd = ['artisan', ...$cmd]; return $this->php($cmd, $alias, env: $env, persistent: $persistent); }