fix(attribute): Enhance HTML attribute element handling with Stringable and UnitEnum support.#66
Conversation
…le and UnitEnum support.
📝 WalkthroughWalkthroughThis PR broadens attribute trait method parameter types to accept Stringable and UnitEnum (alongside existing types), updates docblocks and tests/data providers to match, adds test stub enums, and inserts a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Element/HasReferrerpolicy.php (1)
69-74:⚠️ Potential issue | 🟠 MajorUpdate
src/HasReferrerpolicy.phpfor API consistency.The non-Element
src/HasReferrerpolicy.phptrait (line 64) still usesstring|UnitEnum|null, while the Element version now acceptsstring|Stringable|UnitEnum|null. Update the non-Element trait to includeStringablesupport for consistent public APIs across the codebase.
🤖 Fix all issues with AI agents
In `@src/Values/Type.php`:
- Around line 194-199: The docblock for the enum case TEXT incorrectly links to
MIME types; update the comment for the enum case TEXT (case TEXT = 'text') to
link to the HTML input type documentation instead (e.g., MDN page for <input
type="text"> or the HTML spec for input types) and adjust the brief description
to state it represents the <input type="text"> single-line text control; locate
the comment above the Type::TEXT enum case and replace the URL and text
accordingly.
In `@tests/HasSizeTest.php`:
- Around line 9-38: The test imports use the singular names HasSize and
SizeProvider but the actual trait and provider are plural; update the import
statements to reference UIAwesome\Html\Attribute\HasSizes and
UIAwesome\Html\Attribute\Tests\Support\Provider\SizesProvider so the test class
(which references the HasSize trait usage) points to the correct symbols
HasSizes and SizesProvider.
In `@tests/Support/Stub/Values/Backed.php`:
- Line 12: Update the copyright year in the file Backed.php from 2025 to 2026;
locate the file/class named Backed (or the top-of-file docblock) and modify the
copyright line that currently reads "Copyright (C) 2025 Terabytesoftw." to
"Copyright (C) 2026 Terabytesoftw." so the header reflects the correct year.
In `@tests/Support/Stub/Values/Unit.php`:
- Line 12: Update the copyright year in the file header comment of
tests/Support/Stub/Values/Unit.php from 2025 to 2026; locate the docblock at the
top of Unit.php (same pattern as Backed.php) and replace the year token "2025"
with "2026" so the file header matches the new-file copyright year.
🧹 Nitpick comments (2)
tests/Support/Stub/Values/Unit.php (1)
20-20: Inconsistent enum case naming convention.The case
valueuses lowercase, while the companionBackedenum uses uppercaseVALUE. Consider using consistent naming across both test stub enums.Proposed fix
- case value; + case VALUE;src/Element/HasAlt.php (1)
24-24: Minor inconsistency in@methodannotation.The
@methodannotation uses\UnitEnumwith a leading backslash, whileUnitEnumis already imported at line 9 without a namespace prefix. This is inconsistent with other traits likeHasDecoding(line 26) which usesstring|UnitEnumwithout the backslash. Consider removing the backslash for consistency.♻️ Suggested fix
- * `@method` static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. + * `@method` static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Pull Request
Summary by CodeRabbit
New Features
Tests
Documentation