diff --git a/.php_cs b/.php_cs
deleted file mode 100644
index 8f4dd5aa..00000000
--- a/.php_cs
+++ /dev/null
@@ -1,45 +0,0 @@
-in('src')
- ->in('test')
- ->notPath('TestAsset')
- ->notPath('_files')
- ->filter(function (SplFileInfo $file) {
- if (strstr($file->getPath(), 'compatibility')) {
- return false;
- }
- });
-$config = Symfony\CS\Config\Config::create();
-$config->level(null);
-$config->fixers(
- array(
- 'braces',
- 'duplicate_semicolon',
- 'elseif',
- 'empty_return',
- 'encoding',
- 'eof_ending',
- 'function_call_space',
- 'function_declaration',
- 'indentation',
- 'join_function',
- 'line_after_namespace',
- 'linefeed',
- 'lowercase_keywords',
- 'parenthesis',
- 'multiple_use',
- 'method_argument_space',
- 'object_operator',
- 'php_closing_tag',
- 'remove_lines_between_uses',
- 'short_array_syntax',
- 'short_tag',
- 'standardize_not_equal',
- 'trailing_spaces',
- 'unused_use',
- 'visibility',
- 'whitespacy_lines',
- )
-);
-$config->finder($finder);
-return $config;
diff --git a/.travis.yml b/.travis.yml
index 813a6c85..4093bdf1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,6 +15,9 @@ 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: matthew@weierophinney.net
@@ -22,61 +25,78 @@ env:
- 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
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dadf3128..e2205f61 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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
diff --git a/composer.json b/composer.json
index cfbc5a41..c9f69257 100644
--- a/composer.json
+++ b/composer.json
@@ -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",
@@ -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"
}
}
diff --git a/doc/book/translation.md b/doc/book/translation.md
index 9c8deedf..ad5609c5 100644
--- a/doc/book/translation.md
+++ b/doc/book/translation.md
@@ -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.
diff --git a/doc/book/validators.md b/doc/book/validators.md
index 70d18d99..b3e31f8e 100644
--- a/doc/book/validators.md
+++ b/doc/book/validators.md
@@ -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
@@ -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
@@ -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+'
+]);
+```
\ No newline at end of file
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 00000000..b4eb2e3b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ src
+ test
+ src/Validator/PhoneNumber/*
+ */_files/*
+
\ No newline at end of file
diff --git a/src/Filter/AbstractLocale.php b/src/Filter/AbstractLocale.php
index ffff1b1d..3610b4e3 100644
--- a/src/Filter/AbstractLocale.php
+++ b/src/Filter/AbstractLocale.php
@@ -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__
@@ -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'];
diff --git a/src/Filter/Alnum.php b/src/Filter/Alnum.php
index 0dee4580..702c35e4 100644
--- a/src/Filter/Alnum.php
+++ b/src/Filter/Alnum.php
@@ -73,14 +73,14 @@ public function getAllowWhiteSpace()
*/
public function filter($value)
{
- if (!is_scalar($value) && !is_array($value)) {
+ if (! is_scalar($value) && ! is_array($value)) {
return $value;
}
$whiteSpace = $this->options['allow_white_space'] ? '\s' : '';
$language = Locale::getPrimaryLanguage($this->getLocale());
- if (!static::hasPcreUnicodeSupport()) {
+ if (! static::hasPcreUnicodeSupport()) {
// POSIX named classes are not supported, use alternative a-zA-Z0-9 match
$pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/';
} elseif ($language == 'ja'|| $language == 'ko' || $language == 'zh') {
diff --git a/src/Filter/Alpha.php b/src/Filter/Alpha.php
index ad468f53..80175d03 100644
--- a/src/Filter/Alpha.php
+++ b/src/Filter/Alpha.php
@@ -23,14 +23,14 @@ class Alpha extends Alnum
*/
public function filter($value)
{
- if (!is_scalar($value) && !is_array($value)) {
+ if (! is_scalar($value) && ! is_array($value)) {
return $value;
}
$whiteSpace = $this->options['allow_white_space'] ? '\s' : '';
$language = Locale::getPrimaryLanguage($this->getLocale());
- if (!static::hasPcreUnicodeSupport()) {
+ if (! static::hasPcreUnicodeSupport()) {
// POSIX named classes are not supported, use alternative [a-zA-Z] match
$pattern = '/[^a-zA-Z' . $whiteSpace . ']/';
} elseif ($language == 'ja' || $language == 'ko' || $language == 'zh') {
diff --git a/src/Filter/NumberFormat.php b/src/Filter/NumberFormat.php
index 9c53c752..865483e7 100644
--- a/src/Filter/NumberFormat.php
+++ b/src/Filter/NumberFormat.php
@@ -22,11 +22,11 @@ class NumberFormat extends NumberParse
*/
public function filter($value)
{
- if (!is_scalar($value)) {
+ if (! is_scalar($value)) {
return $value;
}
- if (!is_int($value) && !is_float($value)) {
+ if (! is_int($value) && ! is_float($value)) {
$result = parent::filter($value);
} else {
ErrorHandler::start();
diff --git a/src/Filter/NumberParse.php b/src/Filter/NumberParse.php
index 3a8a7f0d..f8f43633 100644
--- a/src/Filter/NumberParse.php
+++ b/src/Filter/NumberParse.php
@@ -43,7 +43,7 @@ public function __construct(
$localeOrOptions = iterator_to_array($localeOrOptions);
}
- if (!is_array($localeOrOptions)) {
+ if (! is_array($localeOrOptions)) {
$this->setLocale($localeOrOptions);
$this->setStyle($style);
$this->setType($type);
@@ -119,7 +119,7 @@ public function getFormatter()
{
if ($this->formatter === null) {
$formatter = NumberFormatter::create($this->getLocale(), $this->getStyle());
- if (!$formatter) {
+ if (! $formatter) {
throw new Exception\RuntimeException(
'Can not create NumberFormatter instance; ' . intl_get_error_message()
);
@@ -140,8 +140,8 @@ public function getFormatter()
*/
public function filter($value)
{
- if (!is_int($value)
- && !is_float($value)
+ if (! is_int($value)
+ && ! is_float($value)
) {
ErrorHandler::start();
diff --git a/src/Translator/Loader/AbstractFileLoader.php b/src/Translator/Loader/AbstractFileLoader.php
index 28527326..661de8bf 100644
--- a/src/Translator/Loader/AbstractFileLoader.php
+++ b/src/Translator/Loader/AbstractFileLoader.php
@@ -56,8 +56,8 @@ public function useIncludePath()
*/
protected function resolveFile($filename)
{
- if (!is_file($filename) || !is_readable($filename)) {
- if (!$this->useIncludePath()) {
+ if (! is_file($filename) || ! is_readable($filename)) {
+ if (! $this->useIncludePath()) {
return false;
}
return $this->resolveViaIncludePath($filename);
@@ -74,7 +74,7 @@ protected function resolveFile($filename)
protected function resolveViaIncludePath($filename)
{
$resolvedIncludePath = stream_resolve_include_path($filename);
- if (!$resolvedIncludePath || !is_file($resolvedIncludePath) || !is_readable($resolvedIncludePath)) {
+ if (! $resolvedIncludePath || ! is_file($resolvedIncludePath) || ! is_readable($resolvedIncludePath)) {
return false;
}
return $resolvedIncludePath;
diff --git a/src/Translator/Loader/Gettext.php b/src/Translator/Loader/Gettext.php
index 0821d5b3..2a23d5df 100644
--- a/src/Translator/Loader/Gettext.php
+++ b/src/Translator/Loader/Gettext.php
@@ -45,7 +45,7 @@ class Gettext extends AbstractFileLoader
public function load($locale, $filename)
{
$resolvedFile = $this->resolveFile($filename);
- if (!$resolvedFile) {
+ if (! $resolvedFile) {
throw new Exception\InvalidArgumentException(sprintf(
'Could not find or open file %s for reading',
$filename
diff --git a/src/Translator/Loader/Ini.php b/src/Translator/Loader/Ini.php
index ef2caf9f..e23a731c 100644
--- a/src/Translator/Loader/Ini.php
+++ b/src/Translator/Loader/Ini.php
@@ -32,7 +32,7 @@ public function load($locale, $filename)
{
$resolvedIncludePath = stream_resolve_include_path($filename);
$fromIncludePath = ($resolvedIncludePath !== false) ? $resolvedIncludePath : $filename;
- if (!$fromIncludePath || !is_file($fromIncludePath) || !is_readable($fromIncludePath)) {
+ if (! $fromIncludePath || ! is_file($fromIncludePath) || ! is_readable($fromIncludePath)) {
throw new Exception\InvalidArgumentException(sprintf(
'Could not find or open file %s for reading',
$filename
@@ -49,7 +49,7 @@ public function load($locale, $filename)
}
foreach ($list as $message) {
- if (!is_array($message) || count($message) < 2) {
+ if (! is_array($message) || count($message) < 2) {
throw new Exception\InvalidArgumentException(
'Each INI row must be an array with message and translation'
);
@@ -61,7 +61,7 @@ public function load($locale, $filename)
$messages[array_shift($message)] = array_shift($message);
}
- if (!is_array($messages)) {
+ if (! is_array($messages)) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected an array, but received %s',
gettype($messages)
diff --git a/src/Translator/Loader/PhpArray.php b/src/Translator/Loader/PhpArray.php
index 10fdab87..eef918d3 100644
--- a/src/Translator/Loader/PhpArray.php
+++ b/src/Translator/Loader/PhpArray.php
@@ -31,7 +31,7 @@ public function load($locale, $filename)
{
$resolvedIncludePath = stream_resolve_include_path($filename);
$fromIncludePath = ($resolvedIncludePath !== false) ? $resolvedIncludePath : $filename;
- if (!$fromIncludePath || !is_file($fromIncludePath) || !is_readable($fromIncludePath)) {
+ if (! $fromIncludePath || ! is_file($fromIncludePath) || ! is_readable($fromIncludePath)) {
throw new Exception\InvalidArgumentException(sprintf(
'Could not find or open file %s for reading',
$filename
@@ -40,7 +40,7 @@ public function load($locale, $filename)
$messages = include $fromIncludePath;
- if (!is_array($messages)) {
+ if (! is_array($messages)) {
throw new Exception\InvalidArgumentException(sprintf(
'Expected an array, but received %s',
gettype($messages)
diff --git a/src/Translator/Loader/PhpMemoryArray.php b/src/Translator/Loader/PhpMemoryArray.php
index dc9b9e38..1d7cd3d8 100644
--- a/src/Translator/Loader/PhpMemoryArray.php
+++ b/src/Translator/Loader/PhpMemoryArray.php
@@ -39,19 +39,19 @@ public function __construct($messages)
*/
public function load($locale, $textDomain)
{
- if (!is_array($this->messages)) {
+ if (! is_array($this->messages)) {
throw new Exception\InvalidArgumentException(
sprintf('Expected an array, but received %s', gettype($this->messages))
);
}
- if (!isset($this->messages[$textDomain])) {
+ if (! isset($this->messages[$textDomain])) {
throw new Exception\InvalidArgumentException(
sprintf('Expected textdomain "%s" to be an array, but it is not set', $textDomain)
);
}
- if (!isset($this->messages[$textDomain][$locale])) {
+ if (! isset($this->messages[$textDomain][$locale])) {
throw new Exception\InvalidArgumentException(
sprintf('Expected locale "%s" to be an array, but it is not set', $locale)
);
diff --git a/src/Translator/LoaderPluginManager.php b/src/Translator/LoaderPluginManager.php
index 83714beb..d3116965 100644
--- a/src/Translator/LoaderPluginManager.php
+++ b/src/Translator/LoaderPluginManager.php
@@ -92,7 +92,8 @@ public function validate($plugin)
}
throw new InvalidServiceException(sprintf(
- 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface or %s\Loader\RemoteLoaderInterface',
+ 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface '
+ . 'or %s\Loader\RemoteLoaderInterface',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__,
__NAMESPACE__
@@ -113,7 +114,8 @@ public function validatePlugin($plugin)
$this->validate($plugin);
} catch (InvalidServiceException $e) {
throw new Exception\RuntimeException(sprintf(
- 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface or %s\Loader\RemoteLoaderInterface',
+ 'Plugin of type %s is invalid; must implement %s\Loader\FileLoaderInterface '
+ . 'or %s\Loader\RemoteLoaderInterface',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__,
__NAMESPACE__
diff --git a/src/Translator/Plural/Parser.php b/src/Translator/Plural/Parser.php
index 8b5f9f21..7b6830de 100644
--- a/src/Translator/Plural/Parser.php
+++ b/src/Translator/Plural/Parser.php
@@ -211,8 +211,8 @@ protected function registerSymbol($id, $leftBindingPower = 0)
*/
protected function getSymbol($id)
{
- if (!isset($this->symbolTable[$id])) {
- // Unkown symbol exception
+ if (! isset($this->symbolTable[$id])) {
+ // Unknown symbol exception
}
return clone $this->symbolTable[$id];
diff --git a/src/Translator/Plural/Rule.php b/src/Translator/Plural/Rule.php
index 1b310963..ecb3d9ee 100644
--- a/src/Translator/Plural/Rule.php
+++ b/src/Translator/Plural/Rule.php
@@ -161,7 +161,7 @@ protected function evaluateAstPart(array $ast, $number)
? 1 : 0;
case '!':
- return !$this->evaluateAstPart($ast['arguments'][0], $number)
+ return ! $this->evaluateAstPart($ast['arguments'][0], $number)
? 1 : 0;
case '?':
@@ -190,7 +190,7 @@ public static function fromString($string)
static::$parser = new Parser();
}
- if (!preg_match('(nplurals=(?P\d+))', $string, $match)) {
+ if (! preg_match('(nplurals=(?P\d+))', $string, $match)) {
throw new Exception\ParseException(sprintf(
'Unknown or invalid parser rule: %s',
$string
@@ -199,7 +199,7 @@ public static function fromString($string)
$numPlurals = (int) $match['nplurals'];
- if (!preg_match('(plural=(?P[^;\n]+))', $string, $match)) {
+ if (! preg_match('(plural=(?P[^;\n]+))', $string, $match)) {
throw new Exception\ParseException(sprintf(
'Unknown or invalid parser rule: %s',
$string
diff --git a/src/Translator/TextDomain.php b/src/Translator/TextDomain.php
index ee746ba1..d74549ca 100644
--- a/src/Translator/TextDomain.php
+++ b/src/Translator/TextDomain.php
@@ -98,7 +98,9 @@ public function merge(TextDomain $textDomain)
{
if ($this->hasPluralRule() && $textDomain->hasPluralRule()) {
if ($this->getPluralRule()->getNumPlurals() !== $textDomain->getPluralRule()->getNumPlurals()) {
- throw new Exception\RuntimeException('Plural rule of merging text domain is not compatible with the current one');
+ throw new Exception\RuntimeException(
+ 'Plural rule of merging text domain is not compatible with the current one'
+ );
}
} elseif ($textDomain->hasPluralRule()) {
$this->setPluralRule($textDomain->getPluralRule());
diff --git a/src/Translator/Translator.php b/src/Translator/Translator.php
index bb82a33c..575d964e 100644
--- a/src/Translator/Translator.php
+++ b/src/Translator/Translator.php
@@ -118,7 +118,7 @@ public static function factory($options)
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
- } elseif (!is_array($options)) {
+ } elseif (! is_array($options)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an array or Traversable object; received "%s"',
__METHOD__,
@@ -139,7 +139,7 @@ public static function factory($options)
// file patterns
if (isset($options['translation_file_patterns'])) {
- if (!is_array($options['translation_file_patterns'])) {
+ if (! is_array($options['translation_file_patterns'])) {
throw new Exception\InvalidArgumentException(
'"translation_file_patterns" should be an array'
);
@@ -148,7 +148,7 @@ public static function factory($options)
$requiredKeys = ['type', 'base_dir', 'pattern'];
foreach ($options['translation_file_patterns'] as $pattern) {
foreach ($requiredKeys as $key) {
- if (!isset($pattern[$key])) {
+ if (! isset($pattern[$key])) {
throw new Exception\InvalidArgumentException(
"'{$key}' is missing for translation pattern options"
);
@@ -166,7 +166,7 @@ public static function factory($options)
// files
if (isset($options['translation_files'])) {
- if (!is_array($options['translation_files'])) {
+ if (! is_array($options['translation_files'])) {
throw new Exception\InvalidArgumentException(
'"translation_files" should be an array'
);
@@ -175,7 +175,7 @@ public static function factory($options)
$requiredKeys = ['type', 'filename'];
foreach ($options['translation_files'] as $file) {
foreach ($requiredKeys as $key) {
- if (!isset($file[$key])) {
+ if (! isset($file[$key])) {
throw new Exception\InvalidArgumentException(
"'{$key}' is missing for translation file options"
);
@@ -193,7 +193,7 @@ public static function factory($options)
// remote
if (isset($options['remote_translation'])) {
- if (!is_array($options['remote_translation'])) {
+ if (! is_array($options['remote_translation'])) {
throw new Exception\InvalidArgumentException(
'"remote_translation" should be an array'
);
@@ -202,7 +202,7 @@ public static function factory($options)
$requiredKeys = ['type'];
foreach ($options['remote_translation'] as $remote) {
foreach ($requiredKeys as $key) {
- if (!isset($remote[$key])) {
+ if (! isset($remote[$key])) {
throw new Exception\InvalidArgumentException(
"'{$key}' is missing for remote translation options"
);
@@ -255,7 +255,7 @@ public function setLocale($locale)
public function getLocale()
{
if ($this->locale === null) {
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -335,7 +335,7 @@ public function setPluginManager(LoaderPluginManager $pluginManager)
*/
public function getPluginManager()
{
- if (!$this->pluginManager instanceof LoaderPluginManager) {
+ if (! $this->pluginManager instanceof LoaderPluginManager) {
$this->setPluginManager(new LoaderPluginManager(new ServiceManager));
}
@@ -411,7 +411,7 @@ public function translatePlural(
->getPluralRule()
->evaluate($number);
- if (!isset($translation[$index])) {
+ if (! isset($translation[$index])) {
throw new Exception\OutOfBoundsException(
sprintf('Provided index %d does not exist in plural array', $index)
);
@@ -438,7 +438,7 @@ protected function getTranslatedMessage(
return '';
}
- if (!isset($this->messages[$textDomain][$locale])) {
+ if (! isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
@@ -485,7 +485,7 @@ public function addTranslationFile(
) {
$locale = $locale ?: '*';
- if (!isset($this->files[$textDomain])) {
+ if (! isset($this->files[$textDomain])) {
$this->files[$textDomain] = [];
}
@@ -512,7 +512,7 @@ public function addTranslationFilePattern(
$pattern,
$textDomain = 'default'
) {
- if (!isset($this->patterns[$textDomain])) {
+ if (! isset($this->patterns[$textDomain])) {
$this->patterns[$textDomain] = [];
}
@@ -534,7 +534,7 @@ public function addTranslationFilePattern(
*/
public function addRemoteTranslations($type, $textDomain = 'default')
{
- if (!isset($this->remote[$textDomain])) {
+ if (! isset($this->remote[$textDomain])) {
$this->remote[$textDomain] = [];
}
@@ -554,7 +554,7 @@ public function addRemoteTranslations($type, $textDomain = 'default')
*/
protected function loadMessages($textDomain, $locale)
{
- if (!isset($this->messages[$textDomain])) {
+ if (! isset($this->messages[$textDomain])) {
$this->messages[$textDomain] = [];
}
@@ -573,7 +573,7 @@ protected function loadMessages($textDomain, $locale)
$messagesLoaded |= $this->loadMessagesFromPatterns($textDomain, $locale);
$messagesLoaded |= $this->loadMessagesFromFiles($textDomain, $locale);
- if (!$messagesLoaded) {
+ if (! $messagesLoaded) {
$discoveredTextDomain = null;
if ($this->isEventManagerEnabled()) {
$until = function ($r) {
@@ -618,7 +618,7 @@ protected function loadMessagesFromRemote($textDomain, $locale)
foreach ($this->remote[$textDomain] as $loaderType) {
$loader = $this->getPluginManager()->get($loaderType);
- if (!$loader instanceof RemoteLoaderInterface) {
+ if (! $loader instanceof RemoteLoaderInterface) {
throw new Exception\RuntimeException('Specified loader is not a remote loader');
}
@@ -654,7 +654,7 @@ protected function loadMessagesFromPatterns($textDomain, $locale)
if (is_file($filename)) {
$loader = $this->getPluginManager()->get($pattern['type']);
- if (!$loader instanceof FileLoaderInterface) {
+ if (! $loader instanceof FileLoaderInterface) {
throw new Exception\RuntimeException('Specified loader is not a file loader');
}
@@ -685,14 +685,14 @@ protected function loadMessagesFromFiles($textDomain, $locale)
$messagesLoaded = false;
foreach ([$locale, '*'] as $currentLocale) {
- if (!isset($this->files[$textDomain][$currentLocale])) {
+ if (! isset($this->files[$textDomain][$currentLocale])) {
continue;
}
foreach ($this->files[$textDomain][$currentLocale] as $file) {
$loader = $this->getPluginManager()->get($file['type']);
- if (!$loader instanceof FileLoaderInterface) {
+ if (! $loader instanceof FileLoaderInterface) {
throw new Exception\RuntimeException('Specified loader is not a file loader');
}
@@ -723,7 +723,7 @@ public function getAllMessages($textDomain = 'default', $locale = null)
{
$locale = $locale ?: $this->getLocale();
- if (!isset($this->messages[$textDomain][$locale])) {
+ if (! isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
@@ -737,7 +737,7 @@ public function getAllMessages($textDomain = 'default', $locale = null)
*/
public function getEventManager()
{
- if (!$this->events instanceof EventManagerInterface) {
+ if (! $this->events instanceof EventManagerInterface) {
$this->setEventManager(new EventManager());
}
diff --git a/src/Validator/Alnum.php b/src/Validator/Alnum.php
index 97abfe95..ac10df96 100644
--- a/src/Validator/Alnum.php
+++ b/src/Validator/Alnum.php
@@ -90,7 +90,7 @@ public function setAllowWhiteSpace($allowWhiteSpace)
*/
public function isValid($value)
{
- if (!is_string($value) && !is_int($value) && !is_float($value)) {
+ if (! is_string($value) && ! is_int($value) && ! is_float($value)) {
$this->error(self::INVALID);
return false;
}
diff --git a/src/Validator/Alpha.php b/src/Validator/Alpha.php
index fc045bf4..c5e2f6a3 100644
--- a/src/Validator/Alpha.php
+++ b/src/Validator/Alpha.php
@@ -52,7 +52,7 @@ class Alpha extends Alnum
*/
public function isValid($value)
{
- if (!is_string($value)) {
+ if (! is_string($value)) {
$this->error(self::INVALID);
return false;
}
diff --git a/src/Validator/DateTime.php b/src/Validator/DateTime.php
index 48911e43..4eba6ceb 100644
--- a/src/Validator/DateTime.php
+++ b/src/Validator/DateTime.php
@@ -86,7 +86,7 @@ class DateTime extends AbstractValidator
*/
public function __construct($options = [])
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new I18nException\ExtensionNotLoadedException(
sprintf('%s component requires the intl PHP extension', __NAMESPACE__)
);
@@ -127,7 +127,11 @@ public function setCalendar($calendar)
*/
public function getCalendar()
{
- return ($this->formatter && !$this->invalidateFormatter) ? $this->getIntlDateFormatter()->getCalendar() : $this->calendar;
+ if ($this->formatter && ! $this->invalidateFormatter) {
+ return $this->getIntlDateFormatter()->getCalendar();
+ } else {
+ return $this->calendar;
+ }
}
/**
@@ -174,7 +178,11 @@ public function setPattern($pattern)
*/
public function getPattern()
{
- return ($this->formatter && !$this->invalidateFormatter) ? $this->getIntlDateFormatter()->getPattern() : $this->pattern;
+ if ($this->formatter && ! $this->invalidateFormatter) {
+ return $this->getIntlDateFormatter()->getPattern();
+ } else {
+ return $this->pattern;
+ }
}
/**
@@ -221,7 +229,11 @@ public function setTimezone($timezone)
*/
public function getTimezone()
{
- return ($this->formatter && !$this->invalidateFormatter) ? $this->getIntlDateFormatter()->getTimeZoneId() : $this->timezone;
+ if ($this->formatter && ! $this->invalidateFormatter) {
+ return $this->getIntlDateFormatter()->getTimeZoneId();
+ } else {
+ return $this->timezone;
+ }
}
/**
@@ -257,7 +269,7 @@ public function getLocale()
*/
public function isValid($value)
{
- if (!is_string($value)) {
+ if (! is_string($value)) {
$this->error(self::INVALID);
return false;
diff --git a/src/Validator/IsFloat.php b/src/Validator/IsFloat.php
index 64dc7db6..32f28f2b 100644
--- a/src/Validator/IsFloat.php
+++ b/src/Validator/IsFloat.php
@@ -41,7 +41,7 @@ class IsFloat extends AbstractValidator
protected $locale;
/**
- * UTF-8 compatable wrapper for string functions
+ * UTF-8 compatible wrapper for string functions
*
* @var StringWrapperInterface
*/
@@ -55,7 +55,7 @@ class IsFloat extends AbstractValidator
*/
public function __construct($options = [])
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new I18nException\ExtensionNotLoadedException(
sprintf('%s component requires the intl PHP extension', __NAMESPACE__)
);
@@ -109,7 +109,7 @@ public function setLocale($locale)
*/
public function isValid($value)
{
- if (!is_scalar($value) || is_bool($value)) {
+ if (! is_scalar($value) || is_bool($value)) {
$this->error(self::INVALID);
return false;
}
@@ -139,13 +139,13 @@ public function isValid($value)
$search = '/' . $exponentialSymbols . '/';
}
- if (!preg_match($search, $value)) {
+ if (! preg_match($search, $value)) {
$formatter = new NumberFormatter($this->getLocale(), NumberFormatter::DECIMAL);
}
/**
- * @desc There are seperator "look-alikes" for decimal and group seperators that are more commonly used than the
- * official unicode chracter. We need to replace those with the real thing - or remove it.
+ * @desc There are separator "look-alikes" for decimal and group separators that are more commonly used than the
+ * official unicode character. We need to replace those with the real thing - or remove it.
*/
$groupSeparator = $formatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
$decSeparator = $formatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
@@ -166,7 +166,7 @@ public function isValid($value)
$groupSeparatorPosition = $this->wrapper->strpos($value, $groupSeparator);
$decSeparatorPosition = $this->wrapper->strpos($value, $decSeparator);
- //We have seperators, and they are flipped. i.e. 2.000,000 for en-US
+ //We have separators, and they are flipped. i.e. 2.000,000 for en-US
if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) {
$this->error(self::NOT_FLOAT);
diff --git a/src/Validator/IsInt.php b/src/Validator/IsInt.php
index 17adb9a4..55512438 100644
--- a/src/Validator/IsInt.php
+++ b/src/Validator/IsInt.php
@@ -46,7 +46,7 @@ class IsInt extends AbstractValidator
*/
public function __construct($options = [])
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new I18nException\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -96,7 +96,7 @@ public function setLocale($locale)
*/
public function isValid($value)
{
- if (!is_string($value) && !is_int($value) && !is_float($value)) {
+ if (! is_string($value) && ! is_int($value) && ! is_float($value)) {
$this->error(self::INVALID);
return false;
}
diff --git a/src/Validator/PhoneNumber.php b/src/Validator/PhoneNumber.php
index f37f1e3f..dbd0749d 100644
--- a/src/Validator/PhoneNumber.php
+++ b/src/Validator/PhoneNumber.php
@@ -167,13 +167,13 @@ public function setCountry($country)
*/
protected function loadPattern($code)
{
- if (!isset(static::$phone[$code])) {
- if (!preg_match('/^[A-Z]{2}$/D', $code)) {
+ if (! isset(static::$phone[$code])) {
+ if (! preg_match('/^[A-Z]{2}$/D', $code)) {
return false;
}
$file = __DIR__ . '/PhoneNumber/' . $code . '.php';
- if (!file_exists($file)) {
+ if (! file_exists($file)) {
return false;
}
@@ -192,7 +192,7 @@ protected function loadPattern($code)
*/
public function isValid($value = null, $context = null)
{
- if (!is_scalar($value)) {
+ if (! is_scalar($value)) {
$this->error(self::INVALID);
return false;
@@ -201,12 +201,12 @@ public function isValid($value = null, $context = null)
$country = $this->getCountry();
- if (!$countryPattern = $this->loadPattern(strtoupper($country))) {
+ if (! $countryPattern = $this->loadPattern(strtoupper($country))) {
if (isset($context[$country])) {
$country = $context[$country];
}
- if (!$countryPattern = $this->loadPattern(strtoupper($country))) {
+ if (! $countryPattern = $this->loadPattern(strtoupper($country))) {
$this->error(self::UNSUPPORTED);
return false;
diff --git a/src/Validator/PostCode.php b/src/Validator/PostCode.php
index 8eb42086..f532da11 100644
--- a/src/Validator/PostCode.php
+++ b/src/Validator/PostCode.php
@@ -55,6 +55,7 @@ class PostCode extends AbstractValidator
*/
protected $service;
+ // @codingStandardsIgnoreStart
/**
* Postal Code regexes by territory
*
@@ -221,6 +222,7 @@ class PostCode extends AbstractValidator
'YT' => '976\d{2}',
'VN' => '\d{6}',
];
+ // @codingStandardsIgnoreEnd
/**
* Constructor for the PostCode validator
@@ -232,7 +234,7 @@ class PostCode extends AbstractValidator
*/
public function __construct($options = [])
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new I18nException\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -333,7 +335,7 @@ public function setService($service)
*/
public function isValid($value)
{
- if (!is_string($value) && !is_int($value)) {
+ if (! is_string($value) && ! is_int($value)) {
$this->error(self::INVALID);
return false;
}
@@ -343,7 +345,7 @@ public function isValid($value)
$service = $this->getService();
$locale = $this->getLocale();
$format = $this->getFormat();
- if ((null === $format || '' === $format) && !empty($locale)) {
+ if ((null === $format || '' === $format) && ! empty($locale)) {
$region = Locale::getRegion($locale);
if ('' === $region) {
throw new Exception\InvalidArgumentException("Locale must contain a region");
@@ -363,8 +365,8 @@ public function isValid($value)
$format .= '$/';
}
- if (!empty($service)) {
- if (!is_callable($service)) {
+ if (! empty($service)) {
+ if (! is_callable($service)) {
throw new Exception\InvalidArgumentException('Invalid callback given');
}
@@ -374,7 +376,7 @@ public function isValid($value)
'format' => $format,
'locale' => $locale,
]);
- if (!$callback->isValid($value)) {
+ if (! $callback->isValid($value)) {
$this->error(self::SERVICE, $value);
return false;
}
@@ -384,7 +386,7 @@ public function isValid($value)
}
}
- if (!preg_match($format, $value)) {
+ if (! preg_match($format, $value)) {
$this->error(self::NO_MATCH);
return false;
}
diff --git a/src/View/Helper/CurrencyFormat.php b/src/View/Helper/CurrencyFormat.php
index 0ffe1de6..4aa7e3b5 100644
--- a/src/View/Helper/CurrencyFormat.php
+++ b/src/View/Helper/CurrencyFormat.php
@@ -59,7 +59,7 @@ class CurrencyFormat extends AbstractHelper
*/
public function __construct()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -119,7 +119,7 @@ protected function formatCurrency(
) {
$formatterId = md5($locale);
- if (!isset($this->formatters[$formatterId])) {
+ if (! isset($this->formatters[$formatterId])) {
$this->formatters[$formatterId] = new NumberFormatter(
$locale,
NumberFormatter::CURRENCY
diff --git a/src/View/Helper/DateFormat.php b/src/View/Helper/DateFormat.php
index 5557da0d..23c76884 100644
--- a/src/View/Helper/DateFormat.php
+++ b/src/View/Helper/DateFormat.php
@@ -46,7 +46,7 @@ class DateFormat extends AbstractHelper
*/
public function __construct()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -78,7 +78,7 @@ public function __invoke(
$timezone = $this->getTimezone();
$formatterId = md5($dateType . "\0" . $timeType . "\0" . $locale ."\0" . $pattern);
- if (!isset($this->formatters[$formatterId])) {
+ if (! isset($this->formatters[$formatterId])) {
$this->formatters[$formatterId] = new IntlDateFormatter(
$locale,
$dateType,
@@ -145,7 +145,7 @@ public function setTimezone($timezone)
*/
public function getTimezone()
{
- if (!$this->timezone) {
+ if (! $this->timezone) {
return date_default_timezone_get();
}
diff --git a/src/View/Helper/NumberFormat.php b/src/View/Helper/NumberFormat.php
index d1a0a0a7..0cb97e92 100644
--- a/src/View/Helper/NumberFormat.php
+++ b/src/View/Helper/NumberFormat.php
@@ -67,7 +67,7 @@ class NumberFormat extends AbstractHelper
*/
public function __construct()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -103,10 +103,10 @@ public function __invoke(
if (null === $formatType) {
$formatType = $this->getFormatType();
}
- if (!is_int($decimals) || $decimals < 0) {
+ if (! is_int($decimals) || $decimals < 0) {
$decimals = $this->getDecimals();
}
- if (!is_array($textAttributes)) {
+ if (! is_array($textAttributes)) {
$textAttributes = $this->getTextAttributes();
}
diff --git a/src/View/Helper/Plural.php b/src/View/Helper/Plural.php
index 3bb31ba7..e7d73ceb 100644
--- a/src/View/Helper/Plural.php
+++ b/src/View/Helper/Plural.php
@@ -39,7 +39,7 @@ class Plural extends AbstractHelper
*/
public function __construct()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
throw new Exception\ExtensionNotLoadedException(sprintf(
'%s component requires the intl PHP extension',
__NAMESPACE__
@@ -64,7 +64,7 @@ public function __invoke($strings, $number)
));
}
- if (!is_array($strings)) {
+ if (! is_array($strings)) {
$strings = (array) $strings;
}
@@ -81,7 +81,7 @@ public function __invoke($strings, $number)
*/
public function setPluralRule($pluralRule)
{
- if (!$pluralRule instanceof PluralRule) {
+ if (! $pluralRule instanceof PluralRule) {
$pluralRule = PluralRule::fromString($pluralRule);
}
diff --git a/test/Filter/AlnumTest.php b/test/Filter/AlnumTest.php
index f082c67a..6190ba19 100644
--- a/test/Filter/AlnumTest.php
+++ b/test/Filter/AlnumTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\Filter;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Filter\Alnum as AlnumFilter;
use Locale;
/**
* @group Zend_Filter
*/
-class AlnumTest extends \PHPUnit_Framework_TestCase
+class AlnumTest extends TestCase
{
/**
* AlnumFilter object
@@ -52,7 +53,7 @@ class AlnumTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -71,7 +72,7 @@ public function setUp()
*/
public function testBasic()
{
- if (!static::$unicodeEnabled) {
+ if (! static::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z match
$valuesExpected = [
'abc123' => 'abc123',
@@ -123,7 +124,7 @@ public function testAllowWhiteSpace()
{
$this->filter->setAllowWhiteSpace(true);
- if (!static::$unicodeEnabled) {
+ if (! static::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z match
$valuesExpected = [
'abc123' => 'abc123',
@@ -192,6 +193,6 @@ public function testReturnUnfiltered($input)
{
$filter = new AlnumFilter();
- $this->assertEquals($input, $filter->filter($input));
+ $this->assertEquals($input, $filter->filter($input));
}
}
diff --git a/test/Filter/AlphaTest.php b/test/Filter/AlphaTest.php
index 3038e8d4..dd90c7bc 100644
--- a/test/Filter/AlphaTest.php
+++ b/test/Filter/AlphaTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\Filter;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Filter\Alpha as AlphaFilter;
use Locale;
/**
* @group Zend_Filter
*/
-class AlphaTest extends \PHPUnit_Framework_TestCase
+class AlphaTest extends TestCase
{
/**
* AlphaFilter object
@@ -52,7 +53,7 @@ class AlphaTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -71,7 +72,7 @@ public function setUp()
*/
public function testBasic()
{
- if (!self::$unicodeEnabled) {
+ if (! self::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z match
$valuesExpected = [
'abc123' => 'abc',
@@ -125,7 +126,7 @@ public function testAllowWhiteSpace()
{
$this->filter->setAllowWhiteSpace(true);
- if (!self::$unicodeEnabled) {
+ if (! self::$unicodeEnabled) {
// POSIX named classes are not supported, use alternative a-zA-Z match
$valuesExpected = [
'abc123' => 'abc',
@@ -196,6 +197,6 @@ public function testReturnUnfiltered($input)
{
$filter = new AlphaFilter();
- $this->assertEquals($input, $filter->filter($input));
+ $this->assertEquals($input, $filter->filter($input));
}
}
diff --git a/test/Filter/NumberFormatTest.php b/test/Filter/NumberFormatTest.php
index af405e9e..150532ac 100644
--- a/test/Filter/NumberFormatTest.php
+++ b/test/Filter/NumberFormatTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Filter;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Filter\NumberFormat as NumberFormatFilter;
use NumberFormatter;
@@ -17,7 +17,7 @@ class NumberFormatTest extends TestCase
{
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
}
@@ -72,7 +72,7 @@ public function testFormattedToNumber($locale, $style, $type, $value, $expected)
public function numberToFormattedProvider()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
$this->markTestSkipped('ext/intl not enabled');
} else {
@@ -107,7 +107,7 @@ public function numberToFormattedProvider()
public function formattedToNumberProvider()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
$this->markTestSkipped('ext/intl not enabled');
} else {
diff --git a/test/Filter/NumberParseTest.php b/test/Filter/NumberParseTest.php
index 40a66475..c421a3c2 100644
--- a/test/Filter/NumberParseTest.php
+++ b/test/Filter/NumberParseTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Filter;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Filter\NumberParse as NumberParseFilter;
use NumberFormatter;
@@ -17,7 +17,7 @@ class NumberParseTest extends TestCase
{
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
}
diff --git a/test/ModuleTest.php b/test/ModuleTest.php
index 54fb151b..0f84962e 100644
--- a/test/ModuleTest.php
+++ b/test/ModuleTest.php
@@ -8,7 +8,7 @@
namespace ZendTest\I18n;
use Interop\Container\ContainerInterface;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Module;
class ModuleTest extends TestCase
diff --git a/test/Translator/Loader/GettextTest.php b/test/Translator/Loader/GettextTest.php
index 96ae310b..fa505220 100644
--- a/test/Translator/Loader/GettextTest.php
+++ b/test/Translator/Loader/GettextTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator\Loader;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Locale;
use Zend\I18n\Translator\Loader\Gettext as GettextLoader;
@@ -21,7 +21,7 @@ class GettextTest extends TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -45,15 +45,16 @@ public function tearDown()
public function testLoaderFailsToLoadMissingFile()
{
$loader = new GettextLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Could not find or open file');
$loader->load('en_EN', 'missing');
}
public function testLoaderFailsToLoadBadFile()
{
$loader = new GettextLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'is not a valid gettext file');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('is not a valid gettext file');
$loader->load('en_EN', $this->testFilesDir . '/failed.mo');
}
diff --git a/test/Translator/Loader/IniTest.php b/test/Translator/Loader/IniTest.php
index d74692ed..e39d74d8 100644
--- a/test/Translator/Loader/IniTest.php
+++ b/test/Translator/Loader/IniTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator\Loader;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\Loader\Ini as IniLoader;
class IniTest extends TestCase
@@ -34,7 +34,8 @@ public function tearDown()
public function testLoaderFailsToLoadMissingFile()
{
$loader = new IniLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Could not find or open file');
$loader->load('en_EN', 'missing');
}
@@ -48,16 +49,16 @@ public function testLoaderLoadsEmptyFile()
public function testLoaderFailsToLoadNonArray()
{
$loader = new IniLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Each INI row must be an array with message and translation');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Each INI row must be an array with message and translation');
$loader->load('en_EN', $this->testFilesDir . '/failed.ini');
}
public function testLoaderFailsToLoadBadSyntax()
{
$loader = new IniLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Each INI row must be an array with message and translation');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Each INI row must be an array with message and translation');
$loader->load('en_EN', $this->testFilesDir . '/failed_syntax.ini');
}
diff --git a/test/Translator/Loader/PhpArrayTest.php b/test/Translator/Loader/PhpArrayTest.php
index f905f997..52cbd545 100644
--- a/test/Translator/Loader/PhpArrayTest.php
+++ b/test/Translator/Loader/PhpArrayTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator\Loader;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Locale;
use Zend\I18n\Translator\Loader\PhpArray as PhpArrayLoader;
@@ -21,7 +21,7 @@ class PhpArrayTest extends TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -45,15 +45,16 @@ public function tearDown()
public function testLoaderFailsToLoadMissingFile()
{
$loader = new PhpArrayLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException', 'Could not find or open file');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Could not find or open file');
$loader->load('en_EN', 'missing');
}
public function testLoaderFailsToLoadNonArray()
{
$loader = new PhpArrayLoader();
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Expected an array, but received');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected an array, but received');
$loader->load('en_EN', $this->testFilesDir . '/failed.php');
}
diff --git a/test/Translator/Loader/PhpMemoryArrayTest.php b/test/Translator/Loader/PhpMemoryArrayTest.php
index f18594b9..afe241b3 100644
--- a/test/Translator/Loader/PhpMemoryArrayTest.php
+++ b/test/Translator/Loader/PhpMemoryArrayTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator\Loader;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Locale;
use Zend\I18n\Translator\Loader\PhpMemoryArray as PhpMemoryArrayLoader;
@@ -21,7 +21,7 @@ class PhpMemoryArrayTest extends TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -40,24 +40,24 @@ public function tearDown()
public function testLoaderFailsToLoadNonArray()
{
$loader = new PhpMemoryArrayLoader('foo');
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Expected an array, but received');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected an array, but received');
$loader->load('en_US', 'default');
}
public function testLoaderFailsToLoadMissingTextDomain()
{
$loader = new PhpMemoryArrayLoader([]);
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Expected textdomain "default" to be an array, but it is not set');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected textdomain "default" to be an array, but it is not set');
$loader->load('en_US', 'default');
}
public function testLoaderFailsToLoadNonArrayLocale()
{
$loader = new PhpMemoryArrayLoader(['default' => []]);
- $this->setExpectedException('Zend\I18n\Exception\InvalidArgumentException',
- 'Expected locale "en_US" to be an array, but it is not set');
+ $this->expectException('Zend\I18n\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Expected locale "en_US" to be an array, but it is not set');
$loader->load('en_US', 'default');
}
diff --git a/test/Translator/LoaderPluginManagerCompatibilityTest.php b/test/Translator/LoaderPluginManagerCompatibilityTest.php
index d3310fb4..592bbd92 100644
--- a/test/Translator/LoaderPluginManagerCompatibilityTest.php
+++ b/test/Translator/LoaderPluginManagerCompatibilityTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Exception\RuntimeException;
use Zend\I18n\Translator\LoaderPluginManager;
use Zend\ServiceManager\ServiceManager;
diff --git a/test/Translator/LoaderPluginManagerFactoryTest.php b/test/Translator/LoaderPluginManagerFactoryTest.php
index bc4b51a9..27eed370 100644
--- a/test/Translator/LoaderPluginManagerFactoryTest.php
+++ b/test/Translator/LoaderPluginManagerFactoryTest.php
@@ -8,7 +8,7 @@
namespace ZendTest\I18n\Translator;
use Interop\Container\ContainerInterface;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\LoaderPluginManager;
use Zend\I18n\Translator\LoaderPluginManagerFactory;
use Zend\I18n\Translator\Loader\FileLoaderInterface;
diff --git a/test/Translator/Plural/RuleTest.php b/test/Translator/Plural/RuleTest.php
index 339cb6ec..03990c58 100644
--- a/test/Translator/Plural/RuleTest.php
+++ b/test/Translator/Plural/RuleTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator\Plural;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\Plural\Rule;
class RuleTest extends TestCase
diff --git a/test/Translator/TextDomainTest.php b/test/Translator/TextDomainTest.php
index d831a070..7ae7578b 100644
--- a/test/Translator/TextDomainTest.php
+++ b/test/Translator/TextDomainTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\TextDomain;
use Zend\I18n\Translator\Plural\Rule as PluralRule;
@@ -56,7 +56,8 @@ public function testMerging()
public function testMergingIncompatibleTextDomains()
{
- $this->setExpectedException('Zend\I18n\Exception\RuntimeException', 'is not compatible');
+ $this->expectException('Zend\I18n\Exception\RuntimeException');
+ $this->expectExceptionMessage('is not compatible');
$domainA = new TextDomain();
$domainB = new TextDomain();
diff --git a/test/Translator/TranslatorAwareTraitTest.php b/test/Translator/TranslatorAwareTraitTest.php
index ae857b07..7c52accf 100644
--- a/test/Translator/TranslatorAwareTraitTest.php
+++ b/test/Translator/TranslatorAwareTraitTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\Translator;
/**
diff --git a/test/Translator/TranslatorServiceFactoryTest.php b/test/Translator/TranslatorServiceFactoryTest.php
index 69260a5b..167cc0c4 100644
--- a/test/Translator/TranslatorServiceFactoryTest.php
+++ b/test/Translator/TranslatorServiceFactoryTest.php
@@ -10,7 +10,7 @@
namespace ZendTest\I18n\Translator;
use Interop\Container\ContainerInterface;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Translator\TranslatorServiceFactory;
class TranslatorServiceFactoryTest extends TestCase
@@ -18,7 +18,7 @@ class TranslatorServiceFactoryTest extends TestCase
public function testCreateServiceWithNoTranslatorKeyDefined()
{
$slContents = [['config', []]];
- $serviceLocator = $this->getMock(ContainerInterface::class);
+ $serviceLocator = $this->createMock(ContainerInterface::class);
$serviceLocator->expects($this->once())
->method('get')
->will($this->returnValueMap($slContents));
diff --git a/test/Translator/TranslatorTest.php b/test/Translator/TranslatorTest.php
index 2d905ffc..dd7b8fc3 100644
--- a/test/Translator/TranslatorTest.php
+++ b/test/Translator/TranslatorTest.php
@@ -9,7 +9,7 @@
namespace ZendTest\I18n\Translator;
-use PHPUnit_Framework_TestCase as TestCase;
+use PHPUnit\Framework\TestCase;
use Locale;
use Zend\EventManager\EventInterface;
use Zend\I18n\Translator\Translator;
@@ -36,7 +36,7 @@ class TranslatorTest extends TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -299,9 +299,12 @@ public function testMissingTranslationEvent()
$actualEvent = null;
$this->translator->enableEventManager();
- $this->translator->getEventManager()->attach(Translator::EVENT_MISSING_TRANSLATION, function (EventInterface $event) use (&$actualEvent) {
- $actualEvent = $event;
- });
+ $this->translator->getEventManager()->attach(
+ Translator::EVENT_MISSING_TRANSLATION,
+ function (EventInterface $event) use (&$actualEvent) {
+ $actualEvent = $event;
+ }
+ );
$this->translator->translate('foo', 'bar', 'baz');
diff --git a/test/Translator/_files/phpmemoryarray/translation_empty.php b/test/Translator/_files/phpmemoryarray/translation_empty.php
index f0193b12..52dda024 100644
--- a/test/Translator/_files/phpmemoryarray/translation_empty.php
+++ b/test/Translator/_files/phpmemoryarray/translation_empty.php
@@ -7,9 +7,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- 'default' => array(
- 'en_US' => array(
- ),
- ),
-);
+return [
+ 'default' => [
+ 'en_US' => [
+ ],
+ ],
+];
diff --git a/test/Translator/_files/phpmemoryarray/translation_en.php b/test/Translator/_files/phpmemoryarray/translation_en.php
index a9aa2a1d..3e83b51e 100644
--- a/test/Translator/_files/phpmemoryarray/translation_en.php
+++ b/test/Translator/_files/phpmemoryarray/translation_en.php
@@ -7,23 +7,23 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- 'default' => array(
- 'en_US' => array(
- '' => array(
+return [
+ 'default' => [
+ 'en_US' => [
+ '' => [
'plural_forms' => 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);'
- ),
+ ],
'Message 1' => 'Message 1 (en)',
'Message 2' => 'Message 2 (en)',
'Message 3' => 'Message 3 (en)',
'Message 4' => 'Message 4 (en)',
- 'Message 5' => array(
+ 'Message 5' => [
0 => 'Message 5 (en) Plural 0',
1 => 'Message 5 (en) Plural 1',
2 => 'Message 5 (en) Plural 2'
- ),
+ ],
'Cooking furniture' => 'Küchen Möbel (en)',
'Küchen Möbel' => 'Cooking furniture (en)',
- ),
- ),
-);
+ ],
+ ],
+];
diff --git a/test/Translator/_files/testarray/translation-de_DE.php b/test/Translator/_files/testarray/translation-de_DE.php
index 13dd241a..e923bc5d 100644
--- a/test/Translator/_files/testarray/translation-de_DE.php
+++ b/test/Translator/_files/testarray/translation-de_DE.php
@@ -7,14 +7,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- '' => array(
+return [
+ '' => [
'plural_forms' => 'nplurals=2; plural=n!=1;'
- ),
+ ],
'Message 1' => 'Nachricht 1',
'Message 8' => 'Nachricht 8',
- 'Message 10' => array(
+ 'Message 10' => [
'Nachricht 10 - 0',
'Nachricht 10 - 1',
- ),
-);
+ ],
+];
diff --git a/test/Translator/_files/testarray/translation-en_US.php b/test/Translator/_files/testarray/translation-en_US.php
index 6602544c..2137067f 100644
--- a/test/Translator/_files/testarray/translation-en_US.php
+++ b/test/Translator/_files/testarray/translation-en_US.php
@@ -7,9 +7,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
+return [
'Message 1' => 'Message 1 (en)',
'Message 2' => 'Message 2 (en)',
'Message 3' => 'Message 3 (en)',
'Message 4' => 'Message 4 (en)',
-);
+];
diff --git a/test/Translator/_files/testarray/translation-more-de_DE-incompatible.php b/test/Translator/_files/testarray/translation-more-de_DE-incompatible.php
index 2048b162..b4a8c084 100644
--- a/test/Translator/_files/testarray/translation-more-de_DE-incompatible.php
+++ b/test/Translator/_files/testarray/translation-more-de_DE-incompatible.php
@@ -7,15 +7,15 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- '' => array(
+return [
+ '' => [
'plural_forms' => 'nplurals=3; plural=(n==0 ? 0 : (n == 1 ? 1 : 2));'
- ),
+ ],
'Message 2' => 'Nachricht 2',
'Message 9' => 'Nachricht 9',
- 'Message 11' => array(
+ 'Message 11' => [
'Nachricht 11 - 0',
'Nachricht 11 - 1',
'Nachricht 11 - 2',
- ),
-);
+ ],
+];
diff --git a/test/Translator/_files/testarray/translation-more-de_DE.php b/test/Translator/_files/testarray/translation-more-de_DE.php
index f72a9bbf..cb4dce72 100644
--- a/test/Translator/_files/testarray/translation-more-de_DE.php
+++ b/test/Translator/_files/testarray/translation-more-de_DE.php
@@ -7,14 +7,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- '' => array(
+return [
+ '' => [
'plural_forms' => 'nplurals=2; plural=n!=1;'
- ),
+ ],
'Message 2' => 'Nachricht 2',
'Message 9' => 'Nachricht 9',
- 'Message 11' => array(
+ 'Message 11' => [
'Nachricht 11 - 0',
'Nachricht 11 - 1',
- ),
-);
+ ],
+];
diff --git a/test/Translator/_files/testarray/translation-more-en_US.php b/test/Translator/_files/testarray/translation-more-en_US.php
index 7626e670..087956a7 100644
--- a/test/Translator/_files/testarray/translation-more-en_US.php
+++ b/test/Translator/_files/testarray/translation-more-en_US.php
@@ -7,9 +7,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
+return [
'Message 5' => 'Message 5 (en)',
'Message 6' => 'Message 6 (en)',
'Message 7' => 'Message 7 (en)',
'Message 8' => 'Message 8 (en)',
-);
+];
diff --git a/test/Translator/_files/testarray/translation-noplural-ja_JP.php b/test/Translator/_files/testarray/translation-noplural-ja_JP.php
index 77fb99a0..d7e019bc 100644
--- a/test/Translator/_files/testarray/translation-noplural-ja_JP.php
+++ b/test/Translator/_files/testarray/translation-noplural-ja_JP.php
@@ -7,9 +7,9 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- '' => array(
+return [
+ '' => [
'plural_forms' => 'nplurals=1; plural=0;'
- ),
+ ],
'Message 9' => 'Message 9 (ja)',
-);
+];
diff --git a/test/Translator/_files/translation_empty.php b/test/Translator/_files/translation_empty.php
index 88af131a..735ebbea 100644
--- a/test/Translator/_files/translation_empty.php
+++ b/test/Translator/_files/translation_empty.php
@@ -7,4 +7,4 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array();
+return [];
diff --git a/test/Translator/_files/translation_en.php b/test/Translator/_files/translation_en.php
index 54ff6e5e..c0401a78 100644
--- a/test/Translator/_files/translation_en.php
+++ b/test/Translator/_files/translation_en.php
@@ -7,19 +7,19 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-return array(
- '' => array(
+return [
+ '' => [
'plural_forms' => 'nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);'
- ),
+ ],
'Message 1' => 'Message 1 (en)',
'Message 2' => 'Message 2 (en)',
'Message 3' => 'Message 3 (en)',
'Message 4' => 'Message 4 (en)',
- 'Message 5' => array(
+ 'Message 5' => [
0 => 'Message 5 (en) Plural 0',
1 => 'Message 5 (en) Plural 1',
2 => 'Message 5 (en) Plural 2'
- ),
+ ],
'Cooking furniture' => 'Küchen Möbel (en)',
'Küchen Möbel' => 'Cooking furniture (en)',
-);
+];
diff --git a/test/Validator/AlnumTest.php b/test/Validator/AlnumTest.php
index 81bbfffc..ab31a5f2 100644
--- a/test/Validator/AlnumTest.php
+++ b/test/Validator/AlnumTest.php
@@ -9,12 +9,13 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\Alnum as AlnumValidator;
/**
* @group Zend_Validator
*/
-class AlnumTest extends \PHPUnit_Framework_TestCase
+class AlnumTest extends TestCase
{
/**
* @var AlnumValidator
@@ -28,7 +29,7 @@ class AlnumTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/Validator/AlphaTest.php b/test/Validator/AlphaTest.php
index 07d2d997..586ef869 100644
--- a/test/Validator/AlphaTest.php
+++ b/test/Validator/AlphaTest.php
@@ -9,12 +9,13 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\Alpha as AlphaValidator;
/**
* @group Zend_Validator
*/
-class AlphaTest extends \PHPUnit_Framework_TestCase
+class AlphaTest extends TestCase
{
/**
* @var AlphaValidator
@@ -23,7 +24,7 @@ class AlphaTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/Validator/DateTimeTest.php b/test/Validator/DateTimeTest.php
index afcce675..4049a998 100644
--- a/test/Validator/DateTimeTest.php
+++ b/test/Validator/DateTimeTest.php
@@ -12,11 +12,10 @@
use DateTime;
use IntlDateFormatter;
use Locale;
-use PHPUnit_Framework_TestCase;
-use PHPUnit_Runner_Version;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\DateTime as DateTimeValidator;
-class DateTimeTest extends PHPUnit_Framework_TestCase
+class DateTimeTest extends TestCase
{
/**
* @var DateTimeValidator
@@ -35,7 +34,7 @@ class DateTimeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -84,14 +83,8 @@ public function testBasic($value, $expected, $options = [])
public function basicProvider()
{
- if (!extension_loaded('intl')) {
- if (version_compare(PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
- $this->markTestSkipped('ext/intl not enabled');
- } else {
- return [
- []
- ];
- }
+ if (! extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
}
$trueArray = [];
@@ -196,7 +189,7 @@ public function testOptionPatternOmitted()
*/
public function testOptionPattern()
{
- $this->validator->setOptions(['pattern'=>'hh:mm']);
+ $this->validator->setOptions(['pattern' => 'hh:mm']);
$this->assertTrue($this->validator->isValid('02:00'));
$this->assertEquals('hh:mm', $this->validator->getPattern());
diff --git a/test/Validator/FloatTest.php b/test/Validator/FloatTest.php
index dee168d8..42d8bf1e 100644
--- a/test/Validator/FloatTest.php
+++ b/test/Validator/FloatTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\Float as FloatValidator;
use Locale;
/**
* @group Zend_Validator
*/
-class FloatTest extends \PHPUnit_Framework_TestCase
+class FloatTest extends TestCase
{
/**
* @var FloatValidator
@@ -33,7 +34,7 @@ public function setUp()
$this->markTestSkipped('Cannot test Float validator under PHP 7; reserved keyword');
}
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/Validator/IntTest.php b/test/Validator/IntTest.php
index 7e2c7aad..f7d5f9a4 100644
--- a/test/Validator/IntTest.php
+++ b/test/Validator/IntTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\Int as IntValidator;
use Locale;
/**
* @group Zend_Validator
*/
-class IntTest extends \PHPUnit_Framework_TestCase
+class IntTest extends TestCase
{
/**
* @var Int
@@ -33,7 +34,7 @@ public function setUp()
$this->markTestSkipped('Cannot test Int validator under PHP 7; reserved keyword');
}
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/Validator/IsFloatTest.php b/test/Validator/IsFloatTest.php
index 86735274..a436308f 100644
--- a/test/Validator/IsFloatTest.php
+++ b/test/Validator/IsFloatTest.php
@@ -9,6 +9,7 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\IsFloat as IsFloatValidator;
use Locale;
use NumberFormatter;
@@ -16,7 +17,7 @@
/**
* @group Zend_Validator
*/
-class IsFloatTest extends \PHPUnit_Framework_TestCase
+class IsFloatTest extends TestCase
{
/**
* @var IsFloatValidator
@@ -30,7 +31,7 @@ class IsFloatTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -46,7 +47,7 @@ public function tearDown()
}
/**
- * Test float and interger type variables. Includes decimal and scientific notation NumberFormatter-formatted
+ * Test float and integer type variables. Includes decimal and scientific notation NumberFormatter-formatted
* versions. Should return true for all locales.
*
* @param string $value that will be tested
diff --git a/test/Validator/IsIntTest.php b/test/Validator/IsIntTest.php
index 6ddd8c62..332d0699 100644
--- a/test/Validator/IsIntTest.php
+++ b/test/Validator/IsIntTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\IsInt as IsIntValidator;
use Locale;
/**
* @group Zend_Validator
*/
-class IsIntTest extends \PHPUnit_Framework_TestCase
+class IsIntTest extends TestCase
{
/**
* @var Int
@@ -29,7 +30,7 @@ class IsIntTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/Validator/PhoneNumberTest.php b/test/Validator/PhoneNumberTest.php
index ff19b565..56fc060f 100644
--- a/test/Validator/PhoneNumberTest.php
+++ b/test/Validator/PhoneNumberTest.php
@@ -10,9 +10,10 @@
namespace ZendTest\I18n\Validator;
use Locale;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\PhoneNumber;
-class PhoneNumberTest extends \PHPUnit_Framework_TestCase
+class PhoneNumberTest extends TestCase
{
/**
* @var PhoneNumber
@@ -3182,7 +3183,8 @@ public function testCountryIsCaseInsensitive()
public function testInvalidTypes($country, $code, $patterns)
{
$this->validator->setCountry($country);
- if (!isset($patterns['invalid'])) {
+ if (! isset($patterns['invalid'])) {
+ $this->addToAssertionCount(1);
return;
}
foreach ($patterns['invalid'] as $type => $values) {
diff --git a/test/Validator/PostCodeTest.php b/test/Validator/PostCodeTest.php
index 38cf7769..1b306600 100644
--- a/test/Validator/PostCodeTest.php
+++ b/test/Validator/PostCodeTest.php
@@ -9,12 +9,13 @@
namespace ZendTest\I18n\Validator;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\Validator\PostCode as PostCodeValidator;
/**
* @group Zend_Validator
*/
-class PostCodeTest extends \PHPUnit_Framework_TestCase
+class PostCodeTest extends TestCase
{
/**
* @var PostCode
@@ -28,7 +29,7 @@ class PostCodeTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -104,7 +105,8 @@ public function testGetMessages()
*/
public function testSettingLocalesWithoutRegion()
{
- $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'Locale must contain a region');
+ $this->expectException('Zend\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('Locale must contain a region');
$this->validator->setLocale('de')->isValid('1000');
}
@@ -113,7 +115,8 @@ public function testSettingLocalesWithoutRegion()
*/
public function testSettingLocalesWithoutPostalCodes()
{
- $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'A postcode-format string has to be given for validation');
+ $this->expectException('Zend\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('A postcode-format string has to be given for validation');
$this->validator->setLocale('gez_ER')->isValid('1000');
}
@@ -136,13 +139,15 @@ public function testSetGetFormat()
public function testSetGetFormatThrowsExceptionOnNullFormat()
{
- $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'A postcode-format string has to be given');
+ $this->expectException('Zend\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('A postcode-format string has to be given');
$this->validator->setLocale(null)->setFormat(null)->isValid('1000');
}
public function testSetGetFormatThrowsExceptionOnEmptyFormat()
{
- $this->setExpectedException('Zend\Validator\Exception\InvalidArgumentException', 'A postcode-format string has to be given');
+ $this->expectException('Zend\Validator\Exception\InvalidArgumentException');
+ $this->expectExceptionMessage('A postcode-format string has to be given');
$this->validator->setLocale(null)->setFormat('')->isValid('1000');
}
@@ -233,7 +238,7 @@ public function testNoPostCodes()
$validator->setLocale('en_NO');
$this->assertTrue($validator->isValid('0301')); // OSLO
- $this->assertTrue($validator->isValid('9910')); // BJ�RNEVATN
+ $this->assertTrue($validator->isValid('9910')); // BJØRNEVATN
$this->assertFalse($validator->isValid('0000')); // Postal code 0000
}
}
diff --git a/test/View/Helper/CurrencyFormatTest.php b/test/View/Helper/CurrencyFormatTest.php
index af7c1c62..04678e3f 100644
--- a/test/View/Helper/CurrencyFormatTest.php
+++ b/test/View/Helper/CurrencyFormatTest.php
@@ -10,13 +10,14 @@
namespace ZendTest\I18n\View\Helper;
use Locale;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\CurrencyFormat as CurrencyFormatHelper;
/**
* @group Zend_View
* @group Zend_View_Helper
*/
-class CurrencyFormatTest extends \PHPUnit_Framework_TestCase
+class CurrencyFormatTest extends TestCase
{
/**
* @var CurrencyFormatHelper
@@ -31,7 +32,7 @@ class CurrencyFormatTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/View/Helper/DateFormatTest.php b/test/View/Helper/DateFormatTest.php
index 559f657a..ea0f7f27 100644
--- a/test/View/Helper/DateFormatTest.php
+++ b/test/View/Helper/DateFormatTest.php
@@ -12,6 +12,7 @@
use DateTime;
use Locale;
use IntlDateFormatter;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\DateFormat as DateFormatHelper;
/**
@@ -20,7 +21,7 @@
* @group Zend_View
* @group Zend_View_Helper
*/
-class DateFormatTest extends \PHPUnit_Framework_TestCase
+class DateFormatTest extends TestCase
{
/**
* @var DateFormatHelper
@@ -42,7 +43,7 @@ public function setUp()
);
}
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -62,7 +63,7 @@ public function tearDown()
public function dateTestsDataProvider()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
$this->markTestSkipped('ext/intl not enabled');
} else {
@@ -162,7 +163,7 @@ public function dateTestsDataProvider()
public function dateTestsDataProviderWithPattern()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
$this->markTestSkipped('ext/intl not enabled');
} else {
diff --git a/test/View/Helper/NumberFormatTest.php b/test/View/Helper/NumberFormatTest.php
index 9b282dd1..db7e0995 100644
--- a/test/View/Helper/NumberFormatTest.php
+++ b/test/View/Helper/NumberFormatTest.php
@@ -11,6 +11,7 @@
use Locale;
use NumberFormatter;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\NumberFormat as NumberFormatHelper;
/**
@@ -19,7 +20,7 @@
* @group Zend_View
* @group Zend_View_Helper
*/
-class NumberFormatTest extends \PHPUnit_Framework_TestCase
+class NumberFormatTest extends TestCase
{
/**
* @var NumberFormatHelper
@@ -34,7 +35,7 @@ class NumberFormatTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
@@ -54,7 +55,7 @@ public function tearDown()
public function currencyTestsDataProvider()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
if (version_compare(\PHPUnit_Runner_Version::id(), '3.8.0-dev') === 1) {
$this->markTestSkipped('ext/intl not enabled');
} else {
diff --git a/test/View/Helper/PluralTest.php b/test/View/Helper/PluralTest.php
index 281b6a28..8b0d8f9c 100644
--- a/test/View/Helper/PluralTest.php
+++ b/test/View/Helper/PluralTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\View\Helper;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\Plural as PluralHelper;
/**
* @group Zend_View
* @group Zend_View_Helper
*/
-class PluralTest extends \PHPUnit_Framework_TestCase
+class PluralTest extends TestCase
{
/**
* @var PluralHelper
@@ -29,7 +30,7 @@ class PluralTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
- if (!extension_loaded('intl')) {
+ if (! extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}
diff --git a/test/View/Helper/TranslatePluralTest.php b/test/View/Helper/TranslatePluralTest.php
index 865f81d2..3e77eaf7 100644
--- a/test/View/Helper/TranslatePluralTest.php
+++ b/test/View/Helper/TranslatePluralTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\View\Helper;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\TranslatePlural as TranslatePluralHelper;
/**
* @group Zend_View
* @group Zend_View_Helper
*/
-class TranslatePluralTest extends \PHPUnit_Framework_TestCase
+class TranslatePluralTest extends TestCase
{
/**
* @var TranslatePluralHelper
@@ -46,7 +47,7 @@ public function tearDown()
public function testInvokingWithoutTranslatorWillRaiseException()
{
- $this->setExpectedException('Zend\I18n\Exception\RuntimeException');
+ $this->expectException('Zend\I18n\Exception\RuntimeException');
$this->helper->__invoke('singular', 'plural', 1);
}
@@ -57,7 +58,7 @@ public function testDefaultInvokeArguments()
$numberInput = 1;
$expected = 'translated';
- $translatorMock = $this->getMock('Zend\I18n\Translator\Translator');
+ $translatorMock = $this->createMock('Zend\I18n\Translator\Translator');
$translatorMock->expects($this->once())
->method('translatePlural')
->with(
@@ -83,7 +84,7 @@ public function testCustomInvokeArguments()
$textDomain = 'textDomain';
$locale = 'en_US';
- $translatorMock = $this->getMock('Zend\I18n\Translator\Translator');
+ $translatorMock = $this->createMock('Zend\I18n\Translator\Translator');
$translatorMock->expects($this->once())
->method('translatePlural')
->with(
diff --git a/test/View/Helper/TranslateTest.php b/test/View/Helper/TranslateTest.php
index 24dad8d6..6b1d7a0b 100644
--- a/test/View/Helper/TranslateTest.php
+++ b/test/View/Helper/TranslateTest.php
@@ -9,13 +9,14 @@
namespace ZendTest\I18n\View\Helper;
+use PHPUnit\Framework\TestCase;
use Zend\I18n\View\Helper\Translate as TranslateHelper;
/**
* @group Zend_View
* @group Zend_View_Helper
*/
-class TranslateTest extends \PHPUnit_Framework_TestCase
+class TranslateTest extends TestCase
{
/**
* @var TranslateHelper
@@ -46,7 +47,7 @@ public function tearDown()
public function testInvokingWithoutTranslatorWillRaiseException()
{
- $this->setExpectedException('Zend\I18n\Exception\RuntimeException');
+ $this->expectException('Zend\I18n\Exception\RuntimeException');
$this->helper->__invoke('message');
}
@@ -55,7 +56,7 @@ public function testDefaultInvokeArguments()
$input = 'input';
$expected = 'translated';
- $translatorMock = $this->getMock('Zend\I18n\Translator\Translator');
+ $translatorMock = $this->createMock('Zend\I18n\Translator\Translator');
$translatorMock->expects($this->once())
->method('translate')
->with($this->equalTo($input), $this->equalTo('default'), $this->equalTo(null))
@@ -73,7 +74,7 @@ public function testCustomInvokeArguments()
$textDomain = 'textDomain';
$locale = 'en_US';
- $translatorMock = $this->getMock('Zend\I18n\Translator\Translator');
+ $translatorMock = $this->createMock('Zend\I18n\Translator\Translator');
$translatorMock->expects($this->once())
->method('translate')
->with($this->equalTo($input), $this->equalTo($textDomain), $this->equalTo($locale))