Skip to content

fix(attribute): Update value() method in HasValue trait to accept boolean values and adjust related tests and data provider.#80

Merged
terabytesoftw merged 2 commits intomainfrom
feature_44
Feb 8, 2026
Merged

fix(attribute): Update value() method in HasValue trait to accept boolean values and adjust related tests and data provider.#80
terabytesoftw merged 2 commits intomainfrom
feature_44

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

… boolean values and adjust related tests and data provider.
@terabytesoftw terabytesoftw added the bug Something isn't working label Feb 8, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • The value() handling now accepts boolean values in addition to numeric, string, and enum types.
  • Documentation

    • Changelog and docblocks updated to list boolean as an accepted value and show a boolean usage example.
  • Tests

    • Test data and providers expanded to include boolean cases to validate the updated behavior.

Walkthrough

Extends the HasValue trait's value() parameter to accept boolean values; updates docblock and example, adjusts test signatures and the ValueProvider with two boolean test cases, and adds a changelog entry documenting the change.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added entry under 0.5.3 noting that HasValue::value() now accepts bool and tests/data providers were updated.
Core Trait
src/HasValue.php
Method signature updated to accept `bool
Tests
tests/HasValueTest.php, tests/Provider/ValueProvider.php
Test method type hints widened to include bool; ValueProvider::values phpdoc updated; two new data-provider cases added for boolean false and boolean true.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A little hop, a tiny tweak,
True and false now join the clique,
Doc and tests in tidy rows,
The value trait happily grows. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: extending the value() method to accept boolean values and updating related tests.
Description check ✅ Passed The description is related to the changeset, confirming it's a bugfix that updates the value() method to accept booleans without breaking backward compatibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature_44

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/HasValue.php`:
- Around line 29-30: Update the docblock for the $value parameter in
HasValue.php so the prose matches the union type: include "Stringable" and
"UnitEnum" in the descriptive text (e.g., "bool, int, float, string, Stringable,
UnitEnum, or null to remove the attribute") for the parameter $value in the
HasValue trait/method.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85858b8 and 018a579.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/HasValue.php
  • tests/HasValueTest.php
  • tests/Provider/ValueProvider.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-01-09T16:05:15.502Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 18
File: tests/Support/Provider/Global/ContentEditableProvider.php:32-33
Timestamp: 2026-01-09T16:05:15.502Z
Learning: Preserve the original copyright year in file headers when moving PHP source files between packages within the ui-awesome repositories (e.g., from ui-awesome/html-core to ui-awesome/html-attribute). Do not update the header year to the current year; keep the original creation year as stated in the header. This applies to all PHP files throughout the repo that are moved between packages.

Applied to files:

  • src/HasValue.php
  • tests/HasValueTest.php
  • tests/Provider/ValueProvider.php
📚 Learning: 2026-02-07T13:44:00.931Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 78
File: tests/Global/HasDirTest.php:92-92
Timestamp: 2026-02-07T13:44:00.931Z
Learning: In PHP test methods that start with testThrowInvalidArgumentException, do not append 'Invalid' again in the method name suffix (e.g., prefer testThrowInvalidArgumentExceptionForSettingDirValue over testThrowInvalidArgumentExceptionForSettingInvalidDirValue). The exception type already communicates invalid input, so the repeated word is redundant. Apply this convention to all similar test methods under the tests/ directory.

Applied to files:

  • tests/HasValueTest.php
  • tests/Provider/ValueProvider.php
🧬 Code graph analysis (1)
tests/HasValueTest.php (1)
src/HasValue.php (1)
  • value (44-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-windows-2022
🔇 Additional comments (5)
src/HasValue.php (1)

44-47: Type expansion looks correct.

The bool addition to the union type is consistent with the docblock, usage examples, and test data provider.

CHANGELOG.md (1)

53-53: LGTM!

Changelog entry follows the established format and accurately describes the change.

tests/Provider/ValueProvider.php (2)

43-56: Boolean test cases look well-structured.

The false → empty render and true' value' (boolean HTML attribute) pattern correctly follows HTML boolean attribute semantics.


24-30: PHPStan type annotation updated correctly.

Removing null from the third tuple position is accurate — all data entries use a non-null expected value (the null input cases expect '' as the resolved value).

tests/HasValueTest.php (1)

64-70: Test method signature correctly expanded to accept boolean types.

The type unions for $value and $expectedValue are consistent with both the trait's updated signature and the data provider's new boolean entries.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/HasValue.php`:
- Line 35: The docblock for HasValue::value currently shows only
$element->value(true); add a complementary example using $element->value(false)
that demonstrates the different string/casting behavior (e.g. that false yields
an empty string or other expected output) so users can see both cases; update
the docblock examples in HasValue.php near the existing value(true) example and
make the expected returned/printed representation for value(false) explicit.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 018a579 and 245c036.

📒 Files selected for processing (1)
  • src/HasValue.php
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-09T16:05:15.502Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 18
File: tests/Support/Provider/Global/ContentEditableProvider.php:32-33
Timestamp: 2026-01-09T16:05:15.502Z
Learning: Preserve the original copyright year in file headers when moving PHP source files between packages within the ui-awesome repositories (e.g., from ui-awesome/html-core to ui-awesome/html-attribute). Do not update the header year to the current year; keep the original creation year as stated in the header. This applies to all PHP files throughout the repo that are moved between packages.

Applied to files:

  • src/HasValue.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-windows-2022
  • GitHub Check: phpunit / PHP 8.5-windows-2022
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: linter / Super Linter
🔇 Additional comments (1)
src/HasValue.php (1)

24-47: Reconsider accepting boolean values for the value attribute — it renders as a boolean attribute, which is semantically incorrect for a content attribute.

The test data confirms that true renders as a valueless attribute ( value) and false removes the attribute entirely. While this behavior is intentional (handled by the downstream attribute rendering), it's semantically wrong for the value attribute, which is a content attribute meant to hold actual values (strings, numbers, etc.), not a boolean flag like disabled or checked.

Either remove bool from the type signature, or add explicit documentation in the docblock explaining that boolean values render as HTML boolean attributes (e.g., true value, false → attribute removed).

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@terabytesoftw terabytesoftw merged commit 0b3875e into main Feb 8, 2026
47 checks passed
@terabytesoftw terabytesoftw deleted the feature_44 branch February 8, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant