Skip to content

Commit 295b3bf

Browse files
committed
Misc. updates
1 parent 0baeb8d commit 295b3bf

File tree

9 files changed

+35
-62
lines changed

9 files changed

+35
-62
lines changed

.php-cs-fixer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
[
1515
'@PHP81Migration' => true,
1616
'@PHP80Migration:risky' => true,
17-
'@PHPUnit84Migration:risky' => true,
18-
'@PSR12' => true,
19-
'@PSR2' => true,
17+
'@PHPUnit100Migration:risky' => true,
18+
'@PER-CS' => true,
19+
'@PER-CS:risky' => true,
2020
'align_multiline_comment' => true,
2121
'array_indentation' => true,
2222
'array_syntax' => [

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"require": {
77
"php": "^8.1",
88
"fig/link-util": "^1.2",
9-
"illuminate/http": "^10.0 || ^11.0",
10-
"illuminate/support": "^10.0 || ^11.0",
9+
"illuminate/http": "^10.0 || ^11.0 || ^12.0",
10+
"illuminate/support": "^10.0 || ^11.0 || ^12.0",
1111
"psr/link": "^1.1.1 || ^2.0.1"
1212
},
1313
"require-dev": {
14-
"laravel/framework": "^10.0 || ^11.0",
15-
"orchestra/testbench": "^8.0 || ^9.0",
16-
"phpunit/phpunit": "^9.6 || ^10.0"
14+
"laravel/framework": "^10.0 || ^11.0 || ^12.0",
15+
"orchestra/testbench": "^8.0 || ^9.0 || ^10.0",
16+
"phpunit/phpunit": "^10.5 || ^11.5"
1717
},
1818
"autoload": {
1919
"psr-4": {

phpunit.xml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</testsuite>
1111
</testsuites>
1212

13-
<coverage includeUncoveredFiles="false">
13+
<source>
1414
<include>
15-
<directory suffix=".php">src/</directory>
15+
<directory>src/</directory>
1616
</include>
17-
</coverage>
17+
</source>
1818
</phpunit>

src/Http/HeaderSerializer.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public function serialize(iterable $links): ?string
2727
continue;
2828
}
2929

30-
$attributes = ['', sprintf('rel="%s"', implode(' ', $link->getRels()))];
30+
$attributes = ['', \sprintf('rel="%s"', implode(' ', $link->getRels()))];
3131

3232
foreach ($link->getAttributes() as $key => $value) {
3333
if (\is_array($value)) {
3434
foreach ($value as $v) {
35-
$attributes[] = sprintf('%s="%s"', $key, $v);
35+
$attributes[] = \sprintf('%s="%s"', $key, $v);
3636
}
3737

3838
continue;
3939
}
4040

4141
if (!\is_bool($value)) {
42-
$attributes[] = sprintf('%s="%s"', $key, $value);
42+
$attributes[] = \sprintf('%s="%s"', $key, $value);
4343

4444
continue;
4545
}
@@ -49,7 +49,7 @@ public function serialize(iterable $links): ?string
4949
}
5050
}
5151

52-
$elements[] = sprintf('<%s>%s', $link->getHref(), implode('; ', $attributes));
52+
$elements[] = \sprintf('<%s>%s', $link->getHref(), implode('; ', $attributes));
5353
}
5454

5555
return $elements ? implode(',', $elements) : null;

src/Http/Middleware/ServerPush.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ final class ServerPush
1818
*/
1919
public function __construct(
2020
private readonly PushManager $pushManager,
21-
) {
22-
}
21+
) {}
2322

2423
/**
2524
* Handle an incoming request.

src/Providers/ServerPushManagerProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function register(): void
2828
{
2929
$this->app->singleton(
3030
'babdev.push_manager',
31-
static fn () => new PushManager(),
31+
static fn() => new PushManager(),
3232
);
3333

3434
$this->app->alias('babdev.push_manager', PushManager::class);

tests/Facades/PushManagerTest.php

+8-21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use BabDev\ServerPushManager\Providers\ServerPushManagerProvider;
77
use Fig\Link\Link;
88
use Orchestra\Testbench\TestCase;
9+
use PHPUnit\Framework\Attributes\TestDox;
910

1011
final class PushManagerTest extends TestCase
1112
{
@@ -23,9 +24,7 @@ protected function getPackageAliases($app): array
2324
];
2425
}
2526

26-
/**
27-
* @testdox A Link header for the specified relations as a string is added
28-
*/
27+
#[TestDox('A Link header for the specified relations as a string is added')]
2928
public function testLinkWithStringRelations(): void
3029
{
3130
\PushManager::link('/foo.css', 'preload', ['as' => 'style', 'crossorigin' => true]);
@@ -35,9 +34,7 @@ public function testLinkWithStringRelations(): void
3534
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
3635
}
3736

38-
/**
39-
* @testdox A Link header for the specified relations as an array is added
40-
*/
37+
#[TestDox('A Link header for the specified relations as an array is added')]
4138
public function testLinkWithArrayRelations(): void
4239
{
4340
\PushManager::link('/foo.css', ['preload', 'prefetch'], ['as' => 'style', 'crossorigin' => true]);
@@ -47,9 +44,7 @@ public function testLinkWithArrayRelations(): void
4744
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
4845
}
4946

50-
/**
51-
* @testdox A Link header for the preload relation is added
52-
*/
47+
#[TestDox('A Link header for the preload relation is added')]
5348
public function testPreload(): void
5449
{
5550
\PushManager::preload('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -59,9 +54,7 @@ public function testPreload(): void
5954
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
6055
}
6156

62-
/**
63-
* @testdox A Link header for the dns-prefetch relation is added
64-
*/
57+
#[TestDox('A Link header for the dns-prefetch relation is added')]
6558
public function testDnsPrefetch(): void
6659
{
6760
\PushManager::dnsPrefetch('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -71,9 +64,7 @@ public function testDnsPrefetch(): void
7164
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
7265
}
7366

74-
/**
75-
* @testdox A Link header for the preconnect relation is added
76-
*/
67+
#[TestDox('A Link header for the preconnect relation is added')]
7768
public function testPreconnect(): void
7869
{
7970
\PushManager::preconnect('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -83,9 +74,7 @@ public function testPreconnect(): void
8374
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
8475
}
8576

86-
/**
87-
* @testdox A Link header for the prefetch relation is added
88-
*/
77+
#[TestDox('A Link header for the prefetch relation is added')]
8978
public function testPrefetch(): void
9079
{
9180
\PushManager::prefetch('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -95,9 +84,7 @@ public function testPrefetch(): void
9584
$this->assertEquals([$link], array_values(\PushManager::getLinkProvider()->getLinks()));
9685
}
9786

98-
/**
99-
* @testdox A Link header for the prerender relation is added
100-
*/
87+
#[TestDox('A Link header for the prerender relation is added')]
10188
public function testPrerender(): void
10289
{
10390
\PushManager::prerender('/foo.css', ['as' => 'style', 'crossorigin' => true]);

tests/Http/Middleware/ServerPushTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424

2525
public function testNoLinkHeaderIsAddedIfThereAreNoPushedResources(): void
2626
{
27-
$next = static fn () => new Response();
27+
$next = static fn() => new Response();
2828

2929
$request = new Request();
3030

@@ -36,7 +36,7 @@ public function testNoLinkHeaderIsAddedIfThereAreNoPushedResources(): void
3636

3737
public function testNoLinkHeaderIsAddedIfTheResponseIsARedirect(): void
3838
{
39-
$next = static fn () => new RedirectResponse('http://localhost', 301);
39+
$next = static fn() => new RedirectResponse('http://localhost', 301);
4040

4141
$request = new Request();
4242

tests/PushManagerTest.php

+8-21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use BabDev\ServerPushManager\PushManager;
66
use Fig\Link\Link;
7+
use PHPUnit\Framework\Attributes\TestDox;
78
use PHPUnit\Framework\TestCase;
89

910
final class PushManagerTest extends TestCase
@@ -15,9 +16,7 @@ protected function setUp(): void
1516
$this->manager = new PushManager();
1617
}
1718

18-
/**
19-
* @testdox A Link header for the specified relations as a string is added
20-
*/
19+
#[TestDox('A Link header for the specified relations as a string is added')]
2120
public function testLinkWithStringRelations(): void
2221
{
2322
$this->manager->link('/foo.css', 'preload', ['as' => 'style', 'crossorigin' => true]);
@@ -27,9 +26,7 @@ public function testLinkWithStringRelations(): void
2726
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
2827
}
2928

30-
/**
31-
* @testdox A Link header for the specified relations as an array is added
32-
*/
29+
#[TestDox('A Link header for the specified relations as an array is added')]
3330
public function testLinkWithArrayRelations(): void
3431
{
3532
$this->manager->link('/foo.css', ['preload', 'prefetch'], ['as' => 'style', 'crossorigin' => true]);
@@ -39,9 +36,7 @@ public function testLinkWithArrayRelations(): void
3936
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
4037
}
4138

42-
/**
43-
* @testdox A Link header for the preload relation is added
44-
*/
39+
#[TestDox('A Link header for the preload relation is added')]
4540
public function testPreload(): void
4641
{
4742
$this->manager->preload('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -51,9 +46,7 @@ public function testPreload(): void
5146
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
5247
}
5348

54-
/**
55-
* @testdox A Link header for the dns-prefetch relation is added
56-
*/
49+
#[TestDox('A Link header for the dns-prefetch relation is added')]
5750
public function testDnsPrefetch(): void
5851
{
5952
$this->manager->dnsPrefetch('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -63,9 +56,7 @@ public function testDnsPrefetch(): void
6356
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
6457
}
6558

66-
/**
67-
* @testdox A Link header for the preconnect relation is added
68-
*/
59+
#[TestDox('A Link header for the preconnect relation is added')]
6960
public function testPreconnect(): void
7061
{
7162
$this->manager->preconnect('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -75,9 +66,7 @@ public function testPreconnect(): void
7566
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
7667
}
7768

78-
/**
79-
* @testdox A Link header for the prefetch relation is added
80-
*/
69+
#[TestDox('A Link header for the prefetch relation is added')]
8170
public function testPrefetch(): void
8271
{
8372
$this->manager->prefetch('/foo.css', ['as' => 'style', 'crossorigin' => true]);
@@ -87,9 +76,7 @@ public function testPrefetch(): void
8776
$this->assertEquals([$link], array_values($this->manager->getLinkProvider()->getLinks()));
8877
}
8978

90-
/**
91-
* @testdox A Link header for the prerender relation is added
92-
*/
79+
#[TestDox('A Link header for the prerender relation is added')]
9380
public function testPrerender(): void
9481
{
9582
$this->manager->prerender('/foo.css', ['as' => 'style', 'crossorigin' => true]);

0 commit comments

Comments
 (0)