diff --git a/CHANGELOG.md b/CHANGELOG.md index c03bc24..c0b0225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* *Nothing* + +### Changed +* Update shlinkio coding standard to v2.4 + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* *Nothing* + + ## [5.4.0] - 2024-10-21 ### Added * Add support for `laminas/laminas-servicemanager` v4.x. diff --git a/composer.json b/composer.json index 1c0d6ee..59d80ce 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "phpunit/phpunit": "^11.3", "psr/http-factory": "^1.1", "roave/security-advisories": "dev-master", - "shlinkio/php-coding-standard": "~2.3.0", + "shlinkio/php-coding-standard": "~2.4.0", "symfony/var-dumper": "^7.1" }, "suggest": { diff --git a/src/Exception/ImportException.php b/src/Exception/ImportException.php index bd89aae..673f837 100644 --- a/src/Exception/ImportException.php +++ b/src/Exception/ImportException.php @@ -11,9 +11,9 @@ class ImportException extends RuntimeException implements ExceptionInterface { protected function __construct( string $message, - public readonly ?string $continueToken, + public readonly string|null $continueToken, int $code = 0, - ?Throwable $previous = null, + Throwable|null $previous = null, ) { parent::__construct($message, $code, $previous); } diff --git a/src/Model/ImportedShlinkOrphanVisit.php b/src/Model/ImportedShlinkOrphanVisit.php index 5664f18..56c1952 100644 --- a/src/Model/ImportedShlinkOrphanVisit.php +++ b/src/Model/ImportedShlinkOrphanVisit.php @@ -14,7 +14,7 @@ public function __construct( public readonly DateTimeInterface $date, public readonly string $visitedUrl, public readonly string $type, - public readonly ?ImportedShlinkVisitLocation $location, + public readonly ImportedShlinkVisitLocation|null $location, ) { } } diff --git a/src/Model/ImportedShlinkUrl.php b/src/Model/ImportedShlinkUrl.php index 5a1b166..d74a290 100644 --- a/src/Model/ImportedShlinkUrl.php +++ b/src/Model/ImportedShlinkUrl.php @@ -17,11 +17,11 @@ public function __construct( public readonly string $longUrl, public readonly array $tags, public readonly DateTimeInterface $createdAt, - public readonly ?string $domain, + public readonly string|null $domain, public readonly string $shortCode, - public readonly ?string $title, + public readonly string|null $title, public readonly iterable $visits = [], - public readonly ?int $visitsCount = null, + public readonly int|null $visitsCount = null, public ImportedShlinkUrlMeta $meta = new ImportedShlinkUrlMeta(), ) { } diff --git a/src/Model/ImportedShlinkUrlMeta.php b/src/Model/ImportedShlinkUrlMeta.php index 159d1f5..df07407 100644 --- a/src/Model/ImportedShlinkUrlMeta.php +++ b/src/Model/ImportedShlinkUrlMeta.php @@ -9,9 +9,9 @@ final class ImportedShlinkUrlMeta { public function __construct( - public readonly ?DateTimeInterface $validSince = null, - public readonly ?DateTimeInterface $validUntil = null, - public readonly ?int $maxVisits = null, + public readonly DateTimeInterface|null $validSince = null, + public readonly DateTimeInterface|null $validUntil = null, + public readonly int|null $maxVisits = null, ) { } } diff --git a/src/Model/ImportedShlinkVisit.php b/src/Model/ImportedShlinkVisit.php index fbcd1f5..5e2d506 100644 --- a/src/Model/ImportedShlinkVisit.php +++ b/src/Model/ImportedShlinkVisit.php @@ -12,7 +12,7 @@ public function __construct( public readonly string $referer, public readonly string $userAgent, public readonly DateTimeInterface $date, - public readonly ?ImportedShlinkVisitLocation $location, + public readonly ImportedShlinkVisitLocation|null $location, ) { } } diff --git a/src/Sources/Bitly/BitlyApiException.php b/src/Sources/Bitly/BitlyApiException.php index 0704c04..2ec6f17 100644 --- a/src/Sources/Bitly/BitlyApiException.php +++ b/src/Sources/Bitly/BitlyApiException.php @@ -11,7 +11,7 @@ class BitlyApiException extends ImportException { - public static function fromInvalidRequest(InvalidRequestException $e, ?string $continueToken = null): self + public static function fromInvalidRequest(InvalidRequestException $e, string|null $continueToken = null): self { return new self(sprintf( 'Request to Bitly API v4 to URL "%s" failed with status code "%s" and body "%s"', diff --git a/src/Sources/Bitly/BitlyApiParams.php b/src/Sources/Bitly/BitlyApiParams.php index 734c2bf..d1616b1 100644 --- a/src/Sources/Bitly/BitlyApiParams.php +++ b/src/Sources/Bitly/BitlyApiParams.php @@ -14,7 +14,7 @@ private function __construct( public readonly bool $importCustomDomains, public readonly bool $keepCreationDate, public readonly bool $ignoreArchived, - public readonly ?string $continueToken = null, + public readonly string|null $continueToken = null, ) { } diff --git a/src/Sources/Bitly/BitlyApiProgressTracker.php b/src/Sources/Bitly/BitlyApiProgressTracker.php index 450772c..e5c48ef 100644 --- a/src/Sources/Bitly/BitlyApiProgressTracker.php +++ b/src/Sources/Bitly/BitlyApiProgressTracker.php @@ -17,8 +17,8 @@ final class BitlyApiProgressTracker { private const SEPARATOR = '__'; - private ?string $lastProcessedGroup = null; - private ?string $lastProcessedUrlDate = null; + private string|null $lastProcessedGroup = null; + private string|null $lastProcessedUrlDate = null; private array $originalDecodedTokenParts = []; private DateTimeImmutable $startDate; @@ -39,7 +39,7 @@ public static function initFromParams(BitlyApiParams $params): self return $instance; } - public function initialGroup(): ?string + public function initialGroup(): string|null { return $this->originalDecodedTokenParts[0] ?? null; } @@ -64,7 +64,7 @@ public function startDate(): DateTimeImmutable return $this->startDate; } - public function generateContinueToken(): ?string + public function generateContinueToken(): string|null { if ($this->lastProcessedGroup === null) { return null; diff --git a/src/Sources/Csv/CsvImporter.php b/src/Sources/Csv/CsvImporter.php index 1760979..d66b13a 100644 --- a/src/Sources/Csv/CsvImporter.php +++ b/src/Sources/Csv/CsvImporter.php @@ -26,7 +26,7 @@ class CsvImporter implements ImporterStrategyInterface { - public function __construct(private readonly ?DateTimeInterface $date = null) + public function __construct(private readonly DateTimeInterface|null $date = null) { } @@ -83,7 +83,7 @@ private function remapRecordHeaders(array $record): array /** * @return non-empty-string|null */ - private function nonEmptyValueOrNull(array $record, string $key): ?string + private function nonEmptyValueOrNull(array $record, string $key): string|null { $value = trim($record[$key] ?? ''); return empty($value) ? null : $value; diff --git a/src/Sources/Csv/CsvParamsConsoleHelper.php b/src/Sources/Csv/CsvParamsConsoleHelper.php index 65ed9db..757bf50 100644 --- a/src/Sources/Csv/CsvParamsConsoleHelper.php +++ b/src/Sources/Csv/CsvParamsConsoleHelper.php @@ -30,7 +30,7 @@ public function requestParams(StyleInterface $io): array /** * @return resource */ - public function pathToStream(?string $value) + public function pathToStream(string|null $value) { $value = trim($value ?? ''); if ($value === '') { diff --git a/src/Sources/Shlink/ShlinkImporter.php b/src/Sources/Shlink/ShlinkImporter.php index 11c4f81..ed5cd34 100644 --- a/src/Sources/Shlink/ShlinkImporter.php +++ b/src/Sources/Shlink/ShlinkImporter.php @@ -124,7 +124,7 @@ private function mapUrls(array $urls, ShlinkParams $params): array * @throws JsonException * @throws InvalidRequestException */ - private function loadVisits(string $shortCode, ?string $domain, ShlinkParams $params, int $page): Generator + private function loadVisits(string $shortCode, string|null $domain, ShlinkParams $params, int $page): Generator { $queryString = http_build_query( ['page' => $page, 'itemsPerPage' => self::VISITS_PER_PAGE, 'domain' => $domain], diff --git a/src/Sources/Shlink/ShlinkMapper.php b/src/Sources/Shlink/ShlinkMapper.php index a8def7a..cb14a2a 100644 --- a/src/Sources/Shlink/ShlinkMapper.php +++ b/src/Sources/Shlink/ShlinkMapper.php @@ -59,7 +59,7 @@ public function mapOrphanVisit(array $visit, DateTimeInterface $fallbackDate): I ); } - private function mapVisitLocation(?array $visitLocation): ?ImportedShlinkVisitLocation + private function mapVisitLocation(array|null $visitLocation): ImportedShlinkVisitLocation|null { return $visitLocation === null ? null : new ImportedShlinkVisitLocation( $visitLocation['countryCode'] ?? '', diff --git a/src/Sources/Yourls/YourlsParams.php b/src/Sources/Yourls/YourlsParams.php index 931f083..3c2ba36 100644 --- a/src/Sources/Yourls/YourlsParams.php +++ b/src/Sources/Yourls/YourlsParams.php @@ -13,7 +13,7 @@ private function __construct( public readonly string $username, public readonly string $password, public readonly bool $importVisits, - public readonly ?string $domain, + public readonly string|null $domain, ) { } diff --git a/src/Util/DateHelper.php b/src/Util/DateHelper.php index 72a8bf2..7c07292 100644 --- a/src/Util/DateHelper.php +++ b/src/Util/DateHelper.php @@ -20,7 +20,7 @@ public static function dateFromAtom(string $atomDate): DateTimeImmutable return self::dateFromFormat(DateTimeInterface::ATOM, $atomDate); } - public static function nullableDateFromFormatWithDefault(string $format, ?string $date): DateTimeImmutable + public static function nullableDateFromFormatWithDefault(string $format, string|null $date): DateTimeImmutable { if ($date === null) { return new DateTimeImmutable(); @@ -29,7 +29,7 @@ public static function nullableDateFromFormatWithDefault(string $format, ?string return self::dateFromFormat($format, $date); } - public static function nullableDateFromAtom(?string $atomDate): ?DateTimeImmutable + public static function nullableDateFromAtom(string|null $atomDate): DateTimeImmutable|null { if ($atomDate === null) { return null; diff --git a/test/Command/ImportCommandTest.php b/test/Command/ImportCommandTest.php index bfe4336..cfc9069 100644 --- a/test/Command/ImportCommandTest.php +++ b/test/Command/ImportCommandTest.php @@ -75,7 +75,7 @@ public function exceptionIsThrownWhenInvalidSourceIsProvided(): void } #[Test, DataProvider('provideSource')] - public function dependenciesAreInvokedAsExpected(?string $providedSource, bool $expectSourceQuestion): void + public function dependenciesAreInvokedAsExpected(string|null $providedSource, bool $expectSourceQuestion): void { $source = $providedSource ?? ImportSource::BITLY->value; $params = ImportParams::fromSource(ImportSource::from($source)); diff --git a/test/Sources/Bitly/BitlyApiExceptionTest.php b/test/Sources/Bitly/BitlyApiExceptionTest.php index 03e2af1..591ddc8 100644 --- a/test/Sources/Bitly/BitlyApiExceptionTest.php +++ b/test/Sources/Bitly/BitlyApiExceptionTest.php @@ -13,7 +13,7 @@ class BitlyApiExceptionTest extends TestCase { #[Test, DataProvider('provideContinueToken')] - public function generatesExpectedMessage(?string $continueToken): void + public function generatesExpectedMessage(string|null $continueToken): void { $e = BitlyApiException::fromInvalidRequest( InvalidRequestException::fromResponseData('something.com', 500, 'Error body'), diff --git a/test/Sources/Csv/CsvParamsConsoleHelperTest.php b/test/Sources/Csv/CsvParamsConsoleHelperTest.php index 9702abd..dcac67f 100644 --- a/test/Sources/Csv/CsvParamsConsoleHelperTest.php +++ b/test/Sources/Csv/CsvParamsConsoleHelperTest.php @@ -39,7 +39,7 @@ public function requestsParams(): void } #[Test, DataProvider('provideEmptyStreamValues')] - public function pathToStreamThrowsExceptionWithInvalidValue(?string $value, string $expectedMessage): void + public function pathToStreamThrowsExceptionWithInvalidValue(string|null $value, string $expectedMessage): void { $this->expectException(InvalidPathException::class); $this->expectExceptionMessage($expectedMessage);