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.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- Enh #77: Add `Autocomplete` enum and update `AutocompleteProvider` to add test data (@terabytesoftw)
- Enh #78: Add `HasPopover`, `HasPopoverTarget`, `HasPopoverTargetAction` traits and `popover()`, `popoverTarget()`, `popoverTargetAction()` methods to manage popover attributes for HTML elements (@terabytesoftw)
- Enh #79: Add `HasInputmode` trait and `inputmode()` method to manage `inputmode` attribute for HTML elements (@terabytesoftw)
- Bug #80: Update `value()` method in `HasValue` trait to accept boolean values and adjust related tests and data provider (@terabytesoftw)

## 0.5.2 January 29, 2026

Expand Down
13 changes: 7 additions & 6 deletions src/HasValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ trait HasValue
*
* Defines the current value for the element.
*
* @param float|int|string|Stringable|UnitEnum|null $value Element value as `int`, `float`, or `string`, or `null`
* to remove the attribute.
*
* @return static New instance with the updated `value` attribute.
*
* Usage example:
* ```php
* $element->value(3);
* $element->value(3.14);
* $element->value('text');
* $element->value(SomeEnum::VALUE);
* $element->value(true);
* $element->value(null);
* ```
*
* @param bool|float|int|string|Stringable|UnitEnum|null $value Element value as `bool`, `int`, `float`, `string`,
* `Stringable`, `UnitEnum`, or `null` to remove the attribute.
*
* @return static New instance with the updated `value` attribute.
*/
public function value(float|int|string|Stringable|UnitEnum|null $value): static
public function value(bool|float|int|string|Stringable|UnitEnum|null $value): static
{
return $this->addAttribute(Attribute::VALUE, $value);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/HasValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public function testReturnNewInstanceWhenSettingValueAttribute(): void
*/
#[DataProviderExternal(ValueProvider::class, 'values')]
public function testSetValueAttributeValue(
float|int|string|Stringable|UnitEnum|null $value,
bool|float|int|string|Stringable|UnitEnum|null $value,
array $attributes,
float|int|string|Stringable|UnitEnum $expectedValue,
bool|float|int|string|Stringable|UnitEnum $expectedValue,
string $expectedRenderAttributes,
string $message,
): void {
Expand Down
22 changes: 21 additions & 1 deletion tests/Provider/ValueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ final class ValueProvider
/**
* @phpstan-return array<
* string,
* array{float|int|string|Stringable|UnitEnum|null, mixed[], float|int|string|Stringable|UnitEnum, string, string}
* array{
* bool|float|int|string|Stringable|UnitEnum|null,
* mixed[],
* bool|float|int|string|Stringable|UnitEnum,
* string,
* string,
* },
* >
*/
public static function values(): array
Expand All @@ -34,6 +40,20 @@ public function __toString(): string
};

return [
'boolean false' => [
false,
[],
false,
'',
'Should return the attribute value after setting it.',
],
'boolean true' => [
true,
[],
true,
' value',
'Should return the attribute value after setting it.',
],
'empty string' => [
'',
[],
Expand Down
Loading