@@ -51,7 +51,7 @@ class Shell
5151
5252 const DEFAULT_STDOUT_WIN = ['pipe ' , 'w ' ];
5353 const DEFAULT_STDOUT_NIX = ['pipe ' , 'w ' ];
54-
54+
5555 const DEFAULT_STDERR_WIN = ['pipe ' , 'w ' ];
5656 const DEFAULT_STDERR_NIX = ['pipe ' , 'w ' ];
5757
@@ -119,6 +119,7 @@ protected function prepareDescriptors(?array $stdin = null, ?array $stdout = nul
119119 if (!$ stderr ) {
120120 $ stderr = $ win ? self ::DEFAULT_STDERR_WIN : self ::DEFAULT_STDERR_NIX ;
121121 }
122+
122123 return [
123124 self ::STDIN_DESCRIPTOR_KEY => $ stdin ,
124125 self ::STDOUT_DESCRIPTOR_KEY => $ stdout ,
@@ -132,6 +133,7 @@ protected function isWindows(): bool
132133 if (defined ('PHP_OS ' )) {
133134 return 'WIN ' === strtoupper (substr (PHP_OS , 0 , 3 )); // May be 'WINNT' or 'WIN32' or 'Windows'
134135 }
136+
135137 return '\\' === DIRECTORY_SEPARATOR ; // Fallback - Less reliable (Windows 7...)
136138 }
137139
@@ -208,16 +210,17 @@ public function setOptions(
208210
209211 return $ this ;
210212 }
211-
213+
212214 /**
213215 * execute
214216 * Execute the command with optional stdin, stdout and stderr which override the defaults
215- * If async is set to true, the process will be executed in the background
216- *
217- * @param bool $async - default false
218- * @param ?array $stdin - default null (loads default descriptor)
219- * @param ?array $stdout - default null (loads default descriptor)
220- * @param ?array $stderr - default null (loads default descriptor)
217+ * If async is set to true, the process will be executed in the background.
218+ *
219+ * @param bool $async - default false
220+ * @param ?array $stdin - default null (loads default descriptor)
221+ * @param ?array $stdout - default null (loads default descriptor)
222+ * @param ?array $stderr - default null (loads default descriptor)
223+ *
221224 * @return self
222225 */
223226 public function execute (bool $ async = false , ?array $ stdin = null , ?array $ stdout = null , ?array $ stderr = null ): self
@@ -264,6 +267,7 @@ private function setOutputStreamNonBlocking(): bool
264267 if (!is_resource ($ this ->pipes [self ::STDOUT_DESCRIPTOR_KEY ])) {
265268 return false ;
266269 }
270+
267271 return stream_set_blocking ($ this ->pipes [self ::STDOUT_DESCRIPTOR_KEY ], false );
268272 }
269273
@@ -278,6 +282,7 @@ public function getOutput(): string
278282 if (!is_resource ($ this ->pipes [self ::STDOUT_DESCRIPTOR_KEY ])) {
279283 return '' ;
280284 }
285+
281286 return stream_get_contents ($ this ->pipes [self ::STDOUT_DESCRIPTOR_KEY ]);
282287 }
283288
@@ -286,6 +291,7 @@ public function getErrorOutput(): string
286291 if (!is_resource ($ this ->pipes [self ::STDERR_DESCRIPTOR_KEY ])) {
287292 return '' ;
288293 }
294+
289295 return stream_get_contents ($ this ->pipes [self ::STDERR_DESCRIPTOR_KEY ]);
290296 }
291297
0 commit comments