Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/Twig/Components/Badge.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/lib/Twig/Components/Badge.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.3)

Found violation(s) of type: function_declaration

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand Down Expand Up @@ -51,7 +51,8 @@
$resolver
->define('value')
->allowedTypes('int')
->required();
->required()
->normalize(static fn(OptionsResolver $options, int $value): int => max(0, $value));
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normalization silently converts negative values to 0, which may hide bugs in calling code. Consider adding validation to reject negative values with a clear error message, or document this behavior explicitly if silent normalization is intentional.

Suggested change
->normalize(static fn(OptionsResolver $options, int $value): int => max(0, $value));
->allowedValues(static fn(int $value): bool => $value >= 0);

Copilot uses AI. Check for mistakes.
$resolver
->define('maxBadgeValue')
->allowedTypes('int')
Expand Down
Loading