Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #50 +/- ##
=============================================
+ Coverage 78.03% 88.59% +10.55%
- Complexity 287 323 +36
=============================================
Files 3 5 +2
Lines 683 833 +150
=============================================
+ Hits 533 738 +205
+ Misses 150 95 -55
🚀 New features to boost your workflow:
|
fc99fb8 to
2d2ff7b
Compare
…on rules Completes the v3.1 roadmap. All additions are non-breaking for v3.0 callers; the one hard cutover is that the 15 ParseOptions rule properties are now readonly (direct assignment throws Error — use the new fluent withX() builders). Existing deprecated setters, factory presets, and the array-based parse() method continue to work unchanged. New public API: - ParseErrorCode backed enum (46 cases) — structured error codes covering every distinct failure mode the parser can emit. Backing string values are stable and part of the public API. - ParsedEmailAddress — immutable value object with readonly properties for every per-address output field. fromArray() factory for conversion from the legacy array shape. - ParseResult — immutable container for multi-address results (success, reason, emailAddresses). - Parse::parseSingle(string, string): ParsedEmailAddress — typed single- address entry point. Recommended over parse($x, false) for new code. - Parse::parseMultiple(string, string): ParseResult — typed multi-address entry point. - ParseOptions::withX() fluent builders — 19 methods (15 rules + 4 state fields) that return new immutable instances with a single field replaced. - invalid_reason_code: ?ParseErrorCode field on every parsed-address entry, populated at every existing invalid_reason emission site. Immutability: - The 15 boolean rule properties on ParseOptions are readonly via PHP 8.1 constructor promotion. Direct assignment (e.g. $opts->requireFqdn = false) now throws Error. Migration: use withRequireFqdn(false) which returns a new instance with the change applied. - The 4 state fields (bannedChars, separators, useWhitespaceAsSeparator, lengthLimits) remain mutable via deprecated setters for backward compatibility. They will become readonly in v4.0. New validation rules: - validateDisplayNamePhrase — enforce RFC 5322 §3.2.5 phrase syntax (atext + WSP only) on unquoted display names. Quoted-string names are always phrase-valid. New error code: InvalidDisplayNamePhrase. - strictIdna — apply full IDNA2008 conformance on U-label domains: IDNA_USE_STD3_RULES | IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII, plus inspection of idn_to_ascii()'s error bitmask (RFC 5891 §4.4, RFC 5892 Appendix A, RFC 5893). Enabled by default in ParseOptions::rfc6531(). Tests: - 14 tests / 265 assertions (up from 224 / 224 in v3.0). Covers every new typed object, fluent builder, error code assertion, display-name phrase validation, and IDNA strict-mode validation. - Test harness in tests/ParseTest.php now migrates all existing YAML test cases to use fluent builders (direct mutation no longer possible). - alignReasonCode() in ParseTest lets existing YAML entries omit invalid_reason_code (stripped from actual output for comparison) while new entries opt in by specifying a ParseErrorCode string value. Documentation: - CHANGELOG.md: v3.1.0 entry with Added / Changed / Deprecated sections. - UPGRADE.md: v3.0 → v3.1 section covering the readonly cutover and additive changes. - ROADMAP.md: v3.1 section marked [x] with exact counts (265 assertions exceeds the 250+ target). - README.md: typed output example in Basic Usage; withX() builders in the Customizing Rules section; new rule properties added to the reference table.
2d2ff7b to
9578072
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the v3.1 roadmap. All additions are non-breaking for v3.0 callers; the one hard cutover is that the 15
ParseOptionsrule properties are nowreadonly(direct assignment throwsError— use the new fluentwithX()builders). Existing deprecated setters, factory presets, and the array-basedparse()method continue to work unchanged.What's new
Structured error codes
ParseErrorCodebacked enum with 46 cases grouped by category (structural, character-class, dot placement, local-part content, quoted-string, domain, IP literal, length, display-name). Stable string backing values.invalid_reason_code: ?ParseErrorCodeon every parsed-address entry, populated alongside the existinginvalid_reasonstring.Typed output
ParsedEmailAddress— immutable value object with readonly properties for every per-address field.ParseResult— immutable container for multi-address results.Parse::parseSingle(string, string): ParsedEmailAddress— typed single-address entry point.Parse::parseMultiple(string, string): ParseResult— typed multi-address entry point.Immutable config
ParseOptionsarereadonlyvia PHP 8.1 constructor promotion.withX()fluent builders (15 rules + 4 state fields) that return new immutable instances with a single field replaced.bannedChars,separators,useWhitespaceAsSeparator,lengthLimits) remain mutable via@deprecatedsetters; they will become readonly in v4.0.New validation rules
validateDisplayNamePhrase— enforce RFC 5322 §3.2.5 phrase syntax (atext + WSP only) on unquoted display names. New error code:InvalidDisplayNamePhrase.strictIdna— apply full IDNA2008 conformance on U-label domains (IDNA_USE_STD3_RULES | IDNA_CHECK_BIDI | IDNA_CHECK_CONTEXTJ | IDNA_NONTRANSITIONAL_TO_ASCII) per RFC 5891/5892/5893. Enabled by default inParseOptions::rfc6531().Migration for v3.0 users
Only one thing can break existing code: direct assignment to rule properties.
Factory presets, the deprecated setters (
setBannedCharsetc.), andparse()are all unchanged. See UPGRADE.md for full migration notes.Test plan
composer cipasses (cs:check, PHPStan level 6, 14 tests / 265 assertions)alignReasonCode()reconciliation in the test harnessDocs updated
CHANGELOG.md— v3.1.0 entry with Added / Changed / Deprecated sectionsUPGRADE.md— v3.0 → v3.1 section covering the readonly cutover and additive changesROADMAP.md— v3.1 items marked[x]with exact countsREADME.md— typed output example in Basic Usage;withX()builders in Customizing Rules; new rule properties in the reference table