2929 */
3030final class BuildCommand extends Command
3131{
32- /**
33- * {@inheritDoc}
34- */
35- protected $ signature = 'app:build
36- {name? : The build name}
37- {--build-version= : The build version, if not provided it will be asked}
38- {--timeout=300 : The timeout in seconds or 0 to disable}
39- ' ;
32+ /** {@inheritDoc} */
33+ protected $ signature = <<<'EOD'
34+ app:build
35+ {name? : The build name}
36+ {--build-version= : The build version, if not provided it will be asked}
37+ {--timeout=300 : The timeout in seconds or 0 to disable}
4038
41- /**
42- * {@inheritDoc}
43- */
39+ EOD;
40+
41+ /** {@inheritDoc} */
4442 protected $ description = 'Build a single file executable. ' ;
4543
46- /**
47- * Holds the configuration on is original state.
48- *
49- * @var null|string
50- */
51- private static $ config ;
44+ /** Holds the configuration on is original state. */
45+ private static ?string $ config = null ;
5246
53- /**
54- * Holds the box.json on is original state.
55- *
56- * @var null|string
57- */
58- private static $ box ;
47+ /** Holds the box.json on is original state. */
48+ private static ?string $ box ;
5949
60- /**
61- * Holds the command original output.
62- *
63- * @var null|\Symfony\Component\Console\Output\OutputInterface
64- */
65- private $ originalOutput ;
50+ /** Holds the command original output. */
51+ private ?OutputInterface $ originalOutput ;
6652
6753 /**
6854 * Makes sure that the `clear` is performed even
6955 * if the command fails.
70- *
71- * @return void
7256 */
7357 public function __destruct ()
7458 {
@@ -78,12 +62,13 @@ public function __destruct()
7862 }
7963
8064 /**
81- * @psalm-suppress UndefinedInterfaceMethod
8265 * @noinspection PhpMissingParentCallCommonInspection
66+ *
67+ * @psalm-suppress UndefinedInterfaceMethod
8368 */
8469 public function isEnabled (): bool
8570 {
86- return ! $ this ->laravel ->isProduction ();
71+ return !$ this ->laravel ->isProduction ();
8772 }
8873
8974 /**
@@ -125,21 +110,21 @@ private function build(string $name): self
125110 ->clear ();
126111
127112 $ this ->output ->writeln (
128- sprintf (' Compiled successfully: <fg=green>%s</> ' , $ this ->app ->buildsPath ($ name ))
113+ \ sprintf (' Compiled successfully: <fg=green>%s</> ' , $ this ->app ->buildsPath ($ name ))
129114 );
130115
131116 return $ this ;
132117 }
133118
134119 /**
135- * @psalm-suppress UndefinedInterfaceMethod
136- *
137120 * @noinspection PhpVoidFunctionResultUsedInspection
138121 * @noinspection DisconnectedForeachInstructionInspection
122+ *
123+ * @psalm-suppress UndefinedInterfaceMethod
139124 */
140125 private function compile (string $ name ): self
141126 {
142- if (! File::exists ($ this ->app ->buildsPath ())) {
127+ if (!File::exists ($ this ->app ->buildsPath ())) {
143128 File::makeDirectory ($ this ->app ->buildsPath ());
144129 }
145130
@@ -158,7 +143,7 @@ private function compile(string $name): self
158143
159144 $ progressBar = tap (
160145 new ProgressBar (
161- $ this ->output ->getVerbosity () > OutputInterface::VERBOSITY_NORMAL ? new NullOutput () : $ section ,
146+ $ this ->output ->getVerbosity () > OutputInterface::VERBOSITY_NORMAL ? new NullOutput : $ section ,
162147 25
163148 )
164149 )->setProgressCharacter ("\xF0\x9F\x8D\xBA" );
@@ -206,11 +191,11 @@ private function prepare(): self
206191 $ this ->task (
207192 ' 1. Moving application to <fg=yellow>production mode</> ' ,
208193 static function () use ($ configFile , $ config ): void {
209- File::put ($ configFile , '<?php return ' .var_export ($ config , true ).'; ' .PHP_EOL );
194+ File::put ($ configFile , '<?php return ' .var_export ($ config , true ).'; ' .\ PHP_EOL );
210195 }
211196 );
212197
213- $ boxContents = json_decode (self ::$ box , true , 512 , JSON_THROW_ON_ERROR );
198+ $ boxContents = json_decode (self ::$ box , true , 512 , \ JSON_THROW_ON_ERROR );
214199 $ boxContents ['main ' ] = $ this ->getBinary ();
215200
216201 // Exclude Box binaries in output Phar
@@ -220,9 +205,9 @@ static function () use ($configFile, $config): void {
220205 $ boxContents ['blacklist ' ][] = 'vendor/laravel-zero/framework/bin/box73 ' ;
221206 $ boxContents ['blacklist ' ][] = 'vendor/laravel-zero/framework/bin/box73.bat ' ;
222207
223- File::put ($ boxFile , json_encode ($ boxContents , JSON_THROW_ON_ERROR ));
208+ File::put ($ boxFile , json_encode ($ boxContents , \ JSON_THROW_ON_ERROR ));
224209
225- File::put ($ configFile , '<?php return ' .var_export ($ config , true ).'; ' .PHP_EOL );
210+ File::put ($ configFile , '<?php return ' .var_export ($ config , true ).'; ' .\ PHP_EOL );
226211
227212 return $ this ;
228213 }
@@ -256,13 +241,13 @@ private function getBinary(): string
256241 */
257242 private function getTimeout (): ?float
258243 {
259- if (! is_numeric ($ this ->option ('timeout ' ))) {
244+ if (!is_numeric ($ this ->option ('timeout ' ))) {
260245 throw new InvalidArgumentException ('The timeout value must be a number. ' );
261246 }
262247
263248 $ timeout = (float ) $ this ->option ('timeout ' );
264249
265- return $ timeout > 0 ? $ timeout : null ;
250+ return 0 < $ timeout ? $ timeout : null ;
266251 }
267252
268253 /**
@@ -274,7 +259,7 @@ private function listenForSignals(): void
274259 {
275260 pcntl_async_signals (true );
276261
277- pcntl_signal (SIGINT , function (): void {
262+ pcntl_signal (\ SIGINT , function (): void {
278263 if (null !== self ::$ config ) {
279264 $ this ->clear ();
280265 }
0 commit comments