diff --git a/.php_cs b/.php_cs index ff29a34..56145ce 100644 --- a/.php_cs +++ b/.php_cs @@ -24,7 +24,7 @@ return PhpCsFixer\Config::create() 'phpdoc_no_empty_return' => true, 'phpdoc_order' => true, 'phpdoc_scalar' => true, - 'phpdoc_to_comment' => true, + 'phpdoc_to_comment' => false, 'phpdoc_summary' => true, 'psr0' => true, 'psr4' => true, diff --git a/psalm.xml b/psalm.xml index b22c0d5..ad6be53 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ + * @var array */ private array $labels; @@ -176,7 +176,7 @@ private function domainToUnicode(string $domain): string */ public function getIterator(): Iterator { - foreach ($this->labels as $offset => $label) { + foreach ($this->labels as $label) { yield $label; } } @@ -216,7 +216,7 @@ public function label(int $key): ?string } /** - * @return array + * @return list */ public function keys(string $label = null): array { @@ -228,7 +228,7 @@ public function keys(string $label = null): array } /** - * @return array + * @return array */ public function labels(): array { @@ -274,7 +274,7 @@ public function toUnicode(): self /** * Filter a subdomain to update the domain part. * - * @param string|object $domain a domain + * @param string|object|null $domain a domain * * @throws TypeError if the domain can not be converted */ diff --git a/src/DomainName.php b/src/DomainName.php index 2f45845..00496c2 100644 --- a/src/DomainName.php +++ b/src/DomainName.php @@ -36,7 +36,7 @@ public function label(int $key): ?string; /** * Returns the object labels. * - * @return array + * @return array */ public function labels(): array; @@ -63,7 +63,7 @@ public function getIterator(): Iterator; * * @see ::withLabel * - * @param mixed $label a domain label + * @param string|null|object $label a domain label */ public function prepend($label): self; @@ -72,7 +72,7 @@ public function prepend($label): self; * * @see ::withLabel * - * @param mixed $label a domain label + * @param string|null|object $label a domain label */ public function append($label): self; @@ -85,7 +85,7 @@ public function append($label): self; * If $key is non-negative, the added label will be the label at $key position from the start. * If $key is negative, the added label will be the label at $key position from the end. * - * @param mixed $label a domain label + * @param string|null|object $label a domain label * * @throws CannotProcessHost If the key is out of bounds * @throws CannotProcessHost If the label is converted to the NULL value diff --git a/src/DomainTest.php b/src/DomainTest.php index e8151db..1c32a14 100644 --- a/src/DomainTest.php +++ b/src/DomainTest.php @@ -338,7 +338,7 @@ public function testAppend(string $raw, string $append, string $expected): void } /** - * @return iterable + * @return iterable */ public function validAppend(): iterable { @@ -359,7 +359,7 @@ public function testPrepend(string $raw, string $prepend, string $expected): voi } /** - * @return iterable + * @return iterable */ public function validPrepend(): iterable { diff --git a/src/Idna.php b/src/Idna.php index 30d859b..b7096c9 100644 --- a/src/Idna.php +++ b/src/Idna.php @@ -75,9 +75,14 @@ public static function toAscii(string $domain, int $options): IdnaInfo self::supportsIdna(); + /** + * @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo + */ idn_to_ascii($domain, $options, INTL_IDNA_VARIANT_UTS46, $idnaInfo); - /* @var array{result:string, isTransitionalDifferent:bool, errors:int} $idnaInfo */ + /** + * @var array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo + */ return self::createIdnaInfo($domain, $idnaInfo); } @@ -96,9 +101,14 @@ public static function toUnicode(string $domain, int $options): IdnaInfo self::supportsIdna(); + /** + * @param-out array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo + */ idn_to_utf8($domain, $options, INTL_IDNA_VARIANT_UTS46, $idnaInfo); - /* @var array{result:string, isTransitionalDifferent:bool, errors:int} $idnaInfo */ + /** + * @var array{errors: int, isTransitionalDifferent: bool, result: string} $idnaInfo + */ return self::createIdnaInfo($domain, $idnaInfo); } diff --git a/src/ResolvedDomainTest.php b/src/ResolvedDomainTest.php index 45f1a59..5a120fd 100644 --- a/src/ResolvedDomainTest.php +++ b/src/ResolvedDomainTest.php @@ -540,7 +540,7 @@ public function testWithSecondLevelDomain( } /** - * @return iterable + * @return iterable */ public function withSldWorksProvider(): iterable { diff --git a/src/Rules.php b/src/Rules.php index 81b3ca2..6186f5a 100644 --- a/src/Rules.php +++ b/src/Rules.php @@ -157,7 +157,9 @@ private static function addRule(array $list, array $ruleParts): array $list[$rule] = $list[$rule] ?? ($isDomain ? [] : ['!' => '']); if ($isDomain && [] !== $ruleParts) { - $list[$rule] = self::addRule($list[$rule], $ruleParts); + /** @var array $tmpList */ + $tmpList = $list[$rule]; + $list[$rule] = self::addRule($tmpList, $ruleParts); } return $list; @@ -307,6 +309,7 @@ private function getEffectiveTopLevelDomainFromSection(DomainName $domain, strin } $matches[] = $label; + /** @var array $rules */ $rules = $rules[$label]; } diff --git a/src/Storage/TimeToLive.php b/src/Storage/TimeToLive.php index 673a8f7..41b4682 100644 --- a/src/Storage/TimeToLive.php +++ b/src/Storage/TimeToLive.php @@ -58,10 +58,7 @@ public static function fromNow(DateTimeInterface $date): DateInterval $now = new DateTimeImmutable('NOW', $timezone); - /** @var DateInterval $diff */ - $diff = $now->diff($date, false); - - return $diff; + return $now->diff($date, false); } /** diff --git a/src/TopLevelDomains.php b/src/TopLevelDomains.php index 9974088..4623ad0 100644 --- a/src/TopLevelDomains.php +++ b/src/TopLevelDomains.php @@ -186,7 +186,7 @@ public function isEmpty(): bool */ public function getIterator(): Iterator { - foreach ($this->records as $tld => $int) { + foreach ($this->records as $tld => $_) { yield $tld; } }