Skip to content

feat(form): Add InputWeek class for HTML <input type="week"> element with attributes and rendering capabilities.#19

Merged
terabytesoftw merged 2 commits intomainfrom
feature_2
Feb 6, 2026
Merged

feat(form): Add InputWeek class for HTML <input type="week"> element with attributes and rendering capabilities.#19
terabytesoftw merged 2 commits intomainfrom
feature_2

Conversation

@terabytesoftw
Copy link
Contributor

Pull Request

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

…ent with attributes and rendering capabilities.
@terabytesoftw terabytesoftw added the enhancement New feature or request label Feb 6, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a week input form element for selecting year-week values, supporting min/max, value binding, autofocus, readonly, required, tabindex, list association, and standard HTML5 form attributes.
  • Tests
    • Added comprehensive unit tests covering rendering, attribute handling, defaults, and theme/provider integration.

Walkthrough

Adds a new InputWeek form element class implementing HTML input type="week" with attribute support and rendering; includes comprehensive unit tests and a changelog entry.

Changes

Cohort / File(s) Summary
Core Implementation
src/Form/InputWeek.php
Adds InputWeek (extends BaseInput) implementing input type="week", defines getTag(), loadDefault(), and run(), and composes relevant attribute traits (autocomplete, form, list, min, max, readonly, required, step, tabindex, value, autofocus).
Tests & Changelog
tests/Form/InputWeekTest.php, CHANGELOG.md
Adds comprehensive tests covering rendering, attribute behaviour, factories, theme/default providers, and toString; updates CHANGELOG.md with entry for the new element.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble on weeks with gentle cheer,
New inputs sprout for month-and-year,
Attributes tucked in tidy rows,
Rendered neat where HTML flows,
Hooray — a small hop of code, sincere!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.66% 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
Title check ✅ Passed The title accurately describes the main change: adding a new InputWeek class for HTML input type="week" element with attributes and rendering capabilities.
Description check ✅ Passed The description clearly indicates this is a new feature with no breaking changes, which aligns with the changeset that adds the InputWeek class and related tests.

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

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.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (52c315d) to head (707dd9b).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #19   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity        63        66    +3     
===========================================
  Files             50        51    +1     
  Lines            133       139    +6     
===========================================
+ Hits             133       139    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 2

🤖 Fix all issues with AI agents
In `@tests/Form/InputWeekTest.php`:
- Around line 32-601: The test class InputWeekTest has many near-duplicate tests
(e.g., testRenderWithDir & testRenderWithDirUsingEnum, testRenderWithLang &
testRenderWithLangUsingEnum, testRenderWithRole & testRenderWithRoleUsingEnum,
testRenderWithTranslate & testRenderWithTranslateUsingEnum, autocomplete
variants, attribute/data/aria pairs, etc.); collapse each duplicated pair/group
into a single parameterized test that accepts input name, expected attribute
string and the setter call variant, and add a corresponding data provider method
that returns arrays of (label, setter-argument, expected-html) entries; annotate
the consolidated test methods with `@dataProvider`, update assertions to use the
passed expected string, and remove the original individual test methods (keep
their assertions preserved in the data provider rows) so InputWeekTest uses
providers and reduces public method count while retaining coverage.
- Around line 515-524: The test calls the method with incorrect casing: replace
the lowercase call tabindex() in testRenderWithTabindex() with the actual trait
method name tabIndex() so the line
InputWeek::tag()->id('inputweek-')->tabindex(1)->render() becomes
InputWeek::tag()->id('inputweek-')->tabIndex(1)->render(); this aligns the test
with the defined method tabIndex() and resolves the PHPStan/mutation test
failure.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52c315d and 9b33a23.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/Form/InputWeek.php
  • tests/Form/InputWeekTest.php
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Form/InputWeekTest.php (1)
src/Form/InputWeek.php (1)
  • InputWeek (51-96)
🪛 GitHub Check: mutation / PHP 8.5-ubuntu-latest
tests/Form/InputWeekTest.php

[failure] 521-521:
Call to method UIAwesome\Html\Form\InputWeek::tabIndex() with incorrect case: tabindex

🪛 GitHub Check: phpstan / PHP 8.5-ubuntu-latest
tests/Form/InputWeekTest.php

[failure] 521-521:
Call to method UIAwesome\Html\Form\InputWeek::tabIndex() with incorrect case: tabindex

🪛 PHPMD (2.15.0)
tests/Form/InputWeekTest.php

[warning] 32-601: The class InputWeekTest has 50 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)

(ExcessivePublicCount)


[warning] 32-601: The class InputWeekTest has 50 non-getter- and setter-methods. Consider refactoring InputWeekTest to keep number of methods under 25. (undefined)

(TooManyMethods)


[warning] 32-601: The class InputWeekTest has 50 public methods. Consider refactoring InputWeekTest to keep number of public methods under 10. (undefined)

(TooManyPublicMethods)


[warning] 32-601: The class InputWeekTest has an overall complexity of 50 which is very high. The configured complexity threshold is 50. (undefined)

(ExcessiveClassComplexity)


[error] 32-601: The class InputWeekTest has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. (undefined)

(CouplingBetweenObjects)


[error] 279-279: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 287-287: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 552-552: Avoid using static access to class '\PHPForge\Support\LineEndingNormalizer' in method 'testRenderWithToString'. (undefined)

(StaticAccess)


[error] 552-552: Avoid using static access to class '\UIAwesome\Html\Form\InputWeek' in method 'testRenderWithToString'. (undefined)

(StaticAccess)


[error] 581-581: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 588-588: 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). (10)
  • GitHub Check: phpunit / PHP 8.5-windows-2022
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-windows-2022
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-windows-2022
  • GitHub Check: linter / Super Linter
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: linter / Super Linter
🔇 Additional comments (2)
src/Form/InputWeek.php (1)

1-96: Clean implementation following established patterns.

The class is well-structured, properly documented with usage examples and MDN link, and follows the same pattern as other input types in the library. The trait composition covers the relevant HTML attributes for <input type="week">.

CHANGELOG.md (1)

7-7: Verify the issue/PR number reference.

The CHANGELOG references #18, but this pull request is #19. Please confirm whether #18 is the corresponding issue number or if this should be #19 to match the PR.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

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 `@tests/Form/InputWeekTest.php`:
- Around line 277-288: Wrap the SimpleFactory::setDefaults usage in both test
methods so cleanup always runs: in testRenderWithGlobalDefaultsAreApplied and
testRenderWithUserOverridesGlobalDefaults, call
SimpleFactory::setDefaults(InputWeek::class, ['class'=>'default-class']) (or the
override values) inside the try block and move
SimpleFactory::setDefaults(InputWeek::class, []) into a finally block to
guarantee global defaults are cleared even if the assertion throws; locate these
calls by the method names testRenderWithGlobalDefaultsAreApplied,
testRenderWithUserOverridesGlobalDefaults and the SimpleFactory::setDefaults
references.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b33a23 and 707dd9b.

📒 Files selected for processing (1)
  • tests/Form/InputWeekTest.php
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Form/InputWeekTest.php (1)
src/Form/InputWeek.php (1)
  • InputWeek (51-96)
🪛 PHPMD (2.15.0)
tests/Form/InputWeekTest.php

[warning] 32-601: The class InputWeekTest has 50 public methods and attributes. Consider reducing the number of public items to less than 45. (undefined)

(ExcessivePublicCount)


[warning] 32-601: The class InputWeekTest has 50 non-getter- and setter-methods. Consider refactoring InputWeekTest to keep number of methods under 25. (undefined)

(TooManyMethods)


[warning] 32-601: The class InputWeekTest has 50 public methods. Consider refactoring InputWeekTest to keep number of public methods under 10. (undefined)

(TooManyPublicMethods)


[warning] 32-601: The class InputWeekTest has an overall complexity of 50 which is very high. The configured complexity threshold is 50. (undefined)

(ExcessiveClassComplexity)


[error] 32-601: The class InputWeekTest has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. (undefined)

(CouplingBetweenObjects)


[error] 279-279: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 287-287: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithGlobalDefaultsAreApplied'. (undefined)

(StaticAccess)


[error] 552-552: Avoid using static access to class '\PHPForge\Support\LineEndingNormalizer' in method 'testRenderWithToString'. (undefined)

(StaticAccess)


[error] 552-552: Avoid using static access to class '\UIAwesome\Html\Form\InputWeek' in method 'testRenderWithToString'. (undefined)

(StaticAccess)


[error] 581-581: Avoid using static access to class '\UIAwesome\Html\Core\Factory\SimpleFactory' in method 'testRenderWithUserOverridesGlobalDefaults'. (undefined)

(StaticAccess)


[error] 588-588: 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). (11)
  • GitHub Check: easy-coding-standard / PHP 8.5-ubuntu-latest
  • GitHub Check: phpstan / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.2-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.1-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
  • GitHub Check: phpunit / PHP 8.3-ubuntu-latest
  • GitHub Check: mutation / PHP 8.5-ubuntu-latest
  • GitHub Check: phpunit / PHP 8.4-ubuntu-latest
  • GitHub Check: linter / Super Linter
🔇 Additional comments (3)
tests/Form/InputWeekTest.php (3)

1-41: Test structure and basic attribute tests look good.

The file is well-organized with clear, descriptive test names and assertion messages. The testGetAttributeReturnsDefaultWhenMissing test correctly verifies the fallback behavior.


43-513: Attribute and rendering tests are thorough and correct.

The tests cover a comprehensive set of attributes (accesskey, aria, data, autocomplete, autofocus, class, dir, disabled, form, hidden, id, lang, list, max, min, name, readonly, required, role, step, style, title) with both string and enum variants where applicable. Assertion messages are consistently descriptive. The min/max combination test at lines 367–380 is a good addition for verifying multi-attribute rendering.


526-601: Provider, toString, translate, and value tests look correct.

Theme provider, default provider, __toString, translate (both string and enum), and value tests all follow the established patterns and verify expected output accurately.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant