feat(form): Add InputDate class for HTML <input type="date"> element with attributes and rendering capabilities.#52
Conversation
…ent with attributes and rendering capabilities.
📝 WalkthroughSummary by CodeRabbit
WalkthroughIntroduces a new InputDate form component class that extends BaseInput to render HTML Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 155 158 +3
===========================================
Files 80 81 +1
Lines 370 376 +6
===========================================
+ Hits 370 376 +6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
CHANGELOG.mdsrc/Form/InputDate.phptests/Form/InputDateTest.php
🧰 Additional context used
🧠 Learnings (3)
📚 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/InputDateTest.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/InputDateTest.php
📚 Learning: 2026-02-21T01:17:40.877Z
Learnt from: terabytesoftw
Repo: ui-awesome/html PR: 51
File: tests/List/UlTest.php:282-283
Timestamp: 2026-02-21T01:17:40.877Z
Learning: In the ui-awesome/html repository, for PHP tests, ensure that assertion messages in tests/List/UlTest.php for methods named testRenderWith*UsingEnum remain identical to the corresponding non-enum tests (i.e., do not append 'using enum' to the failure message). The reason: the underlying render method treats enum and string inputs the same, so failure output should be uniform. Apply this pattern to all similar test cases under tests/ to maintain consistent failure messages across enum vs non-enum variants.
Applied to files:
tests/Form/InputDateTest.php
🧬 Code graph analysis (2)
src/Form/InputDate.php (1)
src/Root/Html.php (1)
Html(27-40)
tests/Form/InputDateTest.php (4)
src/Root/Html.php (1)
Html(27-40)src/Form/InputDate.php (1)
InputDate(51-96)tests/Support/Stub/DefaultProvider.php (1)
DefaultProvider(17-34)tests/Support/Stub/DefaultThemeProvider.php (1)
DefaultThemeProvider(17-39)
🪛 PHPMD (2.15.0)
tests/Form/InputDateTest.php
[warning] 42-1022: The class InputDateTest has 67 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)
(ExcessivePublicCount)
[warning] 42-1022: The class InputDateTest has 67 non-getter- and setter-methods. Consider refactoring InputDateTest to keep number of methods under 25. (undefined)
(TooManyMethods)
[warning] 42-1022: The class InputDateTest has 67 public methods. Consider refactoring InputDateTest to keep number of public methods under 10. (undefined)
(TooManyPublicMethods)
[warning] 42-1022: The class InputDateTest has an overall complexity of 67 which is very high. The configured complexity threshold is 50. (undefined)
(ExcessiveClassComplexity)
[error] 42-1022: The class InputDateTest has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13. (undefined)
(CouplingBetweenObjects)
[warning] 544-544: Avoid variables with short names like $id. Configured minimum length is 3. (undefined)
(ShortVariable)
[error] 555-558: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 570-573: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)
(StaticAccess)
[error] 987-993: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
[error] 1003-1006: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)
(StaticAccess)
⏰ 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). (9)
- GitHub Check: composer-require-checker / PHP 8.5-ubuntu-latest
- GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
- GitHub Check: linter / Super Linter
- GitHub Check: mutation / PHP 8.5-ubuntu-latest
- GitHub Check: phpunit / PHP 8.4-windows-2022
- GitHub Check: phpunit / PHP 8.4-ubuntu-latest
- GitHub Check: phpunit / PHP 8.2-windows-2022
- GitHub Check: phpunit / PHP 8.1-windows-2022
- GitHub Check: phpunit / PHP 8.3-windows-2022
🔇 Additional comments (3)
src/Form/InputDate.php (1)
51-95: LGTM — well-structured and consistent with sibling input classes.The MDN
@linkat line 46 using/Reference/Elements/(instead of the older/Element/) resolves correctly; MDN restructured their HTML reference paths and both URLs are live.Trait selection matches every spec-valid attribute for
<input type="date">(autocomplete,autofocus,form,list,max,min,readonly,required,step,tabindex,value). The+union operator inloadDefault()is correct here — as long asBaseInput::loadDefault()does not already set atypekey (confirmed by test output), the child'sType::DATEis applied via the right-hand side.tests/Form/InputDateTest.php (1)
41-1022: Comprehensive test suite — well-aligned with project conventions.
- All 67 tests are individual methods with no data providers — compliant with the project preference.
- Every enum/non-enum pair (
testRenderWith*vstestRenderWith*UsingEnum) carries identical assertion messages — compliant with the cross-repo learning.- The short
$idat line 544 is acceptable per the project's relaxed short-variable rule for test code.- PHPMD warnings (
TooManyMethods,ExcessivePublicCount,CouplingBetweenObjects) are expected consequences of the deliberately granular individual-method style; they are not actionable here.Based on learnings from PRs
#24,#37, and#51in this repository: individual test methods are preferred over data providers, short variable names are acceptable in test code, and assertion messages in enum vs non-enum variant tests must be identical.CHANGELOG.md (1)
39-39: LGTM — changelog entry is correctly formatted and placed.
Enh#51`` correctly references the issue number (PR is#52), the description matches the PR objective, and the entry is in the right `0.4.0 Under development` section following the established format.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/Form/InputDateTest.php`:
- Around line 553-574: The test methods testRenderWithGlobalDefaultsAreApplied
and testRenderWithUserOverridesGlobalDefaults set global defaults via
SimpleFactory::setDefaults but reset them only after assertions, so failures can
leak state; wrap the arrangement and assertion in a try/finally in each test:
call SimpleFactory::setDefaults(InputDate::class, ['class'=>'default-class'])
(or the user-overrides setup) before the try, perform the assertion inside the
try block, and always call SimpleFactory::setDefaults(InputDate::class, [])
inside the finally to ensure cleanup regardless of test outcome.
Pull Request