Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 3.31.0 (2026-XX-XX)

* Fix a PHP 8.5 deprecation in `html_cva()` when a recipe value is `null`
* Add the `collate` function to `twig/intl-extra` to compare strings in the alphabetical order of a locale
* Fix reading an attribute through its getter initializing a lazy object when the property is not public
* Fix compiled float literals depending on the `serialize_precision` ini setting
Expand Down
2 changes: 1 addition & 1 deletion extra/html-extra/Cva.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function apply(array $recipes, ?string ...$additionalClasses): string
if (\is_bool($recipeValue)) {
$recipeValue = $recipeValue ? 'true' : 'false';
}
$recipeClasses = $this->variants[$recipeName][$recipeValue] ?? [];
$recipeClasses = $this->variants[$recipeName][$recipeValue ?? ''] ?? [];
$classes = [...$classes, ...(array) $recipeClasses];
}

Expand Down
16 changes: 16 additions & 0 deletions extra/html-extra/Tests/CvaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public function testApply(): void
$this->assertEquals('font-semibold border rounded text-primary text-sm text-red-500', $recipe->apply(['colors' => 'primary', 'sizes' => 'sm']));
}

public function testApplyWithNullRecipeValue(): void
{
$recipe = new Cva('font-semibold', [
'colors' => [
'primary' => 'text-primary',
],
'sizes' => [
'sm' => 'text-sm',
],
], [], [
'sizes' => 'sm',
]);

$this->assertSame('font-semibold text-sm', $recipe->apply(['colors' => null, 'sizes' => null]));
}

public function testApplySameRecipesAgain(): void
{
$createRecipe = static fn () => new Cva("font-semibold border\nrounded border", [
Expand Down