Skip to content

Commit

Permalink
Merge pull request #210 from netglue/dcs-10
Browse files Browse the repository at this point in the history
Update doctrine coding standard to ^10.0
  • Loading branch information
gsteel authored Aug 29, 2022
2 parents e8692a7 + 153b6cb commit 8001d37
Show file tree
Hide file tree
Showing 55 changed files with 294 additions and 446 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"require-dev": {
"ext-curl": "*",
"doctrine/coding-standard": "^9.0",
"doctrine/coding-standard": "^10.0",
"laminas/laminas-diactoros": "^2.13.0",
"maglnet/composer-require-checker": "^3.8.0",
"php-http/cache-plugin": "^1.7",
Expand All @@ -56,7 +56,7 @@
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/cache": "^5.4 || ^6.0.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"vimeo/psalm": "^4.24.0"
"vimeo/psalm": "^4.26.0"
},
"scripts": {
"check": [
Expand Down
286 changes: 112 additions & 174 deletions composer.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ public static function get(
$apiBaseUri,
$httpClient ?? self::psrFactory(
ClientInterface::class,
'An HTTP client cannot be determined.'
'An HTTP client cannot be determined.',
),
(string) $accessToken === '' ? null : $accessToken,
$requestFactory ?? self::psrFactory(
RequestFactoryInterface::class,
'A request factory cannot be determined'
'A request factory cannot be determined',
),
$uriFactory ?? self::psrFactory(
UriFactoryInterface::class,
'A URI factory cannot be determined'
'A URI factory cannot be determined',
),
$resultSetFactory ?? new StandardResultSetFactory(),
$cache
$cache,
);
}

Expand Down Expand Up @@ -168,14 +168,14 @@ private static function psrFactory(string $type, string $message)
default:
throw new InvalidArgument(sprintf(
'Invalid class-string: "%s"',
$type
$type,
));
}
} catch (DiscoveryError $error) {
throw new RuntimeError(
$message,
(int) $error->getCode(),
$error
$error,
);
}
}
Expand Down Expand Up @@ -220,7 +220,7 @@ private function jsonResponse(UriInterface $uri, string $method = 'GET'): object
throw new RuntimeError(
sprintf('The caching library in use threw an exception for the cache key: %s', $cacheKey),
500,
$e
$e,
);
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public function createQuery(string $form = self::DEFAULT_FORM): Query
public function query(Query $query): ResultSet
{
return $this->resultSetFactory->withJsonObject($this->jsonResponse(
$this->uriFactory->createUri($query->toUrl())
$this->uriFactory->createUri($query->toUrl()),
));
}

Expand Down Expand Up @@ -392,7 +392,7 @@ private function previewRef(): ?Ref
'preview',
$cookiePayload,
'Preview',
false
false,
);
}

Expand Down Expand Up @@ -469,7 +469,7 @@ public function next(ResultSet $resultSet): ?ResultSet
}

return $this->resultSetFactory->withJsonObject(
$this->jsonResponse($uri)
$this->jsonResponse($uri),
);
}

Expand All @@ -486,7 +486,7 @@ public function previous(ResultSet $resultSet): ?ResultSet
}

return $this->resultSetFactory->withJsonObject(
$this->jsonResponse($uri)
$this->jsonResponse($uri),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Document/Fragment/BaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function filter(Closure $p): self
$result = array_filter($this->fragments, $p, ARRAY_FILTER_USE_BOTH);

return new static(
$this->isHash($result) ? $result : array_values($result)
$this->isHash($result) ? $result : array_values($result),
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Document/Fragment/DateFragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
use Prismic\Document\Fragment;
use Prismic\Exception\InvalidArgument;

/**
* @psalm-immutable
*/
/** @psalm-immutable */
final class DateFragment extends DateTimeImmutable implements Fragment
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Document/Fragment/DocumentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function withDocument(Document $document): self
$document->type(),
$document->lang(),
false,
$document->tags()
$document->tags(),
);
}

Expand Down
8 changes: 2 additions & 6 deletions src/Document/Fragment/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,10 @@ private function setAttributes(iterable $attributes): void
}
}

/**
* @param scalar|null $value
*/
/** @param scalar|null $value */
private function setAttribute(string $name, $value): void
{
/**
* @psalm-suppress DocblockTypeContradiction
*/
/** @psalm-suppress DocblockTypeContradiction */
if ($value !== null && ! is_scalar($value)) {
throw InvalidArgument::scalarExpected($value);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Document/Fragment/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static function objectFactory(object $data): Fragment
if (property_exists($data, 'latitude')) {
return GeoPoint::new(
self::assertObjectPropertyIsFloaty($data, 'latitude'),
self::assertObjectPropertyIsFloaty($data, 'longitude')
self::assertObjectPropertyIsFloaty($data, 'longitude'),
);
}

Expand Down Expand Up @@ -165,7 +165,7 @@ private static function imageFactory(object $data, string $name = 'main'): Image
self::optionalStringProperty($data, 'alt'),
self::optionalStringProperty($data, 'copyright'),
$views,
$linkTo
$linkTo,
);
}

Expand All @@ -176,7 +176,7 @@ private static function linkFactory(object $data): Link
if ($type === 'Web') {
return WebLink::new(
self::assertObjectPropertyIsString($data, 'url'),
self::optionalStringProperty($data, 'target')
self::optionalStringProperty($data, 'target'),
);
}

Expand Down Expand Up @@ -212,7 +212,7 @@ private static function linkFactory(object $data): Link
self::assertObjectPropertyIsString($data, 'type'),
$lang,
$isBroken,
self::assertObjectPropertyAllString($data, 'tags')
self::assertObjectPropertyAllString($data, 'tags'),
);
}

Expand All @@ -235,7 +235,7 @@ private static function embedFactory(object $data): Fragment
self::optionalStringProperty($data, 'html'),
self::optionalIntegerPropertyOrNull($data, 'width'),
self::optionalIntegerPropertyOrNull($data, 'height'),
$scalars
$scalars,
);
}

Expand All @@ -254,7 +254,7 @@ private static function sliceFactory(object $data): Fragment
self::assertObjectPropertyIsString($data, 'slice_type'),
self::optionalStringProperty($data, 'slice_label'),
$primary,
$items
$items,
);
}

Expand All @@ -266,7 +266,7 @@ private static function textElementFactory(object $data): Fragment
array_map(static function (object $span): Span {
return self::spanFactory($span);
}, self::assertObjectPropertyIsArray($data, 'spans')),
self::optionalStringProperty($data, 'label')
self::optionalStringProperty($data, 'label'),
);
}

Expand All @@ -286,7 +286,7 @@ private static function spanFactory(object $data): Span
self::assertObjectPropertyIsInteger($data, 'start'),
self::assertObjectPropertyIsInteger($data, 'end'),
$label,
$link
$link,
);
}

Expand Down
8 changes: 2 additions & 6 deletions src/Document/Fragment/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
use function array_keys;
use function count;

/**
* @template-implements IteratorAggregate<string, Image>
*/
/** @template-implements IteratorAggregate<string, Image> */
final class Image implements Fragment, IteratorAggregate, Countable
{
/** @var string */
Expand Down Expand Up @@ -135,9 +133,7 @@ public function linkTo(): ?Link
return $this->link;
}

/**
* @return Traversable<string, self>
*/
/** @return Traversable<string, self> */
public function getIterator(): Traversable
{
return new ArrayIterator($this->views);
Expand Down
2 changes: 1 addition & 1 deletion src/Document/Fragment/TextElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function new(
$type,
$text ?? '',
$spans,
$label
$label,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/AuthenticationError.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function with(RequestInterface $request, ResponseInterface $respon
$response->getStatusCode(),
$response->getReasonPhrase(),
$request->getUri()->getHost(),
$url
$url,
), $response->getStatusCode());
$error->request = $request;
$error->response = $response;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ImageViewNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function withNameAndImage(string $name, Image $image): self
return new self(sprintf(
'The image view "%s" does not exist. Known view names are: %s',
$name,
implode(', ', $image->knownViews())
implode(', ', $image->knownViews()),
));
}
}
14 changes: 7 additions & 7 deletions src/Exception/InvalidArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function scalarExpected($received): self
{
return new self(sprintf(
'A scalar argument was expected but %s was received',
is_object($received) ? get_class($received) : gettype($received)
is_object($received) ? get_class($received) : gettype($received),
));
}

Expand All @@ -29,15 +29,15 @@ public static function numberExpected($received): self
{
return new self(sprintf(
'Either a float or an integer was expected but %s was received',
is_object($received) ? get_class($received) : gettype($received)
is_object($received) ? get_class($received) : gettype($received),
));
}

public static function invalidColor(string $value): self
{
return new self(sprintf(
'Expected a string that looks like a hex colour with a # prefix but received "%s"',
$value
$value,
));
}

Expand All @@ -46,7 +46,7 @@ public static function invalidDateFormat(string $expectedFormat, string $value):
return new self(sprintf(
'Expected a date value in the format %s but received "%s"',
$expectedFormat,
$value
$value,
));
}

Expand All @@ -55,7 +55,7 @@ public static function unknownLinkType(string $type, object $payload): self
return new self(sprintf(
'The link type "%s" is not a known type of link. Found in the object: %s',
$type,
Json::encode($payload)
Json::encode($payload),
));
}

Expand All @@ -65,7 +65,7 @@ public static function fieldExpectsString(FormField $field, $invalidValue): self
return new self(sprintf(
'The form field "%s" expects a string value but received %s',
$field->name(),
is_object($invalidValue) ? get_class($invalidValue) : gettype($invalidValue)
is_object($invalidValue) ? get_class($invalidValue) : gettype($invalidValue),
));
}

Expand All @@ -75,7 +75,7 @@ public static function fieldExpectsNumber(FormField $field, $invalidValue): self
return new self(sprintf(
'The form field "%s" expects an integer value but received %s',
$field->name(),
is_object($invalidValue) ? get_class($invalidValue) : gettype($invalidValue)
is_object($invalidValue) ? get_class($invalidValue) : gettype($invalidValue),
));
}
}
2 changes: 1 addition & 1 deletion src/Exception/InvalidPreviewToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function mismatchedPreviewHost(UriInterface $apiUri, UriInterface
return new self(sprintf(
'The preview url has been rejected because its host name "%s" does not match the api host "%s"',
$previewUri->getHost(),
$apiUri->getHost()
$apiUri->getHost(),
));
}

Expand Down
12 changes: 6 additions & 6 deletions src/Exception/JsonError.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public static function unserializeFailed(JsonException $exception, string $paylo
$error = new self(
sprintf(
'Failed to decode JSON payload: %s',
$exception->getMessage()
$exception->getMessage(),
),
(int) $exception->getCode(),
$exception
$exception,
);

$error->payload = $payload;
Expand All @@ -34,26 +34,26 @@ public static function serializeFailed(JsonException $exception): self
return new self(
sprintf(
'Failed to encode the given data to a JSON string: %s',
$exception->getMessage()
$exception->getMessage(),
),
(int) $exception->getCode(),
$exception
$exception,
);
}

public static function cannotUnserializeToObject(string $payload): self
{
return new self(sprintf(
'The given payload cannot be unserialized as an object: %s',
$payload
$payload,
));
}

public static function cannotUnserializeToArray(string $payload): self
{
return new self(sprintf(
'The given payload cannot be unserialized as an array: %s',
$payload
$payload,
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/PreviewTokenExpired.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function with(RequestInterface $request, ResponseInterface $respon
{
$error = new self(sprintf(
'Error %d. The preview token provided has expired',
$response->getStatusCode()
$response->getStatusCode(),
), $response->getStatusCode());
$error->request = $request;
$error->response = $response;
Expand Down
Loading

0 comments on commit 8001d37

Please sign in to comment.