-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use generated zipcode patterns #38
Conversation
Easier to maintain, more available.
* | ||
* @return bool | ||
* @deprecated use validate($zipcode, 'US') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify since version is deprecated (1.1 ? 1.2 ? See with @ronanguilloux) and use trigger_error
on the method to advice developers like this:
trigger_error('The '.__METHOD__.' method is deprecated since version 1.2 and will be removed in 2.0. You should use the validate($zipcode, $country) method instead.', E_USER_DEPRECATED);
See also with @ronanguilloux for which version we should remove deprecated method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement, thank you @barryvdh.
OK for @soullivaneuh proposal: could you please add this E_USER_DEPRECATED
error trigger to the @deprecated blocks (as in use in Symfony2 codebase by example)
As proposed, 1.2
starts the deprecation, and 2.0
will remove this.
trigger_error('The '.__METHOD__.' method is deprecated since version 1.2 and will be removed in 2.0. You should use the validate($zipcode, $country) method instead.', E_USER_DEPRECATED);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay but this will also trigger on validate($zipcode, 'Spain')
so I tweaked the messages to include the correct code. Also fixed the tests.
And some frameworks turn those errors into Exceptions, so not sure how cool that is for everyone, but I changed it.
Very good improvement, I like this! 👍 Is the database source up to date? |
Not sure, they reference it here: http://unicode.org/cldr/trac/browser/trunk/common/supplemental/postalCodeData.xml That was from data from Google from 2009, the appspot api data is also from Google I think, so probably newer or the same. All tests seem to pass except But if there is a newer/better source (I couldn't find any so quickly), we could use that. |
Should be at least a good start. We can indeed maintain it manually later. Code seems to be less covered according to coveralls, can you please take a look? |
Check Exception is thrown and that validateNetherlands() etc are still callable.
Yeah the |
I think it should be until this method could be used. Let @ronanguilloux decide about it. |
} | ||
|
||
/** | ||
* testUSZipCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sould be testZipCodeCountryMethod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I've also tested for the deprecated errors. Not sure if there is a prettier way.. |
Use generated zipcode patterns
Thanks |
StyleCI integration
Use auto-generated sources from http://i18napis.appspot.com with more countries available.
Deprecated the
validateNetherlands($zipcode)
calls in favor of thevalidate($zipcode, 'nl')
so they could be removed some time (Or you would need to add methods for each country?)This doesn't change the tests (and haven't run the tests yet).
Test could perhaps be modified to verify the examples from
zipex
in the data, but that wouldn't be needed if the source already tested those.