Skip to content

Fix #221: Throw LogicException in Tag::id() when id is empty string#265

Merged
samdark merged 2 commits intoyiisoft:masterfrom
razvbir:master
Mar 13, 2026
Merged

Fix #221: Throw LogicException in Tag::id() when id is empty string#265
samdark merged 2 commits intoyiisoft:masterfrom
razvbir:master

Conversation

@razvbir
Copy link
Contributor

@razvbir razvbir commented Mar 11, 2026

Q A
Is bugfix?
New feature?
Breaks BC? ✔️
Fixed issues #221

The issue is a bit old, but I hope it's still relevant.

Remove meaningless @psalm-param tag from Tag::id docblock

Add CHANGELOG message
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3806168) to head (fe202b3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##              master      #265   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       829       830    +1     
===========================================
  Files             89        89           
  Lines           2229      2231    +2     
===========================================
+ Hits            2229      2231    +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a backward-incompatible validation to disallow empty-string IDs on tags, aligning Tag::id() with the expectation that HTML id values should be non-empty, and documents the change in the changelog.

Changes:

  • Throw a LogicException from Tag::id() when $id === ''.
  • Add a unit test asserting id('') triggers an exception.
  • Add a changelog entry documenting the BC break.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Tag/Base/Tag.php Adds runtime validation and throws LogicException for empty-string IDs.
tests/Tag/Base/TagTest.php Adds a regression test for the new empty-string ID behavior.
CHANGELOG.md Documents the BC change for issue #221.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add @throws LogicException to Tag::id docblock.
Update TagTest to expect an empty-string id to throw
LogicException with message: The tag id cannot be
an empty string.
@samdark samdark changed the title Add exception on pass empty string to Tag::id() (#221) Fix #221: Throw LogicException in Tag::id() when id is empty string Mar 13, 2026
@samdark samdark merged commit e34f2d1 into yiisoft:master Mar 13, 2026
24 checks passed
@samdark
Copy link
Member

samdark commented Mar 13, 2026

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants