Skip to content

fix(attribute): Enhance HTML attribute element handling with Stringable and UnitEnum support.#66

Merged
terabytesoftw merged 4 commits into
mainfrom
fix_mini_19
Feb 3, 2026
Merged

fix(attribute): Enhance HTML attribute element handling with Stringable and UnitEnum support.#66
terabytesoftw merged 4 commits into
mainfrom
fix_mini_19

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Feb 3, 2026

Pull Request

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

Summary by CodeRabbit

  • New Features

    • HTML attributes now accept Stringable objects and UnitEnum values (alt, decoding, height, href, loading, referrerpolicy, src, srcset, usemap, width)
    • Added text/html MIME type support
  • Tests

    • Expanded test providers and cases to cover Stringable and enum inputs; added test enum stubs
  • Documentation

    • Updated changelog entry reflecting these enhancements

@terabytesoftw terabytesoftw added the bug Something isn't working label Feb 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This 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 TEXT_HTML case into the Type enum. No control-flow changes.

Changes

Cohort / File(s) Summary
Changelog & Type Enum
CHANGELOG.md, src/Values/Type.php
Added changelog entry for Bug #66 and introduced case TEXT_HTML = 'text/html' to the Type enum with updated docblocks.
Attribute Trait Enhancements
src/Element/HasAlt.php, src/Element/HasDecoding.php, src/Element/HasHeight.php, src/Element/HasHref.php, src/Element/HasLoading.php, src/Element/HasReferrerpolicy.php, src/Element/HasSrc.php, src/Element/HasSrcset.php, src/Element/HasUsemap.php, src/Element/HasWidth.php
Added use Stringable; and expanded public method parameter unions to include Stringable and UnitEnum (e.g., `string
Test Method Signatures
tests/Element/HasAltTest.php, tests/Element/HasDecodingTest.php, tests/Element/HasHeightTest.php, tests/Element/HasHrefTest.php, tests/Element/HasLoadingTest.php, tests/Element/HasReferrerpolicyTest.php, tests/Element/HasSrcTest.php, tests/Element/HasSrcsetTest.php, tests/Element/HasUsemapTest.php, tests/Element/HasWidthTest.php
Widened test method parameter and expected-value type hints to match trait signatures (allowing Stringable and UnitEnum in inputs/expectations).
Test Data Providers
tests/Support/Provider/Element/AltProvider.php, DecodingProvider.php, HeightProvider.php, HrefProvider.php, LoadingProvider.php, ReferrerpolicyProvider.php, SrcProvider.php, SrcsetProvider.php, UsemapProvider.php, WidthProvider.php
Updated @phpstan-return annotations to include Stringable/UnitEnum, added anonymous Stringable instances, and added enum-backed/unit and stringable test cases to provider data sets.
Test Stubs
tests/Support/Stub/Values/Backed.php, tests/Support/Stub/Values/Unit.php
Added two test enums: Backed (string-backed with VALUE) and Unit (unit enum with value) used by new provider cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PR #57: Modifies HasSrcset::srcset() — directly related to the srcset trait changes in this PR.
  • PR #61: Touches the Type enum — related to the addition of TEXT_HTML in src/Values/Type.php.
  • PR #58: Introduces/changes HasUsemap — related to the widened usemap() signature here.

Poem

🐰
I nibble on types, nibble on strings,
I hop through enums and tiny things,
Stringable whispers, UnitEnums hum,
From alt to width, the changes come —
A hop, a test, the attributes sing!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly describes the main change: enhancing HTML attribute element handling to support Stringable and UnitEnum types. It accurately reflects the core objective across the multiple modified files.

✏️ 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 fix_mini_19

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
Copy Markdown

@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: 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 | 🟠 Major

Update src/HasReferrerpolicy.php for API consistency.

The non-Element src/HasReferrerpolicy.php trait (line 64) still uses string|UnitEnum|null, while the Element version now accepts string|Stringable|UnitEnum|null. Update the non-Element trait to include Stringable support 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 value uses lowercase, while the companion Backed enum uses uppercase VALUE. 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 @method annotation.

The @method annotation uses \UnitEnum with a leading backslash, while UnitEnum is already imported at line 9 without a namespace prefix. This is inconsistent with other traits like HasDecoding (line 26) which uses string|UnitEnum without 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.

Comment thread src/Values/Type.php
Comment thread tests/HasSizeTest.php Outdated
Comment thread tests/Support/Stub/Values/Backed.php Outdated
Comment thread tests/Support/Stub/Values/Unit.php Outdated
@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw terabytesoftw merged commit b82b4ea into main Feb 3, 2026
47 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_19 branch February 3, 2026 22:27
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