@@ -51,14 +51,18 @@ public function all(): array
51
51
return $ hydrated ;
52
52
}
53
53
54
+ /**
55
+ * @param string|string[] $cmd
56
+ * @return $this
57
+ */
54
58
public function start (
55
59
string |array $ cmd ,
56
60
string $ alias ,
57
61
?string $ cwd = null ,
58
62
?array $ env = null ,
59
63
bool $ persistent = false
60
64
): static {
61
- $ cmd = $ this -> ensureCmdIsAnIndexedArray ($ cmd );
65
+ $ cmd = is_array ( $ cmd ) ? array_values ($ cmd ) : [ $ cmd ] ;
62
66
63
67
$ process = $ this ->client ->post ('child-process/start ' , [
64
68
'alias ' => $ alias ,
@@ -71,9 +75,13 @@ public function start(
71
75
return $ this ->fromRuntimeProcess ($ process );
72
76
}
73
77
78
+ /**
79
+ * @param string|string[] $cmd
80
+ * @return $this
81
+ */
74
82
public function php (string |array $ cmd , string $ alias , ?array $ env = null , ?bool $ persistent = false ): self
75
83
{
76
- $ cmd = $ this -> ensureCmdIsAnIndexedArray ($ cmd );
84
+ $ cmd = is_array ( $ cmd ) ? array_values ($ cmd ) : [ $ cmd ] ;
77
85
78
86
$ process = $ this ->client ->post ('child-process/start-php ' , [
79
87
'alias ' => $ alias ,
@@ -86,9 +94,15 @@ public function php(string|array $cmd, string $alias, ?array $env = null, ?bool
86
94
return $ this ->fromRuntimeProcess ($ process );
87
95
}
88
96
97
+ /**
98
+ * @param string|string[] $cmd
99
+ * @return $this
100
+ */
89
101
public function artisan (string |array $ cmd , string $ alias , ?array $ env = null , ?bool $ persistent = false ): self
90
102
{
91
- $ cmd = ['artisan ' , ...(array ) $ cmd ];
103
+ $ cmd = is_array ($ cmd ) ? array_values ($ cmd ) : [$ cmd ];
104
+
105
+ $ cmd = ['artisan ' , ...$ cmd ];
92
106
93
107
return $ this ->php ($ cmd , $ alias , env: $ env , persistent: $ persistent );
94
108
}
@@ -135,15 +149,4 @@ protected function fromRuntimeProcess($process): static
135
149
136
150
return $ this ;
137
151
}
138
-
139
- protected function ensureCmdIsAnIndexedArray (string |array $ cmd ): array
140
- {
141
- if (is_string ($ cmd )) {
142
- return [$ cmd ];
143
- }
144
-
145
- if (array_keys ($ cmd ) !== range (0 , count ($ cmd ) - 1 )) {
146
- throw new \InvalidArgumentException ('Only indexed arrays are supported for the cmd: argument. ' );
147
- }
148
- }
149
152
}
0 commit comments