From beff30155e0378990b0592b5116b10deff6fed52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Glawaty?= Date: Thu, 29 Aug 2024 06:58:59 +0200 Subject: [PATCH] Fixed PHPStan --- src/Expression/ExpressionParser.php | 18 +++++++----------- src/Http/Cache/CacheControlHeader.php | 4 ++-- src/Renderer/Options.php | 5 +++++ .../BannersResponseHydratorHandler.php | 1 + src/Response/ValueObject/Position.php | 3 ++- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Expression/ExpressionParser.php b/src/Expression/ExpressionParser.php index 06179ba..a58d829 100644 --- a/src/Expression/ExpressionParser.php +++ b/src/Expression/ExpressionParser.php @@ -33,14 +33,10 @@ public function parseExpression(string $expression): ParsedExpression continue; } - $value = $matches['VALUE'] ?? null; - - if (null === $value) { - continue; - } + $value = $matches['VALUE']; switch (true) { - case '' !== ($matches['INTERVAL_FROM'] ?? '') && '' !== ($matches['INTERVAL_TO'] ?? ''): + case '' !== $matches['INTERVAL_FROM'] && '' !== $matches['INTERVAL_TO']: $rules[] = ExpressionRule::range( (int) $matches['INTERVAL_FROM'], (int) $matches['INTERVAL_TO'], @@ -48,35 +44,35 @@ public function parseExpression(string $expression): ParsedExpression ); break; - case '' !== ($matches['EQ'] ?? ''): + case '' !== $matches['EQ']: $rules[] = ExpressionRule::eq( (int) $matches['EQ'], $value, ); break; - case '' !== ($matches['LT'] ?? ''): + case '' !== $matches['LT']: $rules[] = ExpressionRule::lt( (int) $matches['LT'], $value, ); break; - case '' !== ($matches['LTE'] ?? ''): + case '' !== $matches['LTE']: $rules[] = ExpressionRule::lte( (int) $matches['LTE'], $value, ); break; - case '' !== ($matches['GT'] ?? ''): + case '' !== $matches['GT']: $rules[] = ExpressionRule::gt( (int) $matches['GT'], $value, ); break; - case '' !== ($matches['GTE'] ?? ''): + case '' !== $matches['GTE']: $rules[] = ExpressionRule::gte( (int) $matches['GTE'], $value, diff --git a/src/Http/Cache/CacheControlHeader.php b/src/Http/Cache/CacheControlHeader.php index 43d8bf9..9b341ad 100644 --- a/src/Http/Cache/CacheControlHeader.php +++ b/src/Http/Cache/CacheControlHeader.php @@ -27,9 +27,9 @@ public function __construct(array $values) foreach ($matches as $match) { $val = ''; if (count($match) == 3) { - $val = $match[2]; + $val = $match[2]; # @phpstan-ignore-line } elseif (count($match) > 3) { - $val = $match[3]; + $val = $match[3]; # @phpstan-ignore-line } $this->values[$match[1]] = $val; diff --git a/src/Renderer/Options.php b/src/Renderer/Options.php index 93234e1..e66a6e3 100644 --- a/src/Renderer/Options.php +++ b/src/Renderer/Options.php @@ -31,6 +31,11 @@ public function has(string $name): bool return array_key_exists($name, $this->options); } + /** + * @param mixed $defaultValue + * + * @return mixed + */ public function get(string $name, $defaultValue = null) { return array_key_exists($name, $this->options) ? $this->options[$name] : $defaultValue; diff --git a/src/Response/Hydrator/BannersResponseHydratorHandler.php b/src/Response/Hydrator/BannersResponseHydratorHandler.php index 7c781ff..ffade9e 100644 --- a/src/Response/Hydrator/BannersResponseHydratorHandler.php +++ b/src/Response/Hydrator/BannersResponseHydratorHandler.php @@ -59,6 +59,7 @@ * display_type: string|null, * breakpoint_type: string, * mode?: string, + * options?: array, * dimensions?: DimensionsData, * banners: array, * } diff --git a/src/Response/ValueObject/Position.php b/src/Response/ValueObject/Position.php index f001687..afab93c 100644 --- a/src/Response/ValueObject/Position.php +++ b/src/Response/ValueObject/Position.php @@ -39,7 +39,8 @@ final class Position private array $banners; /** - * @param array $banners + * @param array $options + * @param array $banners */ public function __construct( ?string $id,