@@ -9,7 +9,7 @@ class Console
99 *
1010 * Sets the process title visible in tools such as top and ps.
1111 *
12- * @param string $title
12+ * @param string $title
1313 * @return bool
1414 */
1515 public static function title (string $ title ): bool
@@ -22,7 +22,7 @@ public static function title(string $title): bool
2222 *
2323 * Log messages to console
2424 *
25- * @param string $message
25+ * @param string $message
2626 * @return bool|int
2727 */
2828 public static function log (string $ message ): int |false
@@ -35,7 +35,7 @@ public static function log(string $message): int|false
3535 *
3636 * Log success messages to console
3737 *
38- * @param string $message
38+ * @param string $message
3939 * @return bool|int
4040 */
4141 public static function success (string $ message ): int |false
@@ -48,7 +48,7 @@ public static function success(string $message): int|false
4848 *
4949 * Log error messages to console
5050 *
51- * @param string $message
51+ * @param string $message
5252 * @return bool|int
5353 */
5454 public static function error (string $ message ): int |false
@@ -61,7 +61,7 @@ public static function error(string $message): int|false
6161 *
6262 * Log informative messages to console
6363 *
64- * @param string $message
64+ * @param string $message
6565 * @return bool|int
6666 */
6767 public static function info (string $ message ): int |false
@@ -74,7 +74,7 @@ public static function info(string $message): int|false
7474 *
7575 * Log warning messages to console
7676 *
77- * @param string $message
77+ * @param string $message
7878 * @return bool|int
7979 */
8080 public static function warning (string $ message ): int |false
@@ -87,19 +87,19 @@ public static function warning(string $message): int|false
8787 *
8888 * Log warning messages to console
8989 *
90- * @param string $question
90+ * @param string $question
9191 * @return string
9292 */
9393 public static function confirm (string $ question ): string
9494 {
95- if (!self ::isInteractive ()) {
95+ if (! self ::isInteractive ()) {
9696 return '' ;
9797 }
9898
9999 self ::log ($ question );
100100
101101 $ handle = \fopen ('php://stdin ' , 'r ' );
102- $ line = \trim (\fgets ($ handle ));
102+ $ line = \trim (\fgets ($ handle ));
103103
104104 \fclose ($ handle );
105105
@@ -111,7 +111,7 @@ public static function confirm(string $question): string
111111 *
112112 * Log warning messages to console
113113 *
114- * @param string $message
114+ * @param string $message
115115 * @return void
116116 */
117117 public static function exit (int $ status = 0 ): void
@@ -124,11 +124,11 @@ public static function exit(int $status = 0): void
124124 *
125125 * This function was inspired by: https://stackoverflow.com/a/13287902/2299554
126126 *
127- * @param string $cmd
128- * @param string $stdin
129- * @param string $stdout
130- * @param string $stderr
131- * @param int $timeout
127+ * @param string $cmd
128+ * @param string $stdin
129+ * @param string $stdout
130+ * @param string $stderr
131+ * @param int $timeout
132132 * @return int
133133 */
134134 public static function execute (string $ cmd , string $ stdin , string &$ stdout , string &$ stderr , int $ timeout = -1 ): int
@@ -138,7 +138,7 @@ public static function execute(string $cmd, string $stdin, string &$stdout, stri
138138 $ pipes = [];
139139 $ process = \proc_open (
140140 $ cmd ,
141- [['pipe ' ,'r ' ],['pipe ' ,'w ' ],['pipe ' ,'w ' ],['pipe ' , 'w ' ]],
141+ [['pipe ' , 'r ' ], ['pipe ' , 'w ' ], ['pipe ' , 'w ' ], ['pipe ' , 'w ' ]],
142142 $ pipes
143143 );
144144 $ start = \time ();
@@ -163,15 +163,16 @@ public static function execute(string $cmd, string $stdin, string &$stdout, stri
163163
164164 if ($ timeout > 0 && \time () - $ start > $ timeout ) {
165165 \proc_terminate ($ process , 9 );
166+
166167 return 1 ;
167168 }
168169
169- if (!\proc_get_status ($ process )['running ' ]) {
170+ if (! \proc_get_status ($ process )['running ' ]) {
170171 \fclose ($ pipes [1 ]);
171172 \fclose ($ pipes [2 ]);
172173 \proc_close ($ process );
173174
174- $ exitCode = (int ) str_replace ("\n" , "" , $ status );
175+ $ exitCode = (int ) str_replace ("\n" , '' , $ status );
175176
176177 return $ exitCode ;
177178 }
@@ -189,21 +190,21 @@ public static function execute(string $cmd, string $stdin, string &$stdout, stri
189190 */
190191 public static function isInteractive (): bool
191192 {
192- return ( 'cli ' === PHP_SAPI && defined ('STDOUT ' ) );
193+ return 'cli ' === PHP_SAPI && defined ('STDOUT ' );
193194 }
194195
195196 /**
196- * @param callable $callback
197- * @param float $sleep // in seconds!
198- * @param callable $onError
197+ * @param callable $callback
198+ * @param float $sleep // in seconds!
199+ * @param callable $onError
199200 */
200201 public static function loop (callable $ callback , $ sleep = 1 /* seconds */ , callable $ onError = null ): void
201202 {
202203 gc_enable ();
203204
204205 $ time = 0 ;
205206
206- while (!connection_aborted () || PHP_SAPI == " cli " ) {
207+ while (! connection_aborted () || PHP_SAPI == ' cli ' ) {
207208 try {
208209 $ callback ();
209210 } catch (\Exception $ e ) {
@@ -227,7 +228,7 @@ public static function loop(callable $callback, $sleep = 1 /* seconds */, callab
227228
228229 $ time = $ time + $ sleep ;
229230
230- if (PHP_SAPI == " cli " ) {
231+ if (PHP_SAPI == ' cli ' ) {
231232 if ($ time >= 60 * 5 ) { // Every 5 minutes
232233 $ time = 0 ;
233234 gc_collect_cycles (); //Forces collection of any existing garbage cycles
0 commit comments