Skip to content

Commit

Permalink
Fixed PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Sep 19, 2024
1 parent a1ef524 commit beff301
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
18 changes: 7 additions & 11 deletions src/Expression/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,46 @@ 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'],
$value,
);

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,
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Cache/CacheControlHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/Renderer/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Response/Hydrator/BannersResponseHydratorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* display_type: string|null,
* breakpoint_type: string,
* mode?: string,
* options?: array<string, string>,
* dimensions?: DimensionsData,
* banners: array<int, BannerData>,
* }
Expand Down
3 changes: 2 additions & 1 deletion src/Response/ValueObject/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ final class Position
private array $banners;

/**
* @param array<int, Banner> $banners
* @param array<string, string> $options
* @param array<int, Banner> $banners
*/
public function __construct(
?string $id,
Expand Down

0 comments on commit beff301

Please sign in to comment.