From e656c6e4719bd915cada6db927c7287b5fe35f02 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Tue, 12 Nov 2024 14:13:10 +0000 Subject: [PATCH] Apply fixes from StyleCI --- packages/framework/src/Console/Commands/ServeCommand.php | 6 ++++-- .../framework/tests/Feature/Commands/ServeCommandTest.php | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Console/Commands/ServeCommand.php b/packages/framework/src/Console/Commands/ServeCommand.php index a56b691329c..248ab4431aa 100644 --- a/packages/framework/src/Console/Commands/ServeCommand.php +++ b/packages/framework/src/Console/Commands/ServeCommand.php @@ -193,9 +193,9 @@ protected function getOpenCommand(string $osFamily): ?string protected function runViteProcess(): void { - if (!$this->isPortAvailable(5173)) { + if (! $this->isPortAvailable(5173)) { throw new InvalidArgumentException( - 'Unable to start Vite server: Port 5173 is already in use. ' . + 'Unable to start Vite server: Port 5173 is already in use. '. 'Please stop any other Vite processes and try again.' ); } @@ -208,8 +208,10 @@ protected function isPortAvailable(int $port): bool $socket = @fsockopen('localhost', $port, $errno, $errstr, 1); if ($socket !== false) { fclose($socket); + return false; } + return true; } } diff --git a/packages/framework/tests/Feature/Commands/ServeCommandTest.php b/packages/framework/tests/Feature/Commands/ServeCommandTest.php index 50f89d53add..8e321328099 100644 --- a/packages/framework/tests/Feature/Commands/ServeCommandTest.php +++ b/packages/framework/tests/Feature/Commands/ServeCommandTest.php @@ -10,7 +10,6 @@ use Illuminate\Contracts\Process\InvokedProcess; use Illuminate\Support\Facades\Process; use TypeError; -use InvalidArgumentException; /** * @covers \Hyde\Console\Commands\ServeCommand @@ -269,7 +268,7 @@ public function testHydeServeCommandWithViteOptionButViteNotRunning() public function testHydeServeCommandWithViteOptionThrowsWhenPortIsInUse() { $socket = stream_socket_server('tcp://127.0.0.1:5173'); - + $this->artisan('serve --vite') ->expectsOutputToContain('Unable to start Vite server: Port 5173 is already in use') ->assertExitCode(1);