Skip to content

feat(attribute): Add HasRequired trait and required() method to manage required attribute for HTML elements.#65

Merged
terabytesoftw merged 1 commit into
mainfrom
feature_37
Feb 3, 2026
Merged

feat(attribute): Add HasRequired trait and required() method to manage required attribute for HTML elements.#65
terabytesoftw merged 1 commit into
mainfrom
feature_37

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

    • Added support for managing the HTML required attribute on form elements. Developers can now easily set, update, or remove the required attribute from input fields and form components.
  • Tests

    • Comprehensive unit tests added to validate required attribute handling across various scenarios.

…anage `required` attribute for HTML elements.
@terabytesoftw terabytesoftw added the enhancement New feature or request label Feb 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new HasRequired trait that provides an immutable API for managing the HTML required attribute on elements. The implementation includes comprehensive unit tests and a data provider for various test scenarios covering boolean values, null, and attribute replacement.

Changes

Cohort / File(s) Summary
Implementation
src/HasRequired.php
New trait defining required(bool|null $value): static method that delegates to addAttribute() to manage the HTML required attribute with immutability support.
Testing
tests/HasRequiredTest.php, tests/Support/Provider/RequiredProvider.php
Comprehensive unit tests validating immutability, empty attribute handling, and attribute rendering across multiple scenarios; data provider supplies test cases for true/false/null values and attribute replacement.
Documentation
CHANGELOG.md
Changelog entry documenting the new HasRequired trait and required() method addition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A trait hops forth, so neat and light,
With required() shining bright,
Immutable and true, it bounds with grace,
Managing attributes in their place,
HTML elements now stand required and right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% 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 PR title accurately describes the main change: introducing a HasRequired trait and required() method for managing the required HTML attribute.

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

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.

@terabytesoftw terabytesoftw merged commit 6e59a2b into main Feb 3, 2026
31 checks passed
@terabytesoftw terabytesoftw deleted the feature_37 branch February 3, 2026 15:41
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