Skip to content

Commit f292925

Browse files
committed
fix publicUrl nullability
1 parent 9c7e777 commit f292925

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/DI/WebpackExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function loadConfiguration(): void
9797
->setFactory(DevServer::class, [
9898
$config['devServer']['enabled'],
9999
$config['devServer']['url'] ?? '',
100-
$config['devServer']['publicUrl'] ?? '',
100+
$config['devServer']['publicUrl'],
101101
$config['devServer']['timeout'],
102102
new Statement(Client::class),
103103
]);

src/DevServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DevServer
2727
private $url;
2828

2929
/**
30-
* @var string
30+
* @var ?string
3131
*/
3232
private $publicUrl;
3333

@@ -42,7 +42,7 @@ class DevServer
4242
private $httpClient;
4343

4444

45-
public function __construct(bool $enabled, string $url, string $publicUrl, float $timeout, ClientInterface $httpClient)
45+
public function __construct(bool $enabled, string $url, ?string $publicUrl, float $timeout, ClientInterface $httpClient)
4646
{
4747
$this->enabled = $enabled;
4848
$this->url = $url;

tests/WebpackNetteAdapter/DevServerTest.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class DevServerTest extends TestCase
3838

3939
public function testDevServer(): void
4040
{
41-
$devServer = new DevServer(TRUE, 'http://localhost:3000', '', 0.1, $this->httpClient);
41+
$devServer = new DevServer(TRUE, 'http://localhost:3000', NULL, 0.1, $this->httpClient);
4242
Assert::true($devServer->isEnabled());
43+
Assert::same($devServer->getUrl(), 'http://localhost:3000');
4344

4445
$this->httpClient->shouldReceive('request')
4546
->with('GET', 'http://localhost:3000', ['http_errors' => FALSE, 'verify' => FALSE, 'timeout' => 0.1])
@@ -64,7 +65,7 @@ class DevServerTest extends TestCase
6465

6566
public function testUnavailable(): void
6667
{
67-
$devServer = new DevServer(TRUE, 'http://localhost:3000', '', 0.5, $this->httpClient);
68+
$devServer = new DevServer(TRUE, 'http://localhost:3000', NULL, 0.5, $this->httpClient);
6869
Assert::true($devServer->isEnabled());
6970

7071
$this->httpClient->shouldReceive('request')
@@ -76,7 +77,7 @@ class DevServerTest extends TestCase
7677

7778
public function testDisabled(): void
7879
{
79-
$devServer = new DevServer(FALSE, 'http://localhost:3000', '', 0.1, $this->httpClient);
80+
$devServer = new DevServer(FALSE, 'http://localhost:3000', NULL, 0.1, $this->httpClient);
8081
Assert::false($devServer->isEnabled());
8182
Assert::false($devServer->isAvailable());
8283
}

0 commit comments

Comments
 (0)