Skip to content

Commit 9319e5b

Browse files
committed
Improve codebase against PHPStan results
1 parent 4560167 commit 9319e5b

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

phpstan.src.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ parameters:
66
ignoreErrors:
77
- message: '#Call to function is_iterable\(\) with iterable will always evaluate to true.#'
88
path: src/Cache.php
9+
- message: '#Call to function is_string\(\) with string will always evaluate to true.#'
10+
path: src/Cache.php
11+
- message: '#Call to function is_object\(\) with \*NEVER\* will always evaluate to true.#'
12+
path: src/Cache.php
13+
- message: '#Else branch is unreachable because ternary operator condition is always true.#'
14+
path: src/Cache.php
915
- message: '#Property Pdp\\TopLevelDomains::\$modifiedDate \(DateTimeImmutable\) does not accept DateTimeInterface.#'
1016
path: src/TopLevelDomains.php
1117
reportUnmatchedIgnoredErrors: true

src/Domain.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,16 @@ private function normalize(PublicSuffix $subject): PublicSuffix
187187
}
188188

189189
if (1 !== preg_match(self::REGEXP_IDN_PATTERN, $this->domain)) {
190-
return $subject->toAscii();
190+
/** @var PublicSuffix $result */
191+
$result = $subject->toAscii();
192+
193+
return $result;
191194
}
192195

193-
return $subject->toUnicode();
196+
/** @var PublicSuffix $result */
197+
$result = $subject->toUnicode();
198+
199+
return $result;
194200
}
195201

196202
/**

tests/DomainTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use const IDNA_NONTRANSITIONAL_TO_UNICODE;
3131

3232
/**
33-
* @coversDefaultClass Pdp\Domain
33+
* @coversDefaultClass \Pdp\Domain
3434
*/
3535
class DomainTest extends TestCase
3636
{
@@ -239,6 +239,7 @@ public function testToIDN(
239239
self::assertSame($expectedDomain, $domain->getDomain());
240240
self::assertSame($expectedSuffix, $domain->getPublicSuffix());
241241

242+
/** @var Domain $domainIDN */
242243
$domainIDN = $domain->toUnicode();
243244
self::assertSame($expectedIDNDomain, $domainIDN->getDomain());
244245
self::assertSame($expectedIDNSuffix, $domainIDN->getPublicSuffix());
@@ -339,6 +340,7 @@ public function testToAscii(
339340
self::assertSame($expectedDomain, $domain->getDomain());
340341
self::assertSame($expectedSuffix, $domain->getPublicSuffix());
341342

343+
/** @var Domain $domainIDN */
342344
$domainIDN = $domain->toAscii();
343345
self::assertSame($expectedAsciiDomain, $domainIDN->getDomain());
344346
self::assertSame($expectedAsciiSuffix, $domainIDN->getPublicSuffix());
@@ -1114,11 +1116,13 @@ public function testInstanceCreationWithCustomIDNAOptions(): void
11141116
IDNA_NONTRANSITIONAL_TO_UNICODE
11151117
);
11161118

1119+
/** @var Domain $instance */
11171120
$instance = $domain->toAscii();
11181121
self::assertSame(
11191122
[$domain->getAsciiIDNAOption(), $domain->getUnicodeIDNAOption()],
11201123
[$instance->getAsciiIDNAOption(), $instance->getUnicodeIDNAOption()]
11211124
);
1125+
/** @var Domain $instance */
11221126
$instance = $domain->toUnicode();
11231127
self::assertSame(
11241128
[$domain->getAsciiIDNAOption(), $domain->getUnicodeIDNAOption()],

tests/PublicSuffixTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public function testResolveWithCustomIDNAOptions(
299299
self::assertSame($expectedContent, $publicSuffix->getContent());
300300
self::assertSame($expectedAscii, $publicSuffix->toAscii()->getContent());
301301
self::assertSame($expectedUnicode, $publicSuffix->toUnicode()->getContent());
302+
/** @var PublicSuffix $instance */
302303
$instance = $publicSuffix->toUnicode();
303304
self::assertSame(
304305
[$publicSuffix->getAsciiIDNAOption(), $publicSuffix->getUnicodeIDNAOption()],

0 commit comments

Comments
 (0)