Skip to content

feat(attribute): Add HasNonce trait and nonce() method to manage nonce attribute for HTML elements.#35

Merged
terabytesoftw merged 1 commit into
mainfrom
feature_13
Jan 29, 2026
Merged

feat(attribute): Add HasNonce trait and nonce() method to manage nonce attribute for HTML elements.#35
terabytesoftw merged 1 commit into
mainfrom
feature_13

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

@terabytesoftw terabytesoftw commented Jan 29, 2026

Pull Request

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for managing nonce attributes on HTML elements through a new immutable trait with chainable methods. Supports string, Stringable, UnitEnum values, and null for unsetting.
  • Tests

    • Comprehensive test suite added covering immutability, empty states, attribute storage, rendering output, and various input types.

✏️ Tip: You can customize this high-level summary in your review settings.

@terabytesoftw terabytesoftw added the enhancement New feature or request label Jan 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

The pull request introduces a new HasNonce trait for managing the global HTML nonce attribute with an immutable API. It includes the trait implementation, comprehensive test coverage via a PHPUnit test suite, a test data provider with multiple test cases, and updates to the changelog.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Adds entry for Enh #35 documenting the introduction of HasNonce trait and nonce() method.
Implementation
src/Global/HasNonce.php
Introduces HasNonce trait with immutable nonce() method that delegates to addAttribute for setting GlobalAttribute::NONCE. Accepts string, Stringable, UnitEnum, or null values.
Tests
tests/Global/HasNonceTest.php, tests/Support/Provider/Global/NonceProvider.php
Adds comprehensive test suite using anonymous classes and data provider to verify immutability, attribute setting, rendering, and edge cases including empty state, enum values, and null unsetting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 With whiskers twitching and paws all aglow,

We've added HasNonce to HTML's flow,

Immutable, tested, secure and quite neat,

Guarding nonce attributes, our gift now complete! 🛡️

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 title clearly and specifically describes the main change: adding a HasNonce trait and nonce() method for HTML element nonce attribute management.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 9b8da41 into main Jan 29, 2026
46 checks passed
@terabytesoftw terabytesoftw deleted the feature_13 branch January 29, 2026 21:59
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