Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[WIP] New I18n Validator: CountryCode with companion CountryDb #4142

Closed
wants to merge 301 commits into from
@mwillbanks
Collaborator

This PR is based off of PR #3884 with the feedback taken into account. I've separated each component off individually to make it easier to review and make feedback.

@marc-mabe and @weierophinney please review to see if all feedback was incorporated to your expectations.

Overview

CountryDb

This is a static class for the most part in that it only contains static variables and methods. There are two methods:
1. getTypes that gives you an array of the ISO3611-1 Alpha 2 types
2. getCountries which accepts a type to retrieve a list of countries (key = 2 letter alpha code, value is the name).

CountryCode

The Country validator is based on ISO-3611 country codes. I needed this for actually integration into other systems that require an ISO-3611 country code. The key is the country code where as the value is the country name.
Basic Usage:

$validator = new \Zend\I18n\Validator\CountryCode();
$validator->isValid('US'); 

// input filter with context
$filter = new InputFilter();
$factory = new InputFactory();
$filter->add($factory->createInput(array(
    'name' => 'country',
    'required' => true,
    'validators' => array(
        'name' => 'Zend\I18n\Validator\Country',
    ),
)));

Advanced Usage

$validator = new \Zend\I18n\Validator\CountryCode();

// Specify ISO3611-1 Alpha 2 types to load - default is official
$validator->loadCountryTypes(array('official', 'transition', 'userAssigned'));

// Load your own countries
$validator->setCountries(array('CA', 'TX')); // states most likely their own country in the US
@mwillbanks
Collaborator

Was wondering if anyone had feedback as to if I should separate out the country lists much like PR #4127 is for the country patterns.

@marc-mabe

@mwillbanks Only an idea:

Would it be make more sense to define datasets as resources and write a simple loader like the following:

class Data\Country
{
    public $code;
    public $name;
    public $phoneCode;
    public $phonePatterns;
}

class Data\Countries
{
    public function __construct($glob); // resources/countries/*.php
    public function getCountryCodes();
    public function getCountry($countryCode);
}

An instance of Data\Countries must be cachable to not run glob every time.
The resources could be updated by the consumers.
The validator only requires a list of country codes fetchable Zend\I18n\Data\getCountryCodes()
The phone number validator only requires one pattern on one country code fetchable by Zend\I18n\Data\getCountry()->phonePatterns

@mwillbanks
Collaborator

That's not a bad idea at all; it's a hell of a lot of work although. But it would work for region data also... meaning you could fetch regions by countries. The hard part of it all it is will eventually end up with a ton of data. Think FIPS data and the like.

@marc-mabe

We could also ship CLDR data and create a parser ;) nearly like ZF1

@iquabius iquabius commented on the diff
library/Zend/I18n/Validator/CountryCode.php
((9 lines not shown))
+
+namespace Zend\I18n\Validator;
+
+use Traversable;
+use Zend\I18n\CountryDb;
+use Zend\Stdlib\ArrayUtils;
+use Zend\Validator\AbstractValidator;
+
+class CountryCode extends AbstractValidator
+{
+
+ const INVALID = 'countryInvalid';
+ const NO_MATCH = 'countryNoMatch';
+
+ /**
+ * @var array[string]

Shoudn't this be string[]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samsonasik samsonasik commented on the diff
library/Zend/I18n/Validator/CountryCode.php
((12 lines not shown))
+use Traversable;
+use Zend\I18n\CountryDb;
+use Zend\Stdlib\ArrayUtils;
+use Zend\Validator\AbstractValidator;
+
+class CountryCode extends AbstractValidator
+{
+
+ const INVALID = 'countryInvalid';
+ const NO_MATCH = 'countryNoMatch';
+
+ /**
+ * @var array[string]
+ */
+ protected $messageTemplates = array(
+ self::INVALID => 'Invalid type given. Scalar expected',

double space should be one space :D before 'Scalar'

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

@marc-mabe @weierophinney could use some thoughts here for moving this forward... do we feel that we must put this together in where we have resource data listed as above? meaning already refactoring the PhoneNumber validator? I have no issue with moving forward on that but I do not think I would be able to do it in time for 2.2.

Otherwise; do we go with more of the format that I have completed this in? Then having the region validator use files much like the phone number?

Obviously @marc-mabe mentioned the most flexible and extensible way of doing this; but is it going too far? I think that is basically what I need (besides finding the additional time).

@DASPRiD
Collaborator
@weierophinney

@mwillbanks - The approach you used for PhoneNumber seemed quite reasonable. However, I also really like the suggestion from @DASPRiD, as it would solve the lazy-loading and have a C-based implementation backing it; I'm unsure how it would work with regards to caching however -- or if caching would be necessary.

@DASPRiD - how hard would it be to translate the PhoneNumber resource arrays to something ResourceBundle can use? My thought is that if it's not hard, it likely wouldn't take long to do this for the other validators Mike is working on, and doing so would allow for a consistent approach across all of them (which may actually simplify much of the work).

@marc-mabe

Please correct me if I'm wrong ... The ICU Resource Bundle is similar to a key-value storage but grouped by a locale. This validator and the phone number validator are based on country codes only. How can this be used if the data have to be grouped together with a language without language information?

@mwillbanks
Collaborator

So where does this lead us folks :)
@marc-mabe @DASPRiD @weierophinney

I would like to plow through the rest of this during the weekend.

@weierophinney

@mwillbanks Did you get any consensus from @marc-mabe or @DASPRiD on approach? Would be great to get this ready for 2.3. :)

@mwillbanks
Collaborator

I have an approach for it; just need to grab some time to transform everything over. :)

@EvanDotPro
Collaborator

@mwillbanks Let's make this happen. ;)

@glen-84

@mwillbanks @weierophinney

  1. Isn't it ISO 3166? I see ISO 3611 written everywhere.
  2. What about just storing the codes (US, GB, etc.) and using Locale::getDisplayRegion() for the names? Something like \Locale::getDisplayRegion('-US', 'fr') (I don't know if this is appropriate usage of the method, but it seems to work). If not, how else could you get translated country names?
  3. When will this be released? (yesterday would be good =))
@glen-84

The country lists should be ordered by country name and not code IMHO.

@samsonasik samsonasik commented on the diff
library/Zend/I18n/CountryDb.php
@@ -0,0 +1,777 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)

now already 2014 :D

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

@mwillbanks Any updates? If you don't think you can get to it, we should either close, or hand it to another interested party.

@moderndeveloperllc

@weierophinney I would be willing to take this on if @mwillbanks is too busy to approach it. From what I can see of the discussion, the idea would be to remove the static arrays into files that could be used by ResourceBundle for C-backed lazy loading of the data. I have a few questions though:

  • Any particular reason we have actual country and, in the regions code, region names? I was under the impression that this was solely a validator - does AF exist as a country. Removing names allows for simple arrays.

  • Are we really wanting to distribute binary files that are very difficult for the user to update? The ResourceBundle .res format is not trivial to work with. Removing country/region names would make for much smaller arrays and might alleviate the desire to break the data out separately.

  • Are you still looking for this to be in 2.3.0, or can this slip later? It looks like 2.3.0 is pretty much wrapped up, so I'm not sure I can get something acceptable into the repo fast enough. My unit testing skills are sorely lacking. :-\

  • If we go with .res files, should I follow the PhoneNumber directory structure to create the data directories, or would you prefer something different?

@weierophinney

@mwillbanks Can you point @moderndeveloperllc to what needs to be done, and whether or not his assumptions are correct?

@moderndeveloperllc 2.3.0 is not yet wrapped up - release is most likely next week, so if the two of you can get things worked out this week, it may make it in still.

@weierophinney weierophinney modified the milestone: 2.4.0, 2.3.0
@weierophinney

Changing milestone to 2.4.0, based on discussion with @mwillbanks

@samsonasik samsonasik commented on the diff
tests/ZendTest/I18n/CountryDbTest.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)

2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samsonasik samsonasik commented on the diff
tests/ZendTest/I18n/Validator/CountryCodeTest.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)

2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samsonasik samsonasik commented on the diff
library/Zend/I18n/Validator/CountryCode.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)

2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samsonasik samsonasik commented on the diff
library/Zend/I18n/CountryDb.php
((745 lines not shown))
+ 'ZS' => 'un-assigned',
+ 'ZT' => 'un-assigned',
+ 'ZU' => 'un-assigned',
+ 'ZV' => 'un-assigned',
+ 'ZX' => 'un-assigned',
+ 'ZY' => 'un-assigned',
+ );
+
+ /**
+ * Get Country Types
+ *
+ * @return array[string]
+ */
+ public static function getTypes()
+ {
+ return self::$types;

static::

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Martin-P and others added some commits
@Martin-P Martin-P Add autoEscape option to FlashMessenger c538241
@Martin-P Martin-P Added tests for autoEscape via render() 33538d8
@Martin-P Martin-P Fixed error in test ac960b3
@Martin-P Martin-P Added third parameter to render() whether to use autoEscape 126a41e
@Martin-P Martin-P Updated render() docblock with the third parameter 4ad2368
@Martin-P Martin-P Fixed rebase conflicts, added same functionality to renderCurrent and…
… added tests
56bb2fa
@Maks3w Maks3w Merge pull request #6080 from youngguns-nl/useAuthenticationServiceIn…
…terface

Use AuthenticationServiceInterface as type
7912cdf
@fedys fedys Zend\Loader\ClassMapAutoloader - Performance improvement #5716 2d295d9
@Ocramius Ocramius Merge branch 'hotfix/#6083-hydrator-number-of-parameters-filter-honor…
…ed' into develop

Close #6083
Forward Port #6083
98cc1da
@Ocramius Ocramius Merge branch 'performance/#6084-classmap-autoloader-merging-performan…
…ce' into develop

Close #6084
6e404cd
@pszczekutowicz pszczekutowicz Added map naming strategy for hydrator 37aa52e
@pszczekutowicz pszczekutowicz Removed setters from MapNamingStrategy 9127822
Paweł Szczekutowicz Make one map required in constructor
As there is no setter for maps at least one map should be required
to instantiate MapNamingStrategy
4611dfb
@pszczekutowicz pszczekutowicz Strict map keys and values checker 814438e
@pszczekutowicz pszczekutowicz Typo 0fa556c
@Ocramius Ocramius Merge branch 'hotfix/#6096-prevent-php-5.6-arrayobject-infinite-recur…
…sion' into develop

Close #6096
Forward Port #6096
e74061d
@vincentvandijk vincentvandijk Fixed return value for method. #6095 f6fc213
@Maks3w Maks3w Merge pull request #6097 3123c75
@Ocramius Ocramius Merge branch 'hotfix/#6093-dead-code-cleanups' into develop
Close #6093
Forward Port #6093
77e8e57
@denis-sokolov denis-sokolov Mail TransferEncoding test refactor e5675e8
@denis-sokolov denis-sokolov Mail TransferEncoding allow binary 0b6e38c
@denis-sokolov denis-sokolov Mail ContentType handles trailing semicolon properly 51a4095
@Ocramius Ocramius Merge branch 'hotfix/#6116-typo-fixes' into develop
Close #6116
Forward Port #6116
5698d81
@Ocramius Ocramius Merge branch 'hotfix/#6103-#6102-tar-compress-filter-mode-case-insens…
…itive' into develop

Close #6103 #6102
b0503b8
@pszczekutowicz pszczekutowicz MapNamingStrategy simplified and refactored 497f0d9
@pszczekutowicz pszczekutowicz Fixed CS 828f790
@weierophinney weierophinney Merge pull request #5743 from Martin-P/issue-5600
Add auto escape method to Zend\View\Helper\FlashMessenger
c2b0c6c
@weierophinney weierophinney [#5743] CS fix
- use `null ===` instead of `is_null` (consistency)
ff81ed2
@weierophinney weierophinney [#5743] object calisthenics
- Return from conditional, to remove an else clause
97141fe
@weierophinney weierophinney Merge branch 'feature/5743' into develop
Close #5743
c9144e6
@weierophinney weierophinney Merge branch 'hotfix/5392' into develop
Forward port #5392
3af71d3
@Maks3w Maks3w Merge pull request #6126 in develop 99bf98c
@Ocramius Ocramius Merge branch 'hotfix/#6125-enforcing-braces-in-if-construct-usage' in…
…to develop

Close #6125
Forward Port #6125
4840a11
@Ocramius Ocramius Merge branch 'hotfix/#6128-isimage-file-validator-description' into d…
…evelop

Close #6128
Forward Port #6128
447d7e1
@Ocramius Ocramius Merge branch 'cs/#6129-is_null-removal' into develop
Close #6129
Forward Port #6129
074096c
@Ocramius Ocramius Merge branch 'cs/#6130-Zend_-classnames-replacement' into develop
Close #6130
Forward Port #6130
0273d9d
@Ocramius Ocramius Merge branch 'hotfix/#6094-undefined-symbols-fixes' into develop
Close #6094
Forward Port #6094
d40f796
@weierophinney weierophinney Merge branch 'hotfix/5857' into develop
Forward port #5857
672b84f
@weierophinney weierophinney Merge branch 'hotfix/5970' into develop
Forward port #5970
477755e
@weierophinney weierophinney Merge branch 'hotfix/5997' into develop
Forward port #5997
acd1825
@weierophinney weierophinney Merge branch 'hotfix/6009' into develop
Forward port #6009
eb5e006
@weierophinney weierophinney Merge branch 'hotfix/6024' into develop
Forward port #6024
b759850
@weierophinney weierophinney Merge branch 'hotfix/6049' into develop
Forward port #6049
ce50ec6
@weierophinney weierophinney Merge branch 'hotfix/6077' into develop
Forward port #6077
fe5a9e7
@weierophinney weierophinney Merge branch 'hotfix/6085' into develop
Forward port #6085
e4de527
@weierophinney weierophinney Merge pull request #6091 from pszczekutowicz/map-naming-strategy
Added map naming strategy for hydrator
8f1d690
@weierophinney weierophinney [#6091] Updated docblock parameter names
- Updated docblock parameter names to match signature; added descriptions
5b0c9ca
@weierophinney weierophinney Merge branch 'feature/6091' into develop
Close #6091
1a35602
@weierophinney weierophinney Merge branch 'hotfix/6092' into develop
Forward port #6092
2e69c0b
@weierophinney weierophinney Merge branch 'hotfix/6100' into develop
Forward port #6100
5f63c10
@weierophinney weierophinney Merge branch 'hotfix/6104' into develop
Forward port #6104
1f5b1c9
@weierophinney weierophinney Merge branch 'hotfix/6105' into develop
Forward port #6105
5cd5faf
@weierophinney weierophinney Merge branch 'hotfix/6106' into develop
Forward port #6106
73f65ce
@weierophinney weierophinney Merge branch 'hotfix/6110' into develop
Forward port #6110
bfcee97
@weierophinney weierophinney Merge pull request #6112 from SlikNL/mail-transfer-encoding-binary
Mail transfer encoding binary
b5e2b8c
@weierophinney weierophinney Merge branch 'feature/6112' into develop
Close #6112
cd053dc
@weierophinney weierophinney Merge pull request #6113 from SlikNL/mail-content-type-semicolons
Mail ContentType handles trailing semicolon properly
260bce0
@weierophinney weierophinney Merge branch 'feature/6113' into develop
Close #6113
6266a51
@weierophinney weierophinney Merge branch 'hotfix/6118' into develop
Forward port #6118
46b5499
@weierophinney weierophinney Merge branch 'hotfix/6123' into develop
Forward port #6123
672f17d
@weierophinney weierophinney Merge branch 'hotfix/5986' into develop
Forward port #5986
2313132
@weierophinney weierophinney Merge branch 'hotfix/5968' into develop
Forward port #5968
b6a7d4e
@Ocramius Ocramius Merge branch 'hotfix/#5957-php-5.6-compatibility' into develop
Close #5957
Forward Port #5957
021e4b1
@Martin-P Martin-P Added test for setting label position via second parameter of render() d894393
@Martin-P Martin-P Added second parameter to render() for setting label position bdfa490
@Martin-P Martin-P Updated test for setting label position via render() 4e85f1e
@Martin-P Martin-P Added test setting label position via render() is not cached b058622
@Martin-P Martin-P Added test for setting label position via __invoke() 511496c
@Martin-P Martin-P Fixed typo in test cc4126f
@Martin-P Martin-P Updated __invoke() to not cache label position parameter 8ffc1e6
@Martin-P Martin-P Removed test for setting permanent label position via __invoke() 34a4a43
@Martin-P Martin-P Fixed rebase conflicts 9c4b8a8
@Martin-P Martin-P Fixed typo a9e6c76
@Martin-P Martin-P Accidently removed line while fixing conflicts 2bd4afe
@Martin-P Martin-P Removed a newline at end of file 391b1ef
@Ocramius Ocramius Merge branch 'feature/#5742-#5699-disable-label-position-caching' int…
…o develop

Close #5742 #5699
72bd9a2
@Ocramius Ocramius Merge branch 'hotfix/#6132-form-element-manager-only-initialize-share…
…d-elements-once' into develop

Close #6132
Forward Port #6132
e076bd5
@ralphschindler ralphschindler Forward port #6086
Merge branch 'hotfix/6086' into develop

* hotfix/6086:
  move individual function into data provider instead
  Fixes #6082
0fffc2c
@Ocramius Ocramius Merge branch 'cs/#5029-imports-fqcn-not-prefixed-with-global-ns' into…
… develop

Close #5029
Forward Port #5029
52f5439
@weierophinney weierophinney Merge branch 'hotfix/6139' into develop
Forward port #6139
0551173
@weierophinney weierophinney Merge branch 'hotfix/6140' into develop
Forward port #6140
c837d6e
@weierophinney weierophinney Merge branch 'security/zf2014-03' into develop
ZF2014-03 fixes
64e99c0
@weierophinney weierophinney Merge branch 'releases/2.3.1' into develop
2.3.1 release readiness

Conflicts:
	README.md
	library/Zend/Version/Version.php
cb75ac6
@weierophinney weierophinney Merge branch 'release/bump' into develop
Conflicts:
	README.md
	library/Zend/Version/Version.php
7b0e984
@moderndeveloperllc moderndeveloperllc Add hydratedMethodName private member to optimize the hydrate() metho…
…d for loops.
de53b9a
@moderndeveloperllc moderndeveloperllc Remove unused variable. 6b25870
Mike Willbanks Merge branch 'Ocramius-hotfix/session-validation-listeners-null-retur…
…n-values' into develop

Forward port #6147
3547392
@ezimuel ezimuel Merge branch 'ralphschindler-hotfix/5794' into develop fb5e8e8
@weierophinney weierophinney Merge branch 'hotfix/6141' into develop
Forward port #6141
53f16f2
@weierophinney weierophinney Merge branch 'hotfix/6146' into develop
Forward port #6146
9efe720
@weierophinney weierophinney Merge branch 'hotfix/6144' into develop
Forward port #6144
ae253be
@bakura10 bakura10 Properly pass context to input filter 6ecf218
@weierophinney weierophinney Merge pull request #6154 from bakura10/use-input-filter-context
Properly pass context to input filter
78bb5e3
@weierophinney weierophinney [#6154] Added note to README
(detailing BC break)
9459b77
@weierophinney weierophinney Merge branch 'feature/6154' into develop
Close #6154
bb30e51
@moderndeveloperllc moderndeveloperllc Fix for 6151 - Match patterns now look for any non-whitespace charact…
…er after the separator.
58c1b3f
@Ocramius Ocramius Merge branch 'hotfix/#6158-typo-fix' into develop
Close #6158
Forward Port #6158
27d0ff1
@Maks3w Maks3w Merge pull request #6163 in develop f31d81c
@Maks3w Maks3w Merge pull request #6159 in develop 1edb6c2
@Maks3w Maks3w Merge pull request #6149 in develop 149ec69
@Maks3w Maks3w Merge pull request #6180 in develop c579300
@Maks3w Maks3w Merge pull request #6164 in develop b37355e
@Nainterceptor Nainterceptor Fix E_DEPRECATED message 9d16c4d
@Nainterceptor Nainterceptor Edit test suit about deprecated using of safe option 997791d
@Maks3w Maks3w Merge pull request #6186 in develop 76ef0c0
@ezimuel ezimuel Merge branch 'tommyseus-randgetinteger' into develop 535940f
@Maks3w Maks3w Merge pull request #6191 in develop ef1c68d
@vnagara vnagara Added posibility to render view with short reference.
It makes add rendering view the same as php include file which contains
in the same folder.
c98907d
@vnagara vnagara Add docblock. Made access to protected. 8e87137
Thomas Johnell Clean up repeat code by using already implemented AbstractListenerAgg…
…regate
4e10322
@Ocramius Ocramius Merge branch 'cleanup/#6203-abstract-aggregate-listener-reuse' into d…
…evelop

Close #6203
4454876
@Ocramius Ocramius Merge branch 'hotfix/#6151-separator-to-camel-case-filter-on-any-non-…
…whitespace-after-separator' into develop

Close #6151
Close #6156
3018a30
@Ocramius Ocramius Merge branch 'cs/#6177-log-processor-tests-indentation-cs' into develop
Close #6177
Forward Port #6177
08bbf62
@Ocramius Ocramius Merge branch 'typo/#6178-c-p-mistake-in-processorpluginmanager' into …
…develop

Close #6178
Forward Port #6178
778d429
@Ocramius Ocramius Merge branch 'cs/#6179-logger-indentation-and-trailing-commas' into d…
…evelop

Close #6179
Forward Port #6179
28bb9b6
@Ocramius Ocramius Merge branch 'feature/#6187-homepage-link-for-component-composer-json…
…' into develop

Close #6187
Close #6192
Forward Port #6187
Forward Port #6192
1dbdacb
@Ocramius Ocramius Merge branch 'hotfix/#6200-restore-libxml-entity-loader-in-soap-serve…
…r' into develop

Close #6200
Forward Pory #6200
8e88356
@pszczekutowicz pszczekutowicz Reduced code duplication
- Zend/Mvc/Controller/Plugin/FlashMessenger.php
4ffd482
@pszczekutowicz pszczekutowicz Tests for methods with new $namespace parameter 8e5d052
@Ocramius Ocramius Merge branch 'feature/#6073-explicit-namespacing-in-flashmessenger' i…
…nto develop

Close #6073
2e31a40
@vnagara vnagara Added tests 0dd1a89
@Ocramius Ocramius Merge branch 'hotfix/#5962-mime-empty-string-on-no-part' into develop
Close #5962
Close #6157
Forward Port #5962
Forward Port #6157
820cfcd
@Ocramius Ocramius Merge branch 'hotfix/#6207-underscore-naming-strategy-not-studlycase'…
… into develop

Close #6207
Forward Port #6207
8a52e80
@Ocramius Ocramius Merge branch 'typo/#6213-typo-fix' into develop
Close #6213
Forward Port #6213
be64022
@demichl68 demichl68 * added MutableCreationOptionsAwareTrait ade0734
@demichl68 demichl68 Update MutableCreationOptionsAwareTrait.php 02c4a85
@demichl68 demichl68 Create MutableCreationOptionsAwareTraitTest.php
* added unit test for MutableCreationOptionsAwareTrait
fef8e73
@demichl68 demichl68 Update MutableCreationOptionsAwareTraitTest.php
added requires annotation
63abdd8
@demichl68 demichl68 Update MutableCreationOptionsAwareTraitTest.php
removed trailing space in docblock
2e88f3e
@demichl68 demichl68 Update MutableCreationOptionsAwareTrait.php
changed copyright information to 2014
9ba40d5
@demichl68 demichl68 * fixed array notation 733bf7a
@demichl68 demichl68 * improved options array readability a8e8973
@demichl68 demichl68 * fixed @requires annotation a1e3d99
@demichl68 demichl68 * explicitly skipping unit tests on PHP Version < 5.4 as "@require" w…
…ouldn't suffice
fe56890
@demichl68 demichl68 * removed "Aware" from Classname
* Removed leading \  from Zend namespace in unit test
* Removed @group annotation from unit test
79e43b2
@Ocramius Ocramius Merge branch 'feature/mutable-creation-options-traits' into develop
Close #6175
50ccaf2
@Ocramius Ocramius Merge branch 'typo/#6215-console-adapter-typo' into develop
Close #6215
Forward Port #6215
27b5d35
@nikolaposa nikolaposa Created log filter for filtering log events based on the time when th…
…ey were triggered.
b90e5a8
@nikolaposa nikolaposa Fixing trailing spaces in Timestamp log filter. a98b1ae
@nikolaposa nikolaposa Fixing EOF line in Timestamp log filter. a3cbe41
@nikolaposa nikolaposa Added missing license headers. Removing redundant else statement. bdab4f2
@nikolaposa nikolaposa Fixing trailing spaces in Timestamp log filter. 14e4544
@nikolaposa nikolaposa Added validation for the Timestamp log filter comparion operator. 448ec84
@nikolaposa nikolaposa Fixed initialization of the Timestamp log filter operator parameter. …
…Testing string versions of comparison operators.
fbfc94f
@Ocramius Ocramius #6058 - Correct namespacing of `@expectedException` symbols dfe05b0
@Ocramius Ocramius #6058 - Verifying that a timestamp filter can be built from a travers…
…able
504de00
@Ocramius Ocramius #6058 - importing undefined symbol `Traversable` c803f8b
@Ocramius Ocramius #6058 - Preferring `ArrayUtils::iteratorToArray()` over `iterator_to_…
…array`
67500b6
@Ocramius Ocramius #6058 - Removing unused casting and variable initialization f042772
@Ocramius Ocramius #6058 - Adding tests to verify that messages without a datetime are d…
…iscarded
bebd945
@Ocramius Ocramius #6058 - Timestamp filter is now skipping events without a timestamp 0428621
@Ocramius Ocramius #6058 - Moving ignored messages to a data provider d4f323f
@Ocramius Ocramius #6058 - Adding tests to verify support for integer and string timestamps d781786
@Ocramius Ocramius #6058 - Moving data provider to the bottom of the test 00f4982
@Ocramius Ocramius #6058 - Timestamp tests should not use hardcoded (hard to read) times…
…tamps
cf4d725
@Ocramius Ocramius #6058 - Removing value from ignored timestamps (strings) should be ch…
…ecked too
1257983
@Ocramius Ocramius #6058 - Timestamp filter now also checks integers and strings 3043452
@Ocramius Ocramius #6058 - Adding coverage annotation, removing \`@group\` annotation b3e0c40
@Ocramius Ocramius Merge branch 'feature/#6058-timestamp-log-filter' into develop
Close #6058
c343f08
@Ocramius Ocramius Merge branch 'typo/#6217-callback-paginator-test-typos' into develop
Close #6217
Forward Port #6217
20bf722
@Maks3w Maks3w [travis] Adds hhvm-nightly dec0394
@Ocramius Ocramius Merge branch 'feature/#6216-travis-build-hhvm-nightly' into develop
Close #6216
4cf9a06
@l-x l-x Fix double registration of a complex type
Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType::addComplexType()
stores already added classes under the methods argument `$type`.

Therefore a class with preceding backslash is treated like another complextype
than the same class without given backslash. As a result the xsd:ComplexType
definition is found twice (with exactly the same name) in the generated wsdl.
a29f905
@vnagara vnagara Move logic to new RelativeFallbackResolver 2b9642c
@vnagara vnagara Fix misspelling 2f8287c
@vnagara vnagara Add docblock param to constructor c14f53f
Thomas Johnell Fix return type a31bec5
@Maks3w Maks3w Merge pull request #6232 deff9a2
@weierophinney weierophinney Merge branch 'hotfix/6219' into develop
Forward port #6219
f7ecca8
@vnagara vnagara Remade resolver to clear fallback and using it coupling with Aggragat…
…eResolver
c21facf
@Maks3w Maks3w Merge pull request #6237 in develop 556df54
@vnagara vnagara Refactor by removing 1 check. 0e4c955
@Ocramius Ocramius #6142 - using `string[]` instead of `array` for the hydrated method n…
…ames
d58c01b
@Ocramius Ocramius #6142 - better description of what the hydration method names cache does 95d7048
@Ocramius Ocramius #6142 - better hydration cache property name 566c92b
@Ocramius Ocramius #6142 - adding tests to verify that the `ClassMethods` hydrator can a…
…ct on separate object types
ff0b06d
@Ocramius Ocramius #6142 - Caching the hydration methods per class to avoid calling non-…
…existing methods and for performance
31296ba
@Ocramius Ocramius #6142 - Stubbing out structure of an extraction methods cache ae6138b
@Ocramius Ocramius #6142 - Implementing more performing extraction via an extraction map…
… cache
5c9abf5
@Ocramius Ocramius #6142 - Hydration caches should be reset when filters/strategies are …
…changed
fb0f2f4
@Ocramius Ocramius #6142 - Adding minor comments to distinguish various portions of the …
…caching logic
88bf584
@moderndeveloperllc moderndeveloperllc Merge pull request #1 from Ocramius/feature/#6142-classmethod-hydrato…
…r-optimization

Classmethod hydrator optimization - massive cleanup and extension by @Ocramius
f7e39ca
@staabm staabm Use substr instead of regex 3d783c0
@staabm staabm Fixed CS db6bda4
@staabm staabm Use strpos instead of substr. 0186a20
@Ocramius Ocramius Merge branch 'hotfix/#6245-invalid-date-step-error-with-dst' into dev…
…elop

Close #6245
Forward Port #6245
16b3c36
@Ocramius Ocramius Merge branch 'feature/#6142-setter-matching-performance' into feature/#…
…6142-classmethod-hydrator-optimization
c8d78ff
@Ocramius Ocramius Merge branch 'feature/#6142-classmethod-hydrator-optimization' into d…
…evelop

Close #6142
69cd791
@vnagara vnagara Removed unnecessary assignment. FallbackResolver wraps entire Aggraga…
…teResolver.
f6d3b89
@samsonasik samsonasik Fixes #6188 6d9c57f
@samsonasik samsonasik added missing full stop 7c011a1
@Ocramius Ocramius Merge branch 'cs/abstract-controller-test-case-closure-braces' into d…
…evelop

Close #6238
Forward Port #6238
c0fa304
@weierophinney weierophinney Merge branch 'hotfix/6033' into develop
Forward port #6033
122c1cd
@vnagara vnagara Fix infinite recursion. Revert to wrap evry resolver. 8d5a9db
@BreyndotEchse BreyndotEchse Update StringTrim to allow '0' as charlist
Update Zend\Filter\StringTrim to allow '0' as charlist
b581082
@BreyndotEchse BreyndotEchse Add Test for empty charlist in StringTrim d871d57
@sbtoledo sbtoledo HTML5 compliant form attributes
According to W3C specification, form ‘action’ attribute can’t be empty in HTML5 — but now, is optional. So, if the form doctype is ‘HTML5’ or ‘XHTML5’, the form action isn’t set as an empty string. Also, if either doctypes are detected, form ‘method’ attribute is not set to ‘get’ by default, as some applications may use only ‘formmethod’ attribute on submit buttons (according to W3C, “missing value default for the method attribute is also the GET state” — and this is valid since HTML 2.0).

Reference:
- http://www.w3.org/TR/html5/forms.html#attr-fs-action
- http://www.w3.org/TR/html5/forms.html#attr-fs-method
d346f9c
@sbtoledo sbtoledo Use of Zend\View\Helper\Doctype constants 0e064e3
@BreyndotEchse BreyndotEchse Update StringTrimTest.php adf6890
@Ocramius Ocramius #6271 - avoiding `else` clauses where possible 03f3602
@Ocramius Ocramius #6271 - better conditional 2f75195
@Ocramius Ocramius Merge branch 'hotfix/#6271-default-form-tag-action-and-method' into d…
…evelop

Close #6271
438fe5e
@Ocramius Ocramius Merge branch 'hotfix/#6184-deprecated-mongodb-flags-replacement'
Close #6184
0f72a6f
@Ocramius Ocramius Merge branch 'hotfix/#6184-deprecated-mongodb-flags-replacement' into…
… develop

Close #6184
Forward Port #6184
ada5dba
@Ocramius Ocramius Merge branch 'doc/#6254-per-component-contributing.md'
Close #6254
Close #6188
794f8d9
@Ocramius Ocramius Merge branch 'doc/#6254-per-component-contributing.md' into develop
Close #6254
Close #6188
Forward Port #6254
Forward Port #6188
7382d34
@Ocramius Ocramius #6223 - cs (alignment) e8cc41a
@Ocramius Ocramius #6223 - cs (braces on own line) 9be04f2
@Ocramius Ocramius #6223 - coverage annotation ecd40d8
@Ocramius Ocramius #6223 - removing unused imports 7246ed3
@Ocramius Ocramius Merge branch 'hotfix/#6223-soap-registration-of-complex-type'
Close #6223
9f4a9bc
@Ocramius Ocramius Merge branch 'hotfix/#6223-soap-registration-of-complex-type' into de…
…velop

Close #6223
Forward Port #6223
5451a95
David Stockton Digit filter should not touch boolean dde042f
@BreyndotEchse BreyndotEchse Update StringTrimTest.php
Removed trailing spaces
4a1ab31
David Stockton Early return for int values which are always just digits ec6dfa9
@Ocramius Ocramius #6261 - minor CS fixes in `StringTrim` 5ac5618
@Ocramius Ocramius #6261 - adding missing coverage annotations 8540c90
@Ocramius Ocramius #6261 - adding missing group annotation 2ba7c56
@Ocramius Ocramius Merge branch 'hotfix/#6261-string-trim-allows-0-in-charlist'
Close #6261
067e6a6
@Ocramius Ocramius Merge branch 'hotfix/#6261-string-trim-allows-0-in-charlist' into dev…
…elop

Close #6261
Forward Port #6261
f42f0f0
@Ocramius Ocramius #6196 - adding missing coverage annotations b5275cd
@Ocramius Ocramius #6196 - completely importing dependencies 9e26b10
@Ocramius Ocramius #6196 - minor CS fixes - removing useless imports 23dfb36
@Ocramius Ocramius #6196 - fixed unresolved referenced symbol 2f264fd
@Ocramius Ocramius #6196 - adding missing hints 0cf1395
@Ocramius Ocramius #6196 - Reverting feedback of zendframework/zendframework@c98907d
This class does not need to be designed for extension. Replacing it is preferrable.
1a48de2
@Ocramius Ocramius #6196 - Removing unused docblock 8df959c
@Ocramius Ocramius #6196 - Adding docblock describing the purpose of the relative fallba…
…ck resolver class
4e69733
@Ocramius Ocramius #6196 - The fallback resolver should ignore unknown view renderer types d426a05
@Ocramius Ocramius #6196 - The fallback resolver should ignore renderers that don't prov…
…ide the correct plugin type
39f27ee
@Ocramius Ocramius #6196 - Fallback resolver skips on invalid `view_model` plugin type 297baf7
@Ocramius Ocramius #6196 - Fallback resolver skips should skip when no view model is cur…
…rently set
0a7f309
@Ocramius Ocramius #6196 - Fallback resolver skips when no view model is currently set eea8e6b
@Ocramius Ocramius #6196 - CS - wrong type hints, removing unused assignment 92f98db
@Ocramius Ocramius #6196 - CS - using `call_user_func` to actually use the callable that…
… was instantiated

Also moving success path to the end of the code block
dd79150
@Ocramius Ocramius #6196 - Inlining wrapped resolver call 9d1dc8b
@Ocramius Ocramius Merge branch 'feature/#6196-subpath-fallback-resolver' into develop
Close #6196
faf4541
@Ocramius Ocramius #6196 - fixed coverage annotation referencing non existing class 0a2cfe1
@vnagara

We should put it accurate here: remove some from my/module/script/path/some/partial.phtml or add it to my/module/script/path/my-view.

@mwillbanks
Collaborator

@moderndeveloperllc

Any particular reason we have actual country and, in the regions code, region names? I was under the impression that this was solely a validator - does AF exist as a country. Removing names allows for simple arrays.

  • Simple arrays are nice; however, the meta data comes in very handy when displaying forms and additional types of data. More often than not you are going to want to transform them to a variable of some kind and in a simple data structure this is not possible.

Are we really wanting to distribute binary files that are very difficult for the user to update? The ResourceBundle .res format is not trivial to work with. Removing country/region names would make for much smaller arrays and might alleviate the desire to break the data out separately.

  • I actually do not like the ResourceBundle's for this; I had attempted to utilize them at one point during the comments and was having quite the trouble getting them to cooperate with the structures I was putting in place.

If we go with .res files, should I follow the PhoneNumber directory structure to create the data directories, or would you prefer something different?

  • The data structure is really not the most important thing here; it would likely be somewhat different and based more on how a resource bundle is used in practice.
@mwillbanks mwillbanks changed the title from New I18n Validator: CountryCode with companion CountryDb to [WIP] New I18n Validator: CountryCode with companion CountryDb
@mwillbanks
Collaborator

I've added in a few examples of the resource bundles; a sample folder structure with the source and then the generated. The actual code would then be changed to something like the following:

$r = ResourceBundle::create('official', __DIR__);
var_dump(iterator_to_array($r)); // this will get associative key => value pairs

For validation, we could check via:

$r->get('AD')

If it returns something it is good to go.

The fault with this approach is that you cannot extend the list easily nor really at all. While it may be a bit more memory proficient I'm not completely sold on the resource bundle route. I'm also having a hard time understand how I should put this in so that it is more scalable by language or something to that degree.

@weierophinney @DASPRiD ideas?

Once we determine this I think I can complete this week so that we can finally close this out and merge it in!

@mwillbanks
Collaborator

@weierophinney @DASPRiD bump.

If we don't want this; I am just going to close the PR :facepunch:

@moderndeveloperllc

@mwillbanks Sorry to see this has languished without Zend feedback. I still think it's a good idea if this were simplified down to just a validator of the country code. You're right in that storing country names might be useful, but that runs against the single responsibility idea of programming. A country code validator should validate a code and nothing else.

Honestly, this should be in the Zend/Validator namespace as there are no I18n considerations involved - the codes are universal. Country names are locale-specific and it would be a bad precedent to store English-only data. You can already get country names with code with

var_dump(Locale::getDisplayRegion('-US', 'fr');

string 'États-Unis' (length=11)

You put in a region code preceded by a dash (no language) then the locale you want the name displayed in.

@glen-84

I agree with not storing the country names – see my first comment above.

@weierophinney

@mwillbanks The approach you used seems fine to me; it's easy to update as needed (which will likely be quite infrequently), and developers can extend it easily if desired to "monkey patch" it when needed.

Remove the resource bundle files, and we can merge. :)

@samsonasik

@mwillbanks and please incorporate feedback, at least for copyright year :D

@Ocramius
Collaborator

@mwillbanks this PR could need a rebase

@samsonasik

and incorporate feedback...

@Ocramius
Collaborator

@mwillbanks somehow the entire branch is messed up (requires rebase) :-\

@adamlundrigan

I take it from @weierophinney's comment that this is nearly ready, just needs a tidyup. If @mwillbanks is busy I can sheppard this down the home stretch for inclusion in 2.4

@samsonasik

@Ocramius @mwillbanks I think it can be close in favor of #6888

@Ocramius Ocramius self-assigned this
@Ocramius Ocramius removed this from the 2.4.0 milestone
@Ocramius Ocramius closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.