Skip to content

Commit

Permalink
Update to PHP coding standard 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Oct 28, 2024
1 parent 5e24443 commit b006ca2
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 28 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/ImportException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ImportedShlinkOrphanVisit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}
}
6 changes: 3 additions & 3 deletions src/Model/ImportedShlinkUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
) {
}
Expand Down
6 changes: 3 additions & 3 deletions src/Model/ImportedShlinkUrlMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}
}
2 changes: 1 addition & 1 deletion src/Model/ImportedShlinkVisit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}
}
2 changes: 1 addition & 1 deletion src/Sources/Bitly/BitlyApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"',
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/Bitly/BitlyApiParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/Sources/Bitly/BitlyApiProgressTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Sources/Csv/CsvImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/Csv/CsvParamsConsoleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/Shlink/ShlinkImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/Shlink/ShlinkMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? '',
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/Yourls/YourlsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Util/DateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/Command/ImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion test/Sources/Bitly/BitlyApiExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion test/Sources/Csv/CsvParamsConsoleHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b006ca2

Please sign in to comment.