Skip to content

Commit 0cff0a4

Browse files
committed
Improve package coding style
1 parent c0e175d commit 0cff0a4

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

.php-cs-fixer.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111
'@PSR2' => true,
1212
'array_syntax' => ['syntax' => 'short'],
1313
'concat_space' => ['spacing' => 'none'],
14+
'global_namespace_import' => [
15+
'import_classes' => true,
16+
'import_constants' => true,
17+
'import_functions' => true,
18+
],
19+
'list_syntax' => ['syntax' => 'short'],
1420
'new_with_braces' => true,
1521
'no_blank_lines_after_phpdoc' => true,
1622
'no_empty_phpdoc' => true,
1723
'no_empty_comment' => true,
1824
'no_leading_import_slash' => true,
19-
'no_superfluous_phpdoc_tags' => true,
25+
'no_superfluous_phpdoc_tags' => [
26+
'allow_mixed' => true,
27+
'remove_inheritdoc' => true,
28+
'allow_unused_params' => false,
29+
],
2030
'no_trailing_comma_in_singleline_array' => true,
2131
'no_unused_imports' => true,
2232
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
23-
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
33+
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
2434
'phpdoc_align' => true,
2535
'phpdoc_no_empty_return' => true,
2636
'phpdoc_order' => true,
2737
'phpdoc_scalar' => true,
28-
'phpdoc_to_comment' => false,
38+
'phpdoc_to_comment' => true,
2939
'phpdoc_summary' => true,
3040
'psr_autoloading' => true,
3141
'return_type_declaration' => ['space_before' => 'none'],
@@ -36,7 +46,5 @@
3646
'trailing_comma_in_multiline' => true,
3747
'trim_array_spaces' => true,
3848
'whitespace_after_comma_in_array' => true,
39-
'yoda_style' => true,
4049
])
41-
->setFinder($finder)
42-
;
50+
->setFinder($finder);

src/DomainTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Pdp;
66

77
use PHPUnit\Framework\TestCase;
8+
use stdClass;
89
use TypeError;
910

1011
/**
@@ -314,7 +315,7 @@ public function withLabelWorksProvider(): iterable
314315
public function testWithLabelFailsWithTypeError(): void
315316
{
316317
$this->expectException(TypeError::class);
317-
Domain::fromIDNA2008('example.com')->withLabel(1, new \stdClass());
318+
Domain::fromIDNA2008('example.com')->withLabel(1, new stdClass());
318319
}
319320

320321
public function testWithLabelFailsWithInvalidKey(): void

src/Idna.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static function toAscii(string $domain, int $options): IdnaInfo
9999

100100
self::supportsIdna();
101101

102-
/** @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo */
102+
/* @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo */
103103
idn_to_ascii($domain, $options, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
104104

105105
/** @var array{result:string, isTransitionalDifferent:bool, errors:int} $idnaInfo */
@@ -124,7 +124,7 @@ public static function toUnicode(string $domain, int $options): IdnaInfo
124124

125125
self::supportsIdna();
126126

127-
/** @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo */
127+
/* @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo */
128128
idn_to_utf8($domain, $options, INTL_IDNA_VARIANT_UTS46, $idnaInfo);
129129

130130
/** @var array{result:string, isTransitionalDifferent:bool, errors:int} $idnaInfo */

src/Storage/PublicSuffixListPsr16CacheTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Pdp\Storage;
66

7+
use DateInterval;
8+
use DateTimeImmutable;
79
use InvalidArgumentException;
810
use Pdp\Rules;
911
use PHPUnit\Framework\TestCase;
@@ -54,7 +56,7 @@ public function testItReturnsNullIfTheCacheContentCannotBeConvertedToTheCorrectI
5456
$cache = $this->createStub(CacheInterface::class);
5557
$cache->method('get')->willReturn('{"foo":"bar"}');
5658

57-
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new \DateTimeImmutable('+1 DAY'));
59+
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new DateTimeImmutable('+1 DAY'));
5860

5961
self::assertNull($pslCache->fetch('http://www.example.com'));
6062
}
@@ -65,7 +67,7 @@ public function testItCanStoreAPublicSuffixListInstance(): void
6567
$cache->method('set')->willReturn(true);
6668

6769
$psl = Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
68-
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new \DateInterval('P1D'));
70+
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new DateInterval('P1D'));
6971

7072
self::assertTrue($pslCache->remember('http://www.example.com', $psl));
7173
}
@@ -76,7 +78,7 @@ public function testItReturnsFalseIfItCantStoreAPublicSuffixListInstance(): void
7678
$cache->method('set')->willReturn(false);
7779

7880
$psl = Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
79-
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new \DateInterval('P1D'));
81+
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new DateInterval('P1D'));
8082

8183
self::assertFalse($pslCache->remember('http://www.example.com', $psl));
8284
}
@@ -89,7 +91,7 @@ public function testItReturnsFalseIfItCantCacheAPublicSuffixListInstance(): void
8991
$cache->method('set')->will(self::throwException($exception));
9092

9193
$psl = Rules::fromPath(dirname(__DIR__, 2).'/test_data/public_suffix_list.dat');
92-
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new \DateInterval('P1D'));
94+
$pslCache = new PublicSuffixListPsr16Cache($cache, 'pdp_', new DateInterval('P1D'));
9395

9496
self::assertFalse($pslCache->remember('http://www.example.com', $psl));
9597
}
@@ -120,7 +122,7 @@ public function testItCanDeleteTheCachedDatabase(): void
120122
$cache = $this->createStub(CacheInterface::class);
121123
$cache->method('delete')->willReturn(true);
122124

123-
$instance = new PublicSuffixListPsr16Cache($cache, 'pdp_', new \DateInterval('P1D'));
125+
$instance = new PublicSuffixListPsr16Cache($cache, 'pdp_', new DateInterval('P1D'));
124126
self::assertTrue($instance->forget($uri));
125127
}
126128

src/TopLevelDomainList.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public function version(): string;
2424
*/
2525
public function lastUpdated(): DateTimeImmutable;
2626

27-
/**
28-
* {@inheritdoc}
29-
*/
27+
3028
public function count(): int;
3129

3230
/**

0 commit comments

Comments
 (0)