fix(html): Update ui-awesome/html-helper to version ^0.7 and ui-awesome/html-mixin to version ^0.4 in composer.json and apply necessary changes to src and tests directories.#43
Conversation
…awesome/html-mixin` to version `^0.4` in `composer.json` and apply necessary changes to `src` and `tests` directories.
📝 WalkthroughSummary by CodeRabbit
WalkthroughRefactors attribute API by replacing addAttribute() with setAttribute() across traits and tags, updates composer dependencies (adds ui-awesome/html-mixin; bumps helper/attribute versions), introduces BaseChoice and CanBeUnchecked for form choice inputs, and removes HasLabel while updating many tests to the new API. Changes
*Files grouped by directory/pattern for brevity — many individual attribute trait files and tag classes were updated to use Sequence Diagram(s)sequenceDiagram
participant Caller as Test/Runtime
participant BaseChoice as BaseChoice (render)
participant Hidden as InputHidden
participant Label as Label
participant Html as Html\Builder
Caller->>BaseChoice: render()/run()
BaseChoice-->>Html: buildAttributes(parent::getAttributes())
alt uncheckedValue set
BaseChoice->>Hidden: create hidden input (same name, unchecked value)
Hidden-->>BaseChoice: hidden HTML
end
alt label enabled
BaseChoice->>Label: build label (enclosed or standalone)
Label-->>BaseChoice: label HTML
end
BaseChoice->>Html: buildElement(prefix, tag, label, suffix)
Html-->>Caller: final HTML output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (57)
🧰 Additional context used🧠 Learnings (5)📓 Common learnings📚 Learning: 2026-02-06T21:37:44.509ZApplied to files:
📚 Learning: 2026-02-11T14:56:18.277ZApplied to files:
📚 Learning: 2026-02-09T11:28:09.334ZApplied to files:
📚 Learning: 2026-02-06T21:37:51.711ZApplied to files:
🧬 Code graph analysis (30)tests/Form/InputCheckboxTest.php (5)
src/Form/InputRadio.php (1)
tests/Heading/H4Test.php (5)
tests/Form/InputMonthTest.php (3)
tests/Root/BodyTest.php (5)
tests/Form/InputRadioTest.php (4)
tests/Phrasing/SpanTest.php (5)
tests/Form/InputResetTest.php (12)
tests/Heading/H2Test.php (3)
tests/Metadata/BaseTest.php (7)
tests/Form/InputSubmitTest.php (2)
tests/List/LiTest.php (6)
tests/Phrasing/ITest.php (2)
tests/Form/InputPasswordTest.php (3)
tests/Sectioning/ArticleTest.php (8)
tests/Form/InputNumberTest.php (3)
tests/Phrasing/LabelTest.php (4)
tests/Heading/H1Test.php (3)
tests/Root/HeadTest.php (3)
tests/Form/InputSearchTest.php (4)
tests/List/DtTest.php (13)
tests/Heading/H3Test.php (3)
tests/Heading/HGroupTest.php (4)
tests/Form/InputTimeTest.php (3)
tests/Root/FooterTest.php (6)
tests/Root/HtmlTest.php (4)
tests/Form/InputHiddenTest.php (3)
tests/Metadata/NoScriptTest.php (2)
tests/Embedded/ImgTest.php (5)
tests/Sectioning/AsideTest.php (3)
🔇 Additional comments (108)
✏️ Tip: You can disable this entire section by setting 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #43 +/- ##
===========================================
Coverage 100.00% 100.00%
+ Complexity 154 140 -14
===========================================
Files 75 76 +1
Lines 384 326 -58
===========================================
- Hits 384 326 -58 ☔ View full report in Codecov by Sentry. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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 (19)
tests/Heading/HGroupTest.php (1)
127-138: 🧹 Nitpick | 🔵 TrivialTest method name is now misleading after the API rename.
testRenderWithAddAttributestill references the oldaddAttributename but the body now callssetAttribute(). Consider renaming the method totestRenderWithSetAttributeso the test name matches the exercised API.Same applies to
testRenderWithAddAttributeUsingEnumon line 141.Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void- public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): voidtests/Palpable/ATest.php (1)
128-152: 🧹 Nitpick | 🔵 TrivialTest method names still reference
addAttributeafter the API rename.
testRenderWithAddAttribute(Line 128) andtestRenderWithAddAttributeUsingEnum(Line 141) now callsetAttribute(), but the method names still say "Add". Consider renaming totestRenderWithSetAttributeandtestRenderWithSetAttributeUsingEnumfor consistency with the updated API and assertion messages.This same naming inconsistency applies across all test files in this PR.
tests/Form/InputWeekTest.php (1)
184-209: 🧹 Nitpick | 🔵 TrivialTest method names still reference
addAttributewhile the body usessetAttribute.
testRenderWithAddAttributeandtestRenderWithAddAttributeUsingEnumstill carry "Add" in their names even though the underlying API is nowsetAttribute(). This inconsistency is repeated across all test files in this PR. Consider renaming them (e.g.,testRenderWithSetAttribute,testRenderWithSetAttributeUsingEnum) so the method name matches the API being tested.✏️ Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void { // ... } - public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): void { // ... }tests/Form/InputImageTest.php (1)
788-793:⚠️ Potential issue | 🟡 MinorMinor typo: "Select a image" → "Select an image".
The title attribute value and assertion message use "a image" instead of "an image".
✏️ Suggested fix
- <input id="inputimage" type="image" title="Select a image"> + <input id="inputimage" type="image" title="Select an image"> HTML, InputImage::tag() ->id('inputimage') - ->title('Select a image') + ->title('Select an image') ->render(), - "Failed asserting that element renders correctly with 'title' attribute.", + "Failed asserting that element renders correctly with 'title' attribute.",tests/Form/InputRangeTest.php (1)
183-208: 🧹 Nitpick | 🔵 TrivialTest method names still reference
addAttributeafter the API rename.
testRenderWithAddAttribute(Line 183) andtestRenderWithAddAttributeUsingEnum(Line 197) still use the oldAddAttributenaming, but the body and assertion messages now referencesetAttribute(). Consider renaming for consistency:Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void- public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): voidtests/Form/InputUrlTest.php (1)
185-209: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency as other test files.
testRenderWithAddAttributeandtestRenderWithAddAttributeUsingEnumshould be renamed totestRenderWithSetAttribute/testRenderWithSetAttributeUsingEnumto match the updatedsetAttribute()API calls and assertion messages.tests/Root/HeadTest.php (1)
127-152: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency.
testRenderWithAddAttribute(Line 127) andtestRenderWithAddAttributeUsingEnum(Line 141) should be renamed to reflect thesetAttribute()API, consistent with the updated assertion messages.tests/Form/InputMonthTest.php (1)
183-208: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency as other files —
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnum.tests/Form/InputTextTest.php (1)
184-208: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency as other files —
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnum.tests/Form/InputHiddenTest.php (1)
182-208: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency as other files —
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnum.tests/Metadata/StyleTest.php (1)
133-158: 🧹 Nitpick | 🔵 TrivialTest method names still reference
addAttributebut now exercisesetAttribute.
testRenderWithAddAttribute(Line 133) andtestRenderWithAddAttributeUsingEnum(Line 147) still carry the oldAddAttributenaming while the code and messages now referencesetAttribute(). Consider renaming them totestRenderWithSetAttribute/testRenderWithSetAttributeUsingEnumfor consistency. This same pattern applies across all the other test files in this PR.tests/Heading/H5Test.php (1)
127-153: 🧹 Nitpick | 🔵 TrivialTest method names still reference
addAttributeafter the API rename tosetAttribute.
testRenderWithAddAttribute(Line 127) andtestRenderWithAddAttributeUsingEnum(Line 141) now testsetAttribute(), but the method names still say "AddAttribute". The assertion messages were updated, but the method names were not. This same inconsistency appears across all test files in this PR.Consider renaming for consistency:
Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void- public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): voidtests/Flow/DivTest.php (1)
127-153: 🧹 Nitpick | 🔵 TrivialTest method names still reference
AddAttributewhile the body now callssetAttribute.Methods
testRenderWithAddAttribute(Line 127) andtestRenderWithAddAttributeUsingEnum(Line 141) were updated to callsetAttribute()with matching assertion messages, but the method names themselves were not renamed. This applies consistently across all test files in this PR (DivTest, OlTest, DlTest, AsideTest, SectionTest).Consider renaming for consistency:
✏️ Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void- public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): voidtests/Phrasing/LabelTest.php (1)
120-131: 🧹 Nitpick | 🔵 TrivialNit: Test method name
testRenderWithAddAttributeis now misleading.The method calls
setAttribute()but the test name still references "AddAttribute". Consider renaming totestRenderWithSetAttributefor consistency with the updated API. Same applies totestRenderWithAddAttributeUsingEnum(Line 133).tests/Heading/H1Test.php (1)
127-153: 🧹 Nitpick | 🔵 TrivialSame nit as in LabelTest: method names
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnumstill reference "Add" while callingsetAttribute().tests/List/DtTest.php (1)
127-153: 🧹 Nitpick | 🔵 TrivialSame method naming nit applies here —
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnumnow testsetAttribute().tests/List/LiTest.php (1)
128-154: 🧹 Nitpick | 🔵 TrivialSame method naming nit — consider renaming
testRenderWithAddAttribute/testRenderWithAddAttributeUsingEnumto reflectsetAttribute.tests/Root/BodyTest.php (1)
127-138: 🧹 Nitpick | 🔵 TrivialTest method name
testRenderWithAddAttributeis now misleading since it testssetAttribute().The assertion message on line 137 was correctly updated to reference
setAttribute(), but the method name on line 127 still saysAddAttribute. Same applies totestRenderWithAddAttributeUsingEnumon line 141. Consider renaming for consistency:♻️ Suggested rename
- public function testRenderWithAddAttribute(): void + public function testRenderWithSetAttribute(): void- public function testRenderWithAddAttributeUsingEnum(): void + public function testRenderWithSetAttributeUsingEnum(): voidtests/Metadata/BaseTest.php (1)
102-126: 🧹 Nitpick | 🔵 TrivialSame test method naming inconsistency as noted in
BodyTest.
testRenderWithAddAttribute(line 102) andtestRenderWithAddAttributeUsingEnum(line 115) still reference "AddAttribute" in their names while now testingsetAttribute(). Consider renaming totestRenderWithSetAttribute/testRenderWithSetAttributeUsingEnumfor consistency with the updated assertion messages.
🤖 Fix all issues with AI agents
In `@composer.json`:
- Around line 15-19: The composer.json currently pins ui-awesome/html-attribute
to an unstable `@dev` release while bumping ui-awesome/html-helper to ^0.7 and
adding ui-awesome/html-mixin ^0.4 to match the addAttribute()→setAttribute()
migration; replace the unstable "ui-awesome/html-attribute": "^0.6@dev"
constraint with a stable constraint (e.g., the latest released 0.5.x version or
leave it out until a 0.6.x stable is published), or hold the package bump until
ui-awesome/html-attribute has a stable 0.6.x release, then update the constraint
accordingly; after changing the constraint, run composer update to refresh
composer.lock and verify there are no unstable transitive dependencies.
In `@src/Form/InputRadio.php`:
- Line 8: Remove the now-unused import UIAwesome\Html\Core\Html from the top of
the InputRadio file: the run() method was moved to BaseChoice so InputRadio no
longer references Html; update the imports by deleting the line "use
UIAwesome\Html\Core\Html;" (keeping other imports intact) and run tests/static
analysis to ensure no other references to Html remain in the InputRadio class.
In `@tests/Form/InputRadioTest.php`:
- Around line 199-202: Test method names still reference the old API name
addAttribute while the test bodies use setAttribute(); rename the offending test
methods (e.g., change testRenderWithAddAttribute to testRenderWithSetAttribute
and testRenderWithAddAttributeUsingEnum to testRenderWithSetAttributeUsingEnum)
and update any other test method names that mention addAttribute so names match
the new setAttribute API (look for methods in InputRadioTest named
testRenderWithAddAttribute*).
In `@tests/Sectioning/NavTest.php`:
- Line 64: Rename the test methods that still reference the old addAttribute
naming to match the API change to setAttribute: specifically rename
testRenderWithAddAttribute and testRenderWithAddAttributeUsingEnum (and any
other test method names containing "AddAttribute", e.g., the ones reported
around the other occurrences) to use "setAttribute" in their method names and
any related docblocks/assertion messages so names reflect the updated API while
keeping the internal calls (->setAttribute(...)) unchanged.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (79)
composer.jsonsrc/Embedded/Attribute/HasElementtiming.phpsrc/Embedded/Attribute/HasIsmap.phpsrc/Form/Attribute/HasFormaction.phpsrc/Form/Attribute/HasFormenctype.phpsrc/Form/Attribute/HasFormmethod.phpsrc/Form/Attribute/HasFormnovalidate.phpsrc/Form/Attribute/HasFormtarget.phpsrc/Form/Base/BaseChoice.phpsrc/Form/InputCheckbox.phpsrc/Form/InputRadio.phpsrc/Form/Mixin/CanBeUnchecked.phpsrc/Form/Mixin/HasLabel.phpsrc/List/Attribute/HasReversed.phpsrc/List/Attribute/HasStart.phpsrc/Metadata/Attribute/HasAsync.phpsrc/Metadata/Attribute/HasDefer.phpsrc/Metadata/Attribute/HasNomodule.phpsrc/Metadata/Attribute/HasShadowRootClonable.phpsrc/Metadata/Attribute/HasShadowRootDelegatesFocus.phpsrc/Metadata/Attribute/HasShadowRootMode.phpsrc/Metadata/Attribute/HasShadowRootReferenceTarget.phpsrc/Metadata/Attribute/HasShadowRootSerializable.phpsrc/Phrasing/Label.phptests/Embedded/ImgTest.phptests/Flow/DivTest.phptests/Flow/HrTest.phptests/Flow/MainTest.phptests/Flow/PTest.phptests/Form/InputCheckboxTest.phptests/Form/InputHiddenTest.phptests/Form/InputImageTest.phptests/Form/InputMonthTest.phptests/Form/InputNumberTest.phptests/Form/InputPasswordTest.phptests/Form/InputRadioTest.phptests/Form/InputRangeTest.phptests/Form/InputResetTest.phptests/Form/InputSearchTest.phptests/Form/InputSubmitTest.phptests/Form/InputTelTest.phptests/Form/InputTextTest.phptests/Form/InputTimeTest.phptests/Form/InputUrlTest.phptests/Form/InputWeekTest.phptests/Heading/H1Test.phptests/Heading/H2Test.phptests/Heading/H3Test.phptests/Heading/H4Test.phptests/Heading/H5Test.phptests/Heading/H6Test.phptests/Heading/HGroupTest.phptests/List/DdTest.phptests/List/DlTest.phptests/List/DtTest.phptests/List/LiTest.phptests/List/OlTest.phptests/List/UlTest.phptests/Metadata/BaseTest.phptests/Metadata/LinkTest.phptests/Metadata/MetaTest.phptests/Metadata/NoScriptTest.phptests/Metadata/ScriptTest.phptests/Metadata/StyleTest.phptests/Metadata/TemplateTest.phptests/Metadata/TitleTest.phptests/Palpable/ATest.phptests/Phrasing/ITest.phptests/Phrasing/LabelTest.phptests/Phrasing/SpanTest.phptests/Root/BodyTest.phptests/Root/FooterTest.phptests/Root/HeadTest.phptests/Root/HeaderTest.phptests/Root/HtmlTest.phptests/Sectioning/ArticleTest.phptests/Sectioning/AsideTest.phptests/Sectioning/NavTest.phptests/Sectioning/SectionTest.php
💤 Files with no reviewable changes (1)
- src/Form/Mixin/HasLabel.php
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2026-02-06T21:37:44.509Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 24
File: tests/Form/InputTextTest.php:33-620
Timestamp: 2026-02-06T21:37:44.509Z
Learning: In the ui-awesome/html repository, prefer individual test methods over PHPUnit data providers in test classes. This helps maintainers see exactly how each test behaves without cross-referencing data providers. Apply to all PHP test files under tests. Use separate, descriptively named test methods to cover different inputs/edge cases; retain data providers only if they clearly improve readability or reduce duplication.
Applied to files:
tests/Form/InputUrlTest.phptests/List/DtTest.phptests/Metadata/NoScriptTest.phptests/Heading/HGroupTest.phptests/Flow/PTest.phptests/Form/InputSearchTest.phptests/Flow/MainTest.phptests/Phrasing/SpanTest.phptests/Root/HtmlTest.phptests/Phrasing/ITest.phptests/Heading/H5Test.phptests/Form/InputRangeTest.phptests/Root/FooterTest.phptests/Form/InputTextTest.phptests/Root/HeadTest.phptests/Palpable/ATest.phptests/Flow/HrTest.phptests/List/DdTest.phptests/Form/InputSubmitTest.phptests/Flow/DivTest.phptests/Sectioning/ArticleTest.phptests/Form/InputResetTest.phptests/Metadata/StyleTest.phptests/Metadata/ScriptTest.phptests/Form/InputWeekTest.phptests/Sectioning/AsideTest.phptests/Metadata/BaseTest.phptests/Phrasing/LabelTest.phptests/List/LiTest.phptests/Form/InputImageTest.phptests/Metadata/TitleTest.phptests/Sectioning/SectionTest.phptests/Root/HeaderTest.phptests/List/OlTest.phptests/Metadata/LinkTest.phptests/Heading/H1Test.phptests/Form/InputTimeTest.phptests/Heading/H4Test.phptests/Heading/H6Test.phptests/Form/InputMonthTest.phptests/Heading/H2Test.phptests/Sectioning/NavTest.phptests/Embedded/ImgTest.phptests/Form/InputTelTest.phptests/Heading/H3Test.phptests/Metadata/TemplateTest.phptests/Form/InputCheckboxTest.phptests/Form/InputHiddenTest.phptests/Form/InputNumberTest.phptests/Form/InputRadioTest.phptests/Form/InputPasswordTest.phptests/List/DlTest.phptests/Root/BodyTest.phptests/List/UlTest.phptests/Metadata/MetaTest.php
📚 Learning: 2026-02-11T14:56:18.277Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:18.277Z
Learning: In PHP test files under the repository ui-awesome/html (e.g., tests/Form/InputTextTest.php), it is acceptable to use short variable names (e.g., 2-character names like $id). PHPMD's short-variable rule does not need to be strictly followed in test code. During reviews, allow short names in test files and note that this relaxed style applies to tests, while production code should adhere to the standard variable naming conventions.
Applied to files:
tests/Form/InputUrlTest.phptests/List/DtTest.phptests/Metadata/NoScriptTest.phptests/Heading/HGroupTest.phptests/Flow/PTest.phptests/Form/InputSearchTest.phptests/Flow/MainTest.phptests/Phrasing/SpanTest.phptests/Root/HtmlTest.phptests/Phrasing/ITest.phptests/Heading/H5Test.phptests/Form/InputRangeTest.phptests/Root/FooterTest.phptests/Form/InputTextTest.phptests/Root/HeadTest.phptests/Palpable/ATest.phptests/Flow/HrTest.phptests/List/DdTest.phptests/Form/InputSubmitTest.phptests/Flow/DivTest.phptests/Sectioning/ArticleTest.phptests/Form/InputResetTest.phptests/Metadata/StyleTest.phptests/Metadata/ScriptTest.phptests/Form/InputWeekTest.phptests/Sectioning/AsideTest.phptests/Metadata/BaseTest.phptests/Phrasing/LabelTest.phptests/List/LiTest.phptests/Form/InputImageTest.phptests/Metadata/TitleTest.phptests/Sectioning/SectionTest.phptests/Root/HeaderTest.phptests/List/OlTest.phptests/Metadata/LinkTest.phptests/Heading/H1Test.phptests/Form/InputTimeTest.phptests/Heading/H4Test.phptests/Heading/H6Test.phptests/Form/InputMonthTest.phptests/Heading/H2Test.phptests/Sectioning/NavTest.phptests/Embedded/ImgTest.phptests/Form/InputTelTest.phptests/Heading/H3Test.phptests/Metadata/TemplateTest.phptests/Form/InputCheckboxTest.phptests/Form/InputHiddenTest.phptests/Form/InputNumberTest.phptests/Form/InputRadioTest.phptests/Form/InputPasswordTest.phptests/List/DlTest.phptests/Root/BodyTest.phptests/List/UlTest.phptests/Metadata/MetaTest.php
📚 Learning: 2026-02-09T11:28:09.334Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 35
File: tests/Provider/Form/CheckedProvider.php:13-14
Timestamp: 2026-02-09T11:28:09.334Z
Learning: In the ui-awesome/html repository, using `str_replace` to adapt shared data provider HTML strings for different input types (e.g., adapting `CheckedProvider` for both `InputCheckboxTest` and `InputRadioTest` by replacing "inputcheckbox-" with "inputradio-" and "checkbox" with "radio") is acceptable and considered clear. Don't suggest refactoring such patterns to avoid string replacement.
Applied to files:
tests/Form/InputTextTest.phptests/Form/InputSubmitTest.phptests/Form/InputCheckboxTest.phptests/Form/InputRadioTest.php
📚 Learning: 2026-02-07T18:51:41.006Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 31
File: src/Form/Mixin/HasLabel.php:195-195
Timestamp: 2026-02-07T18:51:41.006Z
Learning: In the ui-awesome/html repository, explicit boolean comparisons (e.g., `isset($var) === false`) are required instead of negation operators (e.g., `!isset($var)`) due to PHPStan strict rules configuration at the highest level.
Applied to files:
composer.json
📚 Learning: 2026-02-11T14:56:26.855Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 37
File: tests/Form/InputTextTest.php:448-457
Timestamp: 2026-02-11T14:56:26.855Z
Learning: In the ui-awesome/html repository, short variable names (e.g., 2-character names like `$id`) are acceptable in test files and should not be flagged. PHPMD's short-variable rule does not need to be strictly followed in test code.
Applied to files:
composer.json
🧬 Code graph analysis (1)
src/Form/InputRadio.php (1)
src/Form/Base/BaseChoice.php (1)
BaseChoice(19-115)
🪛 PHPMD (2.15.0)
src/Form/Base/BaseChoice.php
[warning] 50-50: Avoid variables with short names like $id. Configured minimum length is 3. (undefined)
(ShortVariable)
[error] 100-100: Avoid using static access to class '\UIAwesome\Html\Core\Html' in method 'run'. (undefined)
(StaticAccess)
🔇 Additional comments (63)
src/List/Attribute/HasStart.php (2)
10-10: LGTM!The
@mixinannotation correctly documents the dependency on\UIAwesome\Html\Mixin\HasAttributes, which provides thesetAttributemethod used in this trait.
31-34: LGTM!The migration from
addAttribute()tosetAttribute()is consistent with the updatedhtml-mixin ^0.4API. The immutable return pattern and public signature are preserved.tests/Heading/HGroupTest.php (1)
64-64:addAttribute()→setAttribute()migration looks correct.All call sites in this test file have been consistently updated from
addAttribute()tosetAttribute(), and the assertion messages on lines 137 and 151 were updated to match. No issues.Also applies to: 135-135, 149-149, 510-510
tests/Palpable/ATest.php (1)
65-74:addAttribute()→setAttribute()migration applied correctly.The method calls at Lines 70, 135, 148, and 530 correctly use the new
setAttribute()API, and assertion messages at Lines 137 and 150 are updated to match. The rest of the file is unchanged and looks good.Also applies to: 128-139, 523-535
tests/Flow/PTest.php (1)
59-68: API rename applied consistently.All
addAttribute()calls replaced withsetAttribute(), and assertion messages updated accordingly. Changes are correct.Also applies to: 127-153, 502-515
src/Embedded/Attribute/HasIsmap.php (1)
10-10: Production trait correctly updated to usesetAttribute()with@mixinannotation.The
@mixin \UIAwesome\Html\Mixin\HasAttributesdocblock (Line 10) properly informs static analysis thatsetAttribute()is available, and the implementation at Line 32 correctly delegates to it. This aligns with the broader PR migration.Also applies to: 30-33
tests/Root/HeaderTest.php (1)
59-68: API rename applied consistently.Same mechanical
addAttribute()→setAttribute()migration as the other test files. Changes look correct.Also applies to: 127-153, 502-515
tests/Form/InputTimeTest.php (1)
183-209: API rename applied correctly across all changed segments.
setAttribute()calls and updated assertion messages are consistent with the broader migration.Also applies to: 684-697
tests/Form/InputSearchTest.php (1)
184-207: API rename applied correctly.All
addAttribute()calls migrated tosetAttribute()with updated assertion messages.Also applies to: 629-642
tests/Form/InputTelTest.php (1)
185-211: API rename applied correctly.Consistent
addAttribute()→setAttribute()migration with updated assertion messages.Also applies to: 699-712
tests/Form/InputNumberTest.php (1)
184-210: API rename applied correctly.Consistent
addAttribute()→setAttribute()migration with updated assertion messages.Also applies to: 699-712
tests/Form/InputWeekTest.php (1)
191-194:addAttribute()→setAttribute()migration looks correct.The method calls and assertion messages are consistently updated. The
removeAttributetest at line 690 also correctly usessetAttributeto set up the attribute before removal.Also applies to: 205-208, 690-690
tests/Form/InputResetTest.php (1)
190-193:addAttribute()→setAttribute()migration is consistent and correct.Same rename pattern as in the other test files. Method calls and assertion messages are properly aligned.
Also applies to: 204-207, 578-578
tests/Phrasing/ITest.php (1)
62-62:addAttribute()→setAttribute()migration is consistent and correct.All updated call sites and assertion messages align with the new API. The
getAttributes()test at line 62 also properly usessetAttributeto set up the state being verified.Also applies to: 127-129, 140-142, 392-392
tests/Flow/HrTest.php (1)
51-51: LGTM!The
addAttribute()→setAttribute()migration is consistent and correctly applied across all changed segments.Also applies to: 103-105, 116-118, 353-353
tests/Form/InputImageTest.php (1)
191-194:addAttribute()→setAttribute()migration is consistent and correct.Also applies to: 205-208, 677-677
tests/Embedded/ImgTest.php (1)
63-63: LGTM!The
addAttribute()→setAttribute()migration is consistent and correctly applied.Also applies to: 115-117, 128-130, 560-560
tests/Flow/MainTest.php (1)
64-64: LGTM!The
addAttribute()→setAttribute()migration is consistent and correctly applied.Also applies to: 135-137, 149-151, 510-510
src/Embedded/Attribute/HasElementtiming.php (1)
10-37: LGTM!The
@mixinannotation correctly documents the dependency onHasAttributes, and thesetAttributedelegation is clean.src/List/Attribute/HasReversed.php (1)
10-33: LGTM!Clean migration to
setAttributewith proper@mixinannotation.tests/Metadata/StyleTest.php (1)
70-71: LGTM —setAttributemigration is consistent.The
addAttribute→setAttributereplacement intestGetAttributesReturnsAssignedAttributesandtestRenderWithRemoveAttributeis correct and aligns with the updated API.tests/Heading/H6Test.php (1)
64-65: LGTM — consistentsetAttributemigration.All
addAttribute→setAttributereplacements and message updates are correct and aligned with the API rename.Also applies to: 135-137, 149-151, 510-511
tests/Root/HtmlTest.php (1)
64-65: LGTM — consistentsetAttributemigration.Also applies to: 135-137, 149-151, 510-511
tests/Metadata/NoScriptTest.php (1)
64-65: LGTM — consistentsetAttributemigration.Also applies to: 135-137, 149-151, 521-522
tests/Metadata/TitleTest.php (1)
64-65: LGTM — consistentsetAttributemigration.Also applies to: 135-137, 149-151, 522-523
tests/Phrasing/SpanTest.php (1)
62-63: LGTM — consistentsetAttributemigration.Also applies to: 125-127, 138-140, 390-391
tests/Metadata/LinkTest.php (1)
62-63: LGTM — consistentsetAttributemigration.Also applies to: 114-116, 127-129, 599-600
tests/Heading/H2Test.php (1)
64-65: LGTM — consistentsetAttributemigration.Also applies to: 135-137, 149-151, 510-511
tests/Heading/H5Test.php (1)
64-64:setAttribute()migration looks correct.All
addAttribute()call sites have been consistently updated tosetAttribute(), and assertion messages match the new API. The test logic and expected outputs remain sound.Also applies to: 135-135, 149-149, 508-508
src/Metadata/Attribute/HasShadowRootClonable.php (1)
10-10: LGTM!The
@mixinannotation and theaddAttribute→setAttributemigration are consistent with the project-wide refactor.Also applies to: 34-34
src/Phrasing/Label.php (1)
44-44: LGTM!Clean migration from
addAttributetosetAttributefor theforattribute.tests/Flow/DivTest.php (1)
64-64: LGTM!The
setAttributecalls and updated assertion messages are consistent with the API migration.Also applies to: 135-135, 149-149, 510-510
tests/List/OlTest.php (1)
65-65: LGTM!Consistent
setAttributemigration. The test method naming inconsistency (testRenderWithAddAttribute) was noted in the DivTest review and applies here as well.Also applies to: 136-138, 150-152, 574-574
tests/Sectioning/AsideTest.php (1)
64-64: LGTM!Consistent
setAttributemigration matching the project-wide refactor.Also applies to: 135-137, 149-151, 510-510
src/Metadata/Attribute/HasShadowRootMode.php (1)
15-15: LGTM!The
@mixinannotation andsetAttributecall are consistent with the rest of the migration.Also applies to: 45-45
tests/Sectioning/SectionTest.php (1)
64-64: LGTM!Consistent
setAttributemigration matching the project-wide refactor.Also applies to: 135-137, 149-151, 510-510
tests/List/DlTest.php (1)
64-64: LGTM!Consistent
setAttributemigration matching the project-wide refactor.Also applies to: 135-137, 149-151, 573-573
src/Form/Attribute/HasFormenctype.php (1)
13-36: LGTM!The
@mixinannotation andsetAttribute()migration are consistent with the broader refactor.src/Form/Attribute/HasFormnovalidate.php (1)
10-32: LGTM!Consistent with the
addAttribute→setAttributemigration pattern.src/Metadata/Attribute/HasAsync.php (1)
10-35: LGTM!Consistent
@mixinannotation andsetAttribute()migration.src/Form/Attribute/HasFormtarget.php (1)
13-36: LGTM!Consistent with the migration pattern across all trait files.
src/Metadata/Attribute/HasShadowRootReferenceTarget.php (1)
13-13: LGTM — consistent migration tosetAttribute()with proper@mixinannotation.The docblock now correctly declares the
HasAttributesmixin dependency, and the internal call is updated fromaddAttribute()tosetAttribute(). Method signature and immutability contract are preserved.Also applies to: 34-37
tests/Root/BodyTest.php (1)
59-68: RemainingsetAttribute()call sites look correct.Lines 64, 510:
setAttribute()calls intestGetAttributesReturnsAssignedAttributesandtestRenderWithRemoveAttributeare consistent with the API migration. Assertion messages and expected outcomes remain accurate.Also applies to: 502-515
src/Form/InputRadio.php (1)
32-57: Clean refactor toBaseChoice— shared rendering logic is correctly inherited.
InputRadionow cleanly extendsBaseChoice, which encapsulates all the previously duplicated trait usages (CanBeAutofocus,HasCheckedState,HasValue, etc.) and rendering logic (getAttributes(),run()). TheloadDefault()correctly uses PHP array union (+) to giveInputRadio's owntemplateandtypekeys precedence over parent defaults.tests/Metadata/BaseTest.php (1)
52-61: RemainingsetAttribute()changes are consistent and correct.The updates in
testGetAttributesReturnsAssignedAttributes(line 57) andtestRenderWithRemoveAttribute(line 386) properly reflect the API migration. Test logic and assertions are sound.Also applies to: 379-391
tests/List/DdTest.php (1)
59-68:setAttribute()migration in attribute retrieval and removal tests looks correct.Also applies to: 502-515
src/Form/Attribute/HasFormmethod.php (1)
13-13: LGTM — consistentaddAttribute()→setAttribute()migration with proper@mixinannotation.Also applies to: 33-36
src/Metadata/Attribute/HasShadowRootDelegatesFocus.php (1)
10-10: LGTM — clean migration tosetAttribute()for the booleanshadowrootdelegatesfocusattribute.Also applies to: 32-35
src/Metadata/Attribute/HasShadowRootSerializable.php (1)
10-10: LGTM — consistent with the PR-widesetAttribute()migration.Also applies to: 32-35
src/Metadata/Attribute/HasNomodule.php (1)
10-35: LGTM!The
@mixinannotation andsetAttribute()delegation are consistent with the project-wide refactor.src/Metadata/Attribute/HasDefer.php (1)
10-35: LGTM!Consistent with the
addAttribute→setAttributemigration.tests/Sectioning/ArticleTest.php (1)
127-153: LGTM!Test method names (
testRenderWithAddAttribute,testRenderWithAddAttributeUsingEnum) still reference the oldaddAttributenaming while the calls and messages now usesetAttribute. This is a minor inconsistency but not a functional issue — the test names still describe the concept being tested.tests/Form/InputCheckboxTest.php (2)
190-216: LGTM!Mechanical
addAttribute→setAttributerename in test calls and assertion messages, consistent with the project-wide migration.
737-752: Test verifieslabelClass(null)acts as a no-op when label classes already exist.The test correctly demonstrates that calling
labelClass(null)after setting label attributes with a class value (labelAttributes(['class' => 'value'])) preserves the existing class. This behavior is consistent across form elements (InputCheckbox, InputRadio) and appears intentional. However, since this test is newly added, the claim of a "behavioral change" cannot be verified—this may reflect the original design rather than a recent modification from the dependency update.tests/Metadata/MetaTest.php (1)
52-126: LGTM!All
addAttribute→setAttributerenames in test calls and messages are consistent.src/Form/Attribute/HasFormaction.php (1)
13-35: LGTM!Consistent
@mixinannotation andsetAttribute()delegation.tests/List/UlTest.php (1)
127-153: LGTM!Consistent
setAttributemigration in test calls and messages.src/Form/Base/BaseChoice.php (3)
47-114: Well-structured rendering logic with clear separation of label placement strategies.The three rendering paths (no label, external label, enclosed-by-label) are clean and handle the
uncheckedValuehidden input consistently across all branches.
78-84: No issue —Label::for()explicitly acceptsnullvalues.The
Label::for()method signature ispublic function for(string|null $value = null): static, which explicitly permitsnull. The call on line 83 is safe regardless of whether$idisnull.Likely an incorrect or invalid review comment.
96-113: No action needed. The code correctly replaces the{tag}placeholder with the pre-rendered$labelTag(which already contains the input element) rather than separately rendering an additional input element. Test cases confirm this behavior prevents double-rendering.src/Form/Mixin/CanBeUnchecked.php (1)
1-51: Well-structured immutable trait.Clean implementation following the immutable-setter pattern consistent with the rest of the codebase. The type union covers the expected form value types.
tests/Form/InputRadioTest.php (1)
746-761: Verify thelabelClass(null)behavior change.The test
testRenderWithLabelClassNullValue()explicitly validates that callinglabelClass(null)afterlabelAttributes(['class' => 'value'])retainsclass="value"in the rendered output. While I could not locate thelabelClass()method implementation to confirm the null-handling semantics directly, the test expectation clearly shows the behavior is intentional:nulloperates as a no-op that preserves existing class attributes rather than clearing them. Confirm this matches the intended API semantics.src/Form/InputCheckbox.php (1)
31-56: Verify template newline handling with actual rendered output.The template string
'{prefix}\n{unchecked}\n{tag}\n{label}\n{suffix}'uses single quotes where\nis a literal backslash-n, not a newline character. This pattern appears in both InputCheckbox (line 53) and InputRadio (line 54) identically, suggesting intentional design. However, confirm that the template engine orbuildElement()method from the parent package correctly interprets this as line separators in the rendered output, or switch to double quotes if actual newlines are required.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Pull Request