Skip to content

Keep surname particles together across nicknames - #18

Merged
iliaal merged 1 commit into
masterfrom
fix/bind-surname-particles-across-nicknames
Oct 12, 2026
Merged

iliaal merged 1 commit into
masterfrom
fix/bind-surname-particles-across-nicknames

Conversation

@iliaal

@iliaal iliaal commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix van (Bob) der Berg inventing first name Van and reducing the surname to der Berg. Surname particles now stay together across mapped nickname parts, matching the existing nickname-aware surname scan.
  • Keep nicknames intact, preserve the ambiguity of a single particle (Della (Bob) Smith), and propagate the complete surname to joint-name partners.
  • Add 16 regression cases and an Unreleased changelog entry.

Caller and scope audit

LastnameMapper::map() → mapParts() → mapAsPrefixIfPossible() → isApplicablePrefix() is the only path to the changed decision. Grepped all callers and constructors:

  • SegmentParserFactory::newDefaultPipeline() covers normal Western parsing and Parser::getFirstSegmentParser(), including empty comma tails, credential-only comma tails, and the unknown-credential-tail probe. All now use the corrected decision.
  • Parser::getSurnameSegmentParser() uses surname-only mapping for explicit comma names (also used by surname-first routing). Its already-correct behavior remains covered.
  • Parser::resyncConfigurableMappers() rebuilds promoted default mappers through newLastnameMapper(); covered with custom nickname delimiters.
  • Direct/custom LastnameMapper use shares the fix; a direct regression verifies nickname object identity. Independent review also checked mapper flags and sparse arrays. No failing caller of this decision remains excluded.

Removing the spurious given name also restores existing comma-tail rules: van (Bob) der Berg, XYZ keeps Xyz as a given name instead of guessing an unknown credential; van (Bob) der Berg, Jr follows the existing sole-generational-suffix promotion.

Existing out-of-scope limitation: setSurnameFirst(true)->parse('van (Bob) der Berg John') takes only the first token as surname (firstname Der, middlename Berg John, lastname Van). The nickname-free van der Berg John has the same pre-existing limitation in takeSurnameFirst(), before this mapper decision. Use the explicit comma form for a multi-token surname.

Verification

  • PHP 8.4.24 full PHPUnit suite: 1,236 tests / 3,241 assertions passed.
  • Focused regression file: 16 tests / 85 assertions passed; the initial 13-case version produced nine failures against unchanged source, including default, comma-tail, direct-mapper, and promoted-pipeline paths.
  • PHPStan level 9 and PHP 8.5 configuration passed with 512 MB memory limit.
  • PHP-CS-Fixer dry run, empty-baseline guard, PHP 8.5 deprecation guard, README check, and git diff --check passed.
  • Independent review found no blockers and repeated the full suite and static analysis.
  • Before opening this PR, fetched remote head 312f0f1d5b38a7dded52b65126390492c8fee594 and verified its complete tree, contents, and modes match the final tested local index: 27370ce8795ab5057c9411e43488b5a73b0a53d9.
  • No open PRs at inspection or immediately before publication, so no shared-file collision.

Local runtime is PHP 8.4 only; CI is responsible for PHP 8.3/8.5 and dependency audit. No dependency, workflow, or public API changes.

@iliaal
iliaal merged commit e93f6af into master Oct 12, 2026
5 checks passed
@iliaal
iliaal deleted the fix/bind-surname-particles-across-nicknames branch October 12, 2026 13:36
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.

1 participant