Skip to content

Commit 2d73471

Browse files
committed
Improve coding style
1 parent e54b063 commit 2d73471

19 files changed

+59
-41
lines changed

src/Idna.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
namespace Pdp;
66

77
use UnexpectedValueException;
8+
89
use function defined;
910
use function function_exists;
1011
use function idn_to_ascii;
1112
use function idn_to_utf8;
1213
use function preg_match;
1314
use function rawurldecode;
1415
use function strtolower;
16+
1517
use const INTL_IDNA_VARIANT_UTS46;
1618

1719
/**

src/IdnaInfo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Pdp;
66

77
use function array_filter;
8+
89
use const ARRAY_FILTER_USE_KEY;
910

1011
/**

src/IdnaInfoTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Pdp;
66

77
use PHPUnit\Framework\TestCase;
8+
89
use function var_export;
910

1011
final class IdnaInfoTest extends TestCase

src/PublicSuffixList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ interface PublicSuffixList extends DomainNameResolver
99
/**
1010
* Returns PSL info for a given domain against the PSL rules for cookie domain detection.
1111
*
12-
* @throws SyntaxError if the domain is invalid
12+
* @throws SyntaxError if the domain is invalid
1313
* @throws UnableToResolveDomain if the effective TLD can not be resolved
1414
*/
1515
public function getCookieDomain(Host $host): ResolvedDomainName;
1616

1717
/**
1818
* Returns PSL info for a given domain against the PSL rules for ICANN domain detection.
1919
*
20-
* @throws SyntaxError if the domain is invalid
20+
* @throws SyntaxError if the domain is invalid
2121
* @throws UnableToResolveDomain if the domain does not contain a ICANN Effective TLD
2222
*/
2323
public function getICANNDomain(Host $host): ResolvedDomainName;
2424

2525
/**
2626
* Returns PSL info for a given domain against the PSL rules for private domain detection.
2727
*
28-
* @throws SyntaxError if the domain is invalid
28+
* @throws SyntaxError if the domain is invalid
2929
* @throws UnableToResolveDomain if the domain does not contain a private Effective TLD
3030
*/
3131
public function getPrivateDomain(Host $host): ResolvedDomainName;

src/Storage/PublicSuffixListPsr16Cache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Psr\SimpleCache\CacheInterface;
1212
use Stringable;
1313
use Throwable;
14+
1415
use function md5;
1516
use function strtolower;
1617

src/Storage/PublicSuffixListPsr16CacheTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Psr\SimpleCache\CacheException;
1414
use Psr\SimpleCache\CacheInterface;
1515
use RuntimeException;
16+
1617
use function dirname;
1718

1819
final class PublicSuffixListPsr16CacheTest extends TestCase
@@ -81,7 +82,7 @@ public function testItReturnsFalseIfItCantStoreAPublicSuffixListInstance(): void
8182

8283
public function testItReturnsFalseIfItCantCacheAPublicSuffixListInstance(): void
8384
{
84-
$exception = new class('Something went wrong.', 0) extends RuntimeException implements CacheException {
85+
$exception = new class ('Something went wrong.', 0) extends RuntimeException implements CacheException {
8586
};
8687
$cache = self::createStub(CacheInterface::class);
8788
$cache->method('set')->will(self::throwException($exception));
@@ -94,13 +95,13 @@ public function testItReturnsFalseIfItCantCacheAPublicSuffixListInstance(): void
9495

9596
public function testItWillThrowIfItCantCacheAPublicSuffixListInstance(): void
9697
{
97-
$exception = new class('Something went wrong.', 0) extends RuntimeException {
98+
$exception = new class ('Something went wrong.', 0) extends RuntimeException {
9899
};
99100
$cache = self::createStub(CacheInterface::class);
100101
$cache->method('set')->will(self::throwException($exception));
101102

102103
$psl = Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
103-
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new class() {
104+
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new class () {
104105
public function __toString(): string
105106
{
106107
return '1 DAY';

src/Storage/PublicSuffixListPsr18ClientTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
use Psr\Http\Message\RequestFactoryInterface;
1515
use Psr\Http\Message\RequestInterface;
1616
use Psr\Http\Message\ResponseInterface;
17+
1718
use function dirname;
1819
use function file_get_contents;
1920

2021
final class PublicSuffixListPsr18ClientTest extends TestCase
2122
{
2223
public function testIsCanReturnAPublicSuffixListInstance(): void
2324
{
24-
$client = new class() implements ClientInterface {
25+
$client = new class () implements ClientInterface {
2526
public function sendRequest(RequestInterface $request): ResponseInterface
2627
{
2728
/** @var string $body */
@@ -30,7 +31,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface
3031
}
3132
};
3233

33-
$requestFactory = new class() implements RequestFactoryInterface {
34+
$requestFactory = new class () implements RequestFactoryInterface {
3435
public function createRequest(string $method, $uri): RequestInterface
3536
{
3637
return new Request($method, $uri);
@@ -45,14 +46,14 @@ public function createRequest(string $method, $uri): RequestInterface
4546

4647
public function testItWillThrowIfTheClientCanNotConnectToTheRemoteURI(): void
4748
{
48-
$client = new class() implements ClientInterface {
49+
$client = new class () implements ClientInterface {
4950
public function sendRequest(RequestInterface $request): ResponseInterface
5051
{
5152
throw new ConnectException('foobar', $request, null);
5253
}
5354
};
5455

55-
$requestFactory = new class() implements RequestFactoryInterface {
56+
$requestFactory = new class () implements RequestFactoryInterface {
5657
public function createRequest(string $method, $uri): RequestInterface
5758
{
5859
return new Request($method, $uri);
@@ -68,14 +69,14 @@ public function createRequest(string $method, $uri): RequestInterface
6869

6970
public function testItWillThrowIfTheReturnedStatusCodeIsNotOK(): void
7071
{
71-
$client = new class() implements ClientInterface {
72+
$client = new class () implements ClientInterface {
7273
public function sendRequest(RequestInterface $request): ResponseInterface
7374
{
7475
return new Response(404);
7576
}
7677
};
7778

78-
$requestFactory = new class() implements RequestFactoryInterface {
79+
$requestFactory = new class () implements RequestFactoryInterface {
7980
public function createRequest(string $method, $uri): RequestInterface
8081
{
8182
return new Request($method, $uri);

src/Storage/RulesStorageTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
use Pdp\PublicSuffixList;
88
use Pdp\Rules;
99
use PHPUnit\Framework\TestCase;
10+
1011
use function dirname;
1112

1213
final class RulesStorageTest extends TestCase
1314
{
1415
public function testIsCanReturnAPublicSuffixListInstanceFromCache(): void
1516
{
16-
$cache = new class() implements PublicSuffixListCache {
17+
$cache = new class () implements PublicSuffixListCache {
1718
public function fetch(string $uri): ?PublicSuffixList
1819
{
1920
return Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
@@ -30,7 +31,7 @@ public function forget(string $uri): bool
3031
}
3132
};
3233

33-
$client = new class() implements PublicSuffixListClient {
34+
$client = new class () implements PublicSuffixListClient {
3435
public function get(string $uri): PublicSuffixList
3536
{
3637
return Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
@@ -45,7 +46,7 @@ public function get(string $uri): PublicSuffixList
4546

4647
public function testIsCanReturnAPublicSuffixListInstanceFromTheInnerStorage(): void
4748
{
48-
$cache = new class() implements PublicSuffixListCache {
49+
$cache = new class () implements PublicSuffixListCache {
4950
public function fetch(string $uri): ?PublicSuffixList
5051
{
5152
return null;
@@ -62,7 +63,7 @@ public function forget(string $uri): bool
6263
}
6364
};
6465

65-
$client = new class() implements PublicSuffixListClient {
66+
$client = new class () implements PublicSuffixListClient {
6667
public function get(string $uri): PublicSuffixList
6768
{
6869
return Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
@@ -77,7 +78,7 @@ public function get(string $uri): PublicSuffixList
7778

7879
public function testIsCanDeleteAPublicSuffixListInstanceFromTheInnerStorage(): void
7980
{
80-
$cache = new class() implements PublicSuffixListCache {
81+
$cache = new class () implements PublicSuffixListCache {
8182
public function fetch(string $uri): ?PublicSuffixList
8283
{
8384
return null;
@@ -94,7 +95,7 @@ public function forget(string $uri): bool
9495
}
9596
};
9697

97-
$client = new class() implements PublicSuffixListClient {
98+
$client = new class () implements PublicSuffixListClient {
9899
public function get(string $uri): PublicSuffixList
99100
{
100101
return Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');

src/Storage/TimeToLive.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use InvalidArgumentException;
1111
use Stringable;
1212
use Throwable;
13+
1314
use function filter_var;
15+
1416
use const FILTER_VALIDATE_INT;
1517

1618
/**

src/Storage/TimeToLiveTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function validDurationInt(): iterable
7676
];
7777

7878
yield 'stringable object' => [
79-
'input' => new class() {
79+
'input' => new class () {
8080
public function __toString(): string
8181
{
8282
return '2345';

0 commit comments

Comments
 (0)