Repository navigation
Treat an unset extension as empty in containsOnlyValidXChars - #774
Merged
Merged
Conversation
Java compares the digits after an x with number.getExtension(), which is an empty string when the number has no extension. PhoneNumber::getExtension() returns null instead, so an x followed by no digits made the check fail and findNumbers dropped candidates that Java keeps.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #774 +/- ##
=========================================
Coverage 86.12% 86.12%
Complexity 1320 1320
=========================================
Files 31 31
Lines 3444 3444
=========================================
Hits 2966 2966
Misses 478 478 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thank you for these 3 PRs! |
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.
PhoneNumberMatcher::containsOnlyValidXChars()ports this check fromPhoneNumberMatcher.java:In Java,
getExtension()of a number without an extension is the empty string, the protobuf default. In PHP,PhoneNumber::getExtension()returnsnull, so the port's strict!==comparison fails whenever anxin the candidate is followed by no digits. That covers anxthat starts the lettersext. Such candidates are rejected withVALIDand stricter leniencies, where Java accepts them:The comparison now treats a
nullextension as'', as Java does. Anxthat is followed by digits still has to be followed by the extension.The new
testContainsOnlyValidXCharsWithoutExtensionchecks both cases for a number without an extension. Thex.case fails without the change.I compared
findNumbers()with Java libphonenumber 9.0.41 on 20,000 generated texts. This change fixes 10 of the mismatches that remain with #772 and #773 applied, and adds none. Fullvendor/bin/phpunitpasses (6178 tests) exceptLocaleTestdata set #174 (SH, 'St. Helena'), which fails on master too with the current giggsey/locale.php-cs-fixer fix --dry-runreports 0 files andphpstanreports no errors.