Skip to content

fix(attribute): Better naming prefix CanBe for boolean attributes.#85

Merged
terabytesoftw merged 3 commits intomainfrom
fix_mini_31
Feb 16, 2026
Merged

fix(attribute): Better naming prefix CanBe for boolean attributes.#85
terabytesoftw merged 3 commits intomainfrom
fix_mini_31

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

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

@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

Warning

Rate limit exceeded

@terabytesoftw has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ad7dd35 and 697f4d6.

📒 Files selected for processing (1)
  • CHANGELOG.md
📝 Walkthrough

Walkthrough

This PR renames boolean attribute traits from Has* to CanBe*, updates related tests and providers to match, and changes two global trait methods to accept bool|null (nullable booleans). It also adds a CHANGELOG entry for Bug #85.

Changes

Cohort / File(s) Summary
Trait Renaming
src/CanBeDisabled.php, src/Form/CanBeChecked.php, src/Form/CanBeMultiple.php, src/Form/CanBeReadonly.php, src/Form/CanBeRequired.php
Renamed traits from Has*CanBe*; removed docblock examples invoking ...(...false).
Nullable Global Methods
src/Global/CanBeAutofocus.php, src/Global/CanBeHidden.php
Updated method signatures to accept `bool
Tests: Trait Name Updates
tests/CanBeDisabledTest.php, tests/Form/CanBeCheckedTest.php, tests/Form/CanBeMultipleTest.php, tests/Form/CanBeReadonlyTest.php, tests/Form/CanBeRequiredTest.php
Updated test class names and imports to CanBe*Test; switched anonymous test classes to use CanBe* traits; narrowed some test parameter types to `bool
Tests: Nullable Signature Updates
tests/Global/CanBeAutofocusTest.php, tests/Global/CanBeHiddenTest.php
Adjusted test method signatures to accept and expect nullable booleans (?bool).
Providers: Docblock & Types
tests/Provider/DisabledProvider.php, tests/Provider/Form/CheckedProvider.php, tests/Provider/Form/MultipleProvider.php, tests/Provider/Form/ReadonlyProvider.php, tests/Provider/Form/RequiredProvider.php
Updated docblock references to CanBe*Test; tightened @phpstan-return annotations to replace `bool
Providers: Nullable Cases Added
tests/Provider/Global/AutofocusProvider.php, tests/Provider/Global/HiddenProvider.php
Widened phpdoc return types to allow `bool
Changelog
CHANGELOG.md
Added entry for Bug #85 "Better naming prefix for boolean attributes" under 0.6.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I hopped through traits with nimble paws,

Swapped Has for CanBe without a pause,
Nullable booleans wink and flee,
Now attributes may vanish like me —
🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: renaming boolean attribute traits from 'Has' prefix to 'CanBe' prefix across the codebase.
Description check ✅ Passed The description is related to the changeset, indicating it is a bugfix that breaks backwards compatibility, which aligns with the trait renaming changes throughout the codebase.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

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

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.

@coderabbitai coderabbitai bot added the bug Something isn't working label Feb 16, 2026
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/Global/CanBeAutofocus.php (1)

23-26: 🛠️ Refactor suggestion | 🟠 Major

Usage example is inconsistent with other CanBe* traits.

The other renamed traits (e.g., CanBeDisabled, CanBeReadonly, CanBeRequired) all include a null example alongside true in their usage snippets. Since the signature was widened to bool|null in this PR, adding the null case here would keep documentation consistent.

📝 Proposed fix
     * Usage example:
     * ```php
     * $element->autofocus(true);
+    * $element->autofocus(null);
     * ```
tests/Form/CanBeMultipleTest.php (1)

76-80: ⚠️ Potential issue | 🔴 Critical

Same getAttribute default mismatch as in CanBeHiddenTest.

Line 78 uses '' as the default for getAttribute, but the 'null' and 'unset with null' provider cases expect null. This will cause assertSame(null, '') to fail if setAttribute(null) removes the attribute. Use null as the default to be consistent with CanBeRequiredTest.

Proposed fix
         self::assertSame(
             $expectedValue,
-            $instance->getAttribute(Attribute::MULTIPLE, ''),
+            $instance->getAttribute(Attribute::MULTIPLE, null),
             $message,
         );
tests/Form/CanBeCheckedTest.php (1)

76-80: ⚠️ Potential issue | 🔴 Critical

Same getAttribute default mismatch as in CanBeHiddenTest and CanBeMultipleTest.

Line 78 uses '' as the default for getAttribute, but the provider's 'null' and 'unset with null' cases expect null. Use null as the default to match CanBeRequiredTest.

Proposed fix
         self::assertSame(
             $expectedValue,
-            $instance->getAttribute(Attribute::CHECKED, ''),
+            $instance->getAttribute(Attribute::CHECKED, null),
             $message,
         );
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62d9d86 and d88c093.

📒 Files selected for processing (22)
  • CHANGELOG.md
  • src/CanBeDisabled.php
  • src/Form/CanBeChecked.php
  • src/Form/CanBeMultiple.php
  • src/Form/CanBeReadonly.php
  • src/Form/CanBeRequired.php
  • src/Global/CanBeAutofocus.php
  • src/Global/CanBeHidden.php
  • tests/CanBeDisabledTest.php
  • tests/Form/CanBeCheckedTest.php
  • tests/Form/CanBeMultipleTest.php
  • tests/Form/CanBeReadonlyTest.php
  • tests/Form/CanBeRequiredTest.php
  • tests/Global/CanBeAutofocusTest.php
  • tests/Global/CanBeHiddenTest.php
  • tests/Provider/DisabledProvider.php
  • tests/Provider/Form/CheckedProvider.php
  • tests/Provider/Form/MultipleProvider.php
  • tests/Provider/Form/ReadonlyProvider.php
  • tests/Provider/Form/RequiredProvider.php
  • tests/Provider/Global/AutofocusProvider.php
  • tests/Provider/Global/HiddenProvider.php
🧰 Additional context used
🧠 Learnings (3)
📚 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:

  • tests/Provider/Form/RequiredProvider.php
  • src/Global/CanBeHidden.php
  • tests/Provider/DisabledProvider.php
  • src/Global/CanBeAutofocus.php
  • tests/Global/CanBeHiddenTest.php
  • tests/CanBeDisabledTest.php
  • src/Form/CanBeRequired.php
  • src/Form/CanBeReadonly.php
  • tests/Form/CanBeRequiredTest.php
  • tests/Provider/Form/ReadonlyProvider.php
  • tests/Provider/Global/HiddenProvider.php
  • tests/Form/CanBeReadonlyTest.php
  • tests/Global/CanBeAutofocusTest.php
  • tests/Form/CanBeMultipleTest.php
  • src/CanBeDisabled.php
  • src/Form/CanBeChecked.php
  • src/Form/CanBeMultiple.php
  • tests/Provider/Form/CheckedProvider.php
  • tests/Provider/Form/MultipleProvider.php
  • tests/Form/CanBeCheckedTest.php
  • tests/Provider/Global/AutofocusProvider.php
📚 Learning: 2026-02-08T20:05:36.407Z
Learnt from: terabytesoftw
Repo: ui-awesome/html-attribute PR: 80
File: src/HasValue.php:35-35
Timestamp: 2026-02-08T20:05:36.407Z
Learning: In the ui-awesome/html-attribute repository, for methods that accept multiple values of the same type (e.g., boolean true/false), document with a single representative example rather than exhaustively listing all variations. This keeps documentation concise while conveying the intended usage. Apply this consistently across PHP docblocks and examples.

Applied to files:

  • tests/Provider/Form/RequiredProvider.php
  • src/Global/CanBeHidden.php
  • tests/Provider/DisabledProvider.php
  • src/Global/CanBeAutofocus.php
  • tests/Global/CanBeHiddenTest.php
  • tests/CanBeDisabledTest.php
  • src/Form/CanBeRequired.php
  • src/Form/CanBeReadonly.php
  • tests/Form/CanBeRequiredTest.php
  • tests/Provider/Form/ReadonlyProvider.php
  • tests/Provider/Global/HiddenProvider.php
  • tests/Form/CanBeReadonlyTest.php
  • tests/Global/CanBeAutofocusTest.php
  • tests/Form/CanBeMultipleTest.php
  • src/CanBeDisabled.php
  • src/Form/CanBeChecked.php
  • src/Form/CanBeMultiple.php
  • tests/Provider/Form/CheckedProvider.php
  • tests/Provider/Form/MultipleProvider.php
  • tests/Form/CanBeCheckedTest.php
  • tests/Provider/Global/AutofocusProvider.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/Provider/Form/RequiredProvider.php
  • tests/Provider/DisabledProvider.php
  • tests/Global/CanBeHiddenTest.php
  • tests/CanBeDisabledTest.php
  • tests/Form/CanBeRequiredTest.php
  • tests/Provider/Form/ReadonlyProvider.php
  • tests/Provider/Global/HiddenProvider.php
  • tests/Form/CanBeReadonlyTest.php
  • tests/Global/CanBeAutofocusTest.php
  • tests/Form/CanBeMultipleTest.php
  • tests/Provider/Form/CheckedProvider.php
  • tests/Provider/Form/MultipleProvider.php
  • tests/Form/CanBeCheckedTest.php
  • tests/Provider/Global/AutofocusProvider.php
🧬 Code graph analysis (7)
src/Global/CanBeHidden.php (1)
src/HasValue.php (1)
  • value (42-45)
src/Global/CanBeAutofocus.php (1)
src/HasValue.php (1)
  • value (42-45)
tests/CanBeDisabledTest.php (1)
tests/Provider/DisabledProvider.php (1)
  • DisabledProvider (15-60)
tests/Form/CanBeRequiredTest.php (1)
tests/Provider/Form/RequiredProvider.php (1)
  • RequiredProvider (15-60)
tests/Form/CanBeReadonlyTest.php (1)
tests/Provider/Form/ReadonlyProvider.php (1)
  • ReadonlyProvider (15-60)
tests/Form/CanBeMultipleTest.php (1)
tests/Provider/Form/MultipleProvider.php (1)
  • MultipleProvider (15-60)
tests/Form/CanBeCheckedTest.php (1)
tests/Provider/Form/CheckedProvider.php (1)
  • CheckedProvider (15-60)
🪛 PHPMD (2.15.0)
tests/CanBeDisabledTest.php

[warning] 66-66: Avoid excessively long variable names like $expectedRenderAttributes. Keep variable name length under 20. (undefined)

(LongVariable)

tests/Form/CanBeReadonlyTest.php

[warning] 66-66: Avoid excessively long variable names like $expectedRenderAttributes. Keep variable name length under 20. (undefined)

(LongVariable)

tests/Form/CanBeMultipleTest.php

[warning] 66-66: Avoid excessively long variable names like $expectedRenderAttributes. Keep variable name length under 20. (undefined)

(LongVariable)

tests/Form/CanBeCheckedTest.php

[warning] 66-66: Avoid excessively long variable names like $expectedRenderAttributes. Keep variable name length under 20. (undefined)

(LongVariable)

⏰ 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). (16)
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
  • GitHub Check: composer-require-checker / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.4-windows-2022
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.5-windows-2022
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.3-windows-2022
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: linter / Super Linter
🔇 Additional comments (20)
src/Form/CanBeMultiple.php (1)

18-18: LGTM! Clean trait rename with consistent documentation.

src/Form/CanBeChecked.php (1)

18-18: LGTM! Consistent rename from HasChecked to CanBeChecked.

src/Form/CanBeReadonly.php (1)

18-18: LGTM! Consistent rename from HasReadonly to CanBeReadonly.

src/CanBeDisabled.php (1)

18-18: LGTM! Consistent rename from HasDisabled to CanBeDisabled.

src/Form/CanBeRequired.php (1)

18-18: LGTM! Consistent rename from HasRequired to CanBeRequired.

tests/Provider/Form/ReadonlyProvider.php (1)

8-8: LGTM! Docblock reference and PHPStan type annotation correctly updated to reflect the CanBeReadonly rename and narrowed type.

Also applies to: 18-18

tests/Form/CanBeReadonlyTest.php (1)

9-9: LGTM! All references correctly updated from HasReadonly to CanBeReadonly, and the $expectedValue type properly narrowed to bool|null.

Also applies to: 29-29, 34-34, 47-47, 65-65, 70-70

src/Global/CanBeAutofocus.php (1)

28-33: This review comment is based on an incorrect premise.

The CanBeAutofocus trait was newly created in this commit with the bool|null signature from the start—it was not widened from an existing bool parameter. This is a new trait, not a modification to existing code. The bool|null pattern is consistent with similar boolean attribute traits in the library (e.g., CanBeHidden), and the signature is already well-tested with comprehensive coverage for true, false, and null values, including attribute unsetting behavior.

No downstream compatibility concerns apply to a newly created trait.

Likely an incorrect or invalid review comment.

tests/Provider/Global/HiddenProvider.php (1)

17-66: LGTM!

The updated return type annotation and new null test cases are consistent with the nullable boolean support added to the CanBeHidden trait. Good coverage of both the standalone null case and unsetting an existing value with null.

src/Global/CanBeHidden.php (1)

18-37: LGTM!

The nullable parameter addition is clean and consistent with the existing HasValue::value() pattern. The docblock correctly documents all three states (true, false, null).

tests/Provider/Form/MultipleProvider.php (1)

7-14: LGTM!

Docblock reference correctly updated to CanBeMultipleTest.

tests/Form/CanBeRequiredTest.php (1)

1-87: LGTM!

Clean rename from HasRequired to CanBeRequired. The getAttribute default of null on line 78 correctly aligns with the nullable test cases from the provider.

tests/Provider/Form/RequiredProvider.php (1)

7-14: LGTM!

Docblock reference correctly updated to CanBeRequiredTest.

tests/Global/CanBeHiddenTest.php (1)

76-80: The getAttribute default value should match the expected value when attribute is null.

Line 78 uses '' (empty string) as the default for getAttribute, but the provider's 'null' and 'unset with null' test cases expect $expectedValue = null. This creates an inconsistency: if setAttribute(null) unsets the attribute, getAttribute(HIDDEN, '') would return '' not null, causing the assertion to fail.

However, CanBeRequiredTest (line 78) uses getAttribute(..., null) as the default, which aligns with the null expected values in its provider. This inconsistency across the test suite suggests either:

  1. The default should be changed to null to match CanBeRequiredTest and the expected test values, or
  2. All similar tests have the same issue and need consistent updates

Change the default to null to be consistent with the expected value:

         self::assertSame(
             $expectedValue,
-            $instance->getAttribute(GlobalAttribute::HIDDEN, ''),
+            $instance->getAttribute(GlobalAttribute::HIDDEN, null),
             $message,
         );
CHANGELOG.md (1)

58-58: LGTM!

The changelog entry follows the established format and accurately describes the change.

tests/Provider/Form/CheckedProvider.php (1)

8-18: LGTM!

Docblock reference and PHPStan return type annotation correctly updated to reflect the CanBeChecked rename and the narrowed bool|null type.

tests/Provider/DisabledProvider.php (1)

8-18: LGTM!

Docblock and type annotations consistently updated to match the CanBeDisabled rename.

tests/CanBeDisabledTest.php (1)

9-70: LGTM!

Trait references, class name, anonymous class usages, and parameter types are all consistently updated for the CanBeDisabled rename.

tests/Provider/Global/AutofocusProvider.php (1)

37-64: LGTM!

Good addition of null and unset with null test cases — these align with the updated bool|null parameter type and are consistent with the patterns in other providers (e.g., CheckedProvider, DisabledProvider).

tests/Global/CanBeAutofocusTest.php (1)

62-67: LGTM!

Parameter types correctly widened to bool|null to match the updated provider data covering null scenarios.

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 `@CHANGELOG.md`:
- Line 58: Update the changelog entry for Bug `#85` to be more specific: replace
the vague line "Better naming prefix for boolean attributes" with a descriptive
sentence referencing the concrete change (the introduction/standardization of
the "CanBe" prefix for boolean attributes), e.g. "Bug `#85`: Standardize boolean
attribute names to use the 'CanBe' prefix (`@terabytesoftw`)"; ensure the entry
still includes the bug number and author tag and matches the level of
detail/format used by other entries like those around lines with similar
entries.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d88c093 and ad7dd35.

📒 Files selected for processing (1)
  • CHANGELOG.md
⏰ 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). (3)
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: linter / Super Linter

@terabytesoftw terabytesoftw merged commit 7a97e11 into main Feb 16, 2026
33 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_31 branch February 16, 2026 12:00
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