Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cappuc committed Aug 20, 2024
1 parent 1dcf6a0 commit 7fe9d60
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
includes:
- ./vendor/phpstan/phpstan/conf/bleedingEdge.neon
- phpstan-baseline.neon

parameters:
Expand Down
5 changes: 4 additions & 1 deletion src/Tags/CycleTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public function render(RenderContext $context): string
assert(is_array($register));
$key = $context->evaluate($this->name);

$iteration = $register[$key] ?? 0;
$iteration = match (true) {
isset($register[$key]) && is_int($register[$key]) => $register[$key],
default => 0,
};

$value = $this->variables[$iteration];

Expand Down
6 changes: 4 additions & 2 deletions src/Tags/DecrementTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ public static function tagName(): string

public function render(RenderContext $context): string
{
$counter = $context->getEnvironment($this->variableName) ?? 0;
$counter -= 1;
$counter = $context->getEnvironment($this->variableName);

$counter = is_int($counter) ? $counter - 1 : -1;

$context->setEnvironment($this->variableName, $counter);

return (string) $counter;
Expand Down
6 changes: 4 additions & 2 deletions src/Tags/IncrementTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public function parse(TagParseContext $context): static

public function render(RenderContext $context): string
{
$counter = $context->getEnvironment($this->variableName) ?? -1;
$counter += 1;
$counter = $context->getEnvironment($this->variableName);

$counter = is_int($counter) ? $counter + 1 : 0;

$context->setEnvironment($this->variableName, $counter);

return (string) $counter;
Expand Down

0 comments on commit 7fe9d60

Please sign in to comment.