Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/qa-tools'
Browse files Browse the repository at this point in the history
Close #57
Close #59
Close #61
Close #66
Close #68
Close #69
Close #70
  • Loading branch information
weierophinney committed May 17, 2017
2 parents 3e0495b + 0ff9b84 commit db8e85e
Show file tree
Hide file tree
Showing 74 changed files with 464 additions and 339 deletions.
45 changes: 0 additions & 45 deletions .php_cs

This file was deleted.

78 changes: 49 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,88 @@ cache:

env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit"
- SITE_URL: https://zendframework.github.io/zend-i18n
- GH_USER_NAME: "Matthew Weier O'Phinney"
- GH_USER_EMAIL: [email protected]
- GH_REF: github.com/zendframework/zend-i18n.git
- secure: "ACz/CDPU1Nv2mqQL7UZaULiHrlIafQW/ytNc8ijY1fLwrEt1uglh0bqwmW8mu0PN+dcKUTveDSLR2SPUiyXRkUZkehET9pl+Et4gYQ+4ulxvN4El1lQsGHky+xlAVVDuX5v9yWd+0k8FbklDdVmPc6EpXDCj+ul9noMg90K283Fe5/nRmZTmBBCkxBFLsXSmtiCWpuTuWIdGxz4rdTtl8LcpYQx/oxMy5e50HTbgmUfEEr9yeEfw/i0RWCo6+fjM/y+ZB0IHApDYMmR5yp0ZmFm+d/ISmd1rdmYxgrsUAIWwfd7Q/ukF4C0iZVfg1q14bLJqVkCxPJlNVjbFxbJ0EfpyJJqpQPNvHMo92BqbcRDcBSfwoRyeiE0vyH/T2ni38ZuA16qOd/WJILtNHtPVesyJQV5D2vi8b2fAq2givp28/BxXC/7RVzvyv2INZJXrjrJkbbzphf6bAxxyrvDlE+i01N/yy84bkDHMzdQstDLMC0sZa2GicZDg6box/BlquXjy75n+NBYBfyBhftKIJkeDoSPSZxUWfbm7EX1GoPzl1AbTKhhTlbWLMp1jhJQyi2KjrkpyYtS2IH6vnH1fc85QdZhrRfrHDpHm5+kQ5pbPW/pCDX/1BwPJQ9CZELoENicX1r4uzZA2M1hCzrSEbKyapMC8SmoJ4pdOybAn7Ow="

matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- DEPS=lowest
- php: 5.5
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- DEPS=latest
- CS_CHECK=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- DEPS=lowest
- php: 5.6
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- DEPS=latest
- TEST_COVERAGE=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- php: hhvm
- php: hhvm
<<<<<<< HEAD
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=lowest
=======
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- php: hhvm
>>>>>>> xtreamwayz/hotfix/slack-notifications
- php: hhvm
env:
- DEPS=latest
allow_failures:
- php: hhvm

notifications:
irc: "irc.freenode.org#zftalk.dev"
email: false

before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
- if [[ $EVENT_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-eventmanager:$EVENT_MANAGER_VERSION" ; fi
- if [[ $EVENT_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-eventmanager:^3.0" ; fi
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev satooshi/php-coveralls:^1.0 ; fi
- if [[ $TRAVIS_PHP_VERSION != "hhvm" && $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini ; fi
- travis_retry composer self-update

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs
- travis_retry composer install $COMPOSER_ARGS
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- composer show

script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit -c phpunit.xml.travis --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit -c phpunit.xml.travis ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

after_success:
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls -v ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

notifications:
email: false
slack:
rooms:
- secure: "IS9fIP+miHpjrHSQQW28r7SMr0ieUepAQ1tHiry+Kr+rV5ZHtjDkAkBNSlU25zdVPnMpYzRBQ4rCTIpKF9QPGDAj7/kvGBAkz+RFqtu0ZmWPexaFnJ8G69Flc6j6bRPqqMOlOqzQzXoumShQ1jRIZToMTxDm+FyfEbokRDXzTnC2zIj3NFQMMmw/yrmn6+ye6OJmlnDSZm33rzN9sluNTN81cBXLWoriQrHjOjLozyse0olo4oBBABZN9pTv2zSbImZ9dc/VOj1jgRJ5UUChRs7pTeEByeEoQxkwyqYTM6vcbdm/+hno4Fkmkg/CyMY3DbQLBq+nrrH34wkT6NOff92eTrkbyUCOhjTAm73FS6N+YQfJkYMjR5HTklEmXhgxL3JiRM2j6gcVl8qAlPtW5sr/9l3KvGlHIAmlTzBkhJ0rgukVhTkRNyu7ivM6egfRictdw73DcYohZEcvpy9ifJtDiJhz8BrqYko4oaGM/T/4cacbvbfB9inUbb3Rgmg6WVBmZ+V/nS1BCNCckhuaCaBivf7geSvPc+1HwPtFGDITaxDEiCih1mrrVoNHVXIjcW2mOR/AMG8tZZZruHob/rN4gvxFdTUUpwRwhUJ/LF9nbrKpa1RRJYC9d/97iw54t2y5G1JzthAjzOwcaF9Xj+YkOb+Mq2E2mfmW3m7bmV0="
on_success: change
on_failure: always
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ To do so:

## Running Coding Standards Checks

This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding
standards checks, and provides configuration for our selected checks.
`php-cs-fixer` is installed by default via Composer.
`phpcs` is installed by default via Composer.

To run checks only:

```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
$ composer cs-check
```

To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
flag:
`phpcs` also includes a tool for fixing most CS violations, `phpcbf`:


```console
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
$ composer cs-fix
```

If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Recommended Workflow for Contributions
Expand Down
19 changes: 15 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
}
},
"require": {
"php": "^5.5 || ^7.0",
"php": "^7.0 || ^5.6",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"require-dev": {
"phpunit/PHPUnit": "^6.0.8 || ^5.7.15",
"zendframework/zend-cache": "^2.6.1",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-config": "^2.6",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-filter": "^2.6.1",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-validator": "^2.6",
"zendframework/zend-view": "^2.6.3",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
"zendframework/zend-view": "^2.6.3"
},
"suggest": {
"ext-intl": "Required for most features of Zend\\I18n; included in default builds of PHP",
Expand All @@ -52,5 +52,16 @@
"psr-4": {
"ZendTest\\I18n\\": "test/"
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"upload-coverage": "coveralls -v"
}
}
2 changes: 1 addition & 1 deletion doc/book/translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nothing but return all messages verbatim.

## Adding translations

To options exist for adding translations to the translator:
Two options exist for adding translations to the translator:

- Add every translation file individually; use this for translation formats that
store multiple locales in the same file.
Expand Down
94 changes: 92 additions & 2 deletions doc/book/validators.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Several languages supported by ext/intl use alphabets where characters are
formed from multiple bytes, including *Korean*, *Japanese*, and *Chinese*. Such
languages therefore are unsupported with regards to the `Alnum` validator.

When using the `Alnum` validator with these langauges, the input will be validated
When using the `Alnum` validator with these languages, the input will be validated
using the English alphabet.

## Alpha
Expand Down Expand Up @@ -119,7 +119,7 @@ Three languages supported by ext/intl, however, define multibyte characters,
which cannot be matched as alphabetic characters using normal string or regular
expression options. These include *Korean*, *Japanese*, and *Chinese*.

As a result, when using the `Alpha` validator with these langauges, the input
As a result, when using the `Alpha` validator with these languages, the input
will be validated using the English alphabet.

## IsFloat
Expand Down Expand Up @@ -241,3 +241,93 @@ instantiation. Please update your code to refer to the `IsInt` class instead.

Users pulling their `Int` validator instance from the validator plugin manager
receive an `IsInt` instance instead starting in 2.4.0.

## PostCode

`Zend\I18n\Validator\PostCode` allows you to determine if a given value is a
valid postal code. Postal codes are specific to cities, and in some locales
termed ZIP codes.

`Zend\I18n\Validator\PostCode` knows more than 160 different postal code
formats. To select the correct format there are two ways. You can either use a
fully qualified locale, or you can set your own format manually.

### Supported options

The following options are supported for `Zend\I18n\Validator\PostCode`:

- `format`: Sets a postcode format which will be used for validation of the
input.
- `locale`: Sets a locale from which the postcode will be taken from.

### Usage

Using a locale is more convenient as zend-validator already knows the
appropriate postal code format for each locale; however, you need to use the
fully qualified locale (one containing a region specifier) to do so. For
instance, the locale `de` is a locale but could not be used with
`Zend\I18n\Validator\PostCode` as it does not include the region; `de_AT`,
however, would be a valid locale, as it specifies the region code (`AT`, for
Austria).

```php
$validator = new Zend\I18n\Validator\PostCode('de_AT');
```

When you don't set a locale yourself, then `Zend\I18n\Validator\PostCode` will
use the application wide set locale, or, when there is none, the locale returned
by `Locale`.

```php
// application wide locale within your bootstrap
Locale::setDefault('de_AT');

$validator = new Zend\I18n\Validator\PostCode();
```

You can also change the locale afterwards by calling `setLocale()`. And of
course you can get the actual used locale by calling `getLocale()`.

```php
$validator = new Zend\I18n\Validator\PostCode('de_AT');
$validator->setLocale('en_GB');
```

Postal code formats are regular expression strings. When the international
postal code format, which is used by setting the locale, does not fit your
needs, then you can also manually set a format by calling `setFormat()`.

```php
$validator = new Zend\I18n\Validator\PostCode('de_AT');
$validator->setFormat('AT-\d{5}');
```

> ### Conventions for self defined formats
>
> When using self defined formats, you should omit the regex delimiters and
> anchors (`'/^'` and `'$/'`). They are attached automatically.
>
> You should also be aware that postcode values will always be validated in a
> strict way. This means that they have to be written standalone without
> additional characters when they are not covered by the format.
### Constructor options

At its most basic, you may pass a string representing a fully qualified locale
to the constructor of `Zend\I18n\Validator\PostCode`.

```php
$validator = new Zend\I18n\Validator\PostCode('de_AT');
```

Additionally, you may pass either an array or a `Traversable` instance to the
constructor. When you do so, you must include either the key `locale` or
`format`; these will be used to set the appropriate values in the validator
object.

```php
$validator = new Zend\I18n\Validator\PostCode([
'locale' => 'de_AT',
'format' => 'AT_\d+'
]);
```
10 changes: 10 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>src/Validator/PhoneNumber/*</exclude-pattern>
<exclude-pattern>*/_files/*</exclude-pattern>
</ruleset>
4 changes: 2 additions & 2 deletions src/Filter/AbstractLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract class AbstractLocale extends AbstractFilter
*/
public function __construct()
{
if (!extension_loaded('intl')) {
if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
Expand All @@ -47,7 +47,7 @@ public function setLocale($locale = null)
*/
public function getLocale()
{
if (!isset($this->options['locale'])) {
if (! isset($this->options['locale'])) {
$this->options['locale'] = Locale::getDefault();
}
return $this->options['locale'];
Expand Down
Loading

0 comments on commit db8e85e

Please sign in to comment.