From 2636f5e55b8a90dcf5e6d08e4410dd81d712f735 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 22 Nov 2014 22:47:18 +0700 Subject: [PATCH 1/4] updated test case to fit with set error self::NOT_FLOAT --- test/Validator/FloatTest.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/Validator/FloatTest.php b/test/Validator/FloatTest.php index 42a09dfa..824d8b18 100644 --- a/test/Validator/FloatTest.php +++ b/test/Validator/FloatTest.php @@ -222,24 +222,13 @@ public function testEqualsMessageTemplates() } /** - * @group ZF2-6647 - * @dataProvider notFloatProvider + * @group 6647 */ - public function testNotFloat($value) + public function testNotFloat() { - $this->assertFalse($this->validator->isValid($value)); + $this->assertFalse($this->validator->isValid('2.000.000,00')); $message = $this->validator->getMessages(); $this->assertContains('does not appear to be a float', $message['notFloat']); } - - public function notFloatProvider() - { - return array( - array( - 'hello', - 2.000,000 - ), - ); - } } From 59254dc17d1ba33f2baddecd1c13002713a51beb Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 27 Nov 2014 19:46:01 +0100 Subject: [PATCH 2/4] zendframework/zf2#6647 zendframework/zf2#6648 - minor CS fixes (spacing) --- src/Validator/Float.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Validator/Float.php b/src/Validator/Float.php index a2ded7fb..746ef33c 100644 --- a/src/Validator/Float.php +++ b/src/Validator/Float.php @@ -163,6 +163,7 @@ public function isValid($value) //We have seperators, and they are flipped. i.e. 2.000,000 for en-US if ($groupSeparatorPosition && $decSeparatorPosition && $groupSeparatorPosition > $decSeparatorPosition) { $this->error(self::NOT_FLOAT); + return false; } @@ -239,6 +240,7 @@ public function isValid($value) } $this->error(self::NOT_FLOAT); + return false; } } From 6eee880330e2eb43f124c8a2dbeed94424749a7b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 27 Nov 2014 19:46:49 +0100 Subject: [PATCH 3/4] zendframework/zf2#6647 zendframework/zf2#6648 - adding `@group` annotation referencing the open pull request --- test/Validator/FloatTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Validator/FloatTest.php b/test/Validator/FloatTest.php index 824d8b18..bd9a9cec 100644 --- a/test/Validator/FloatTest.php +++ b/test/Validator/FloatTest.php @@ -223,6 +223,7 @@ public function testEqualsMessageTemplates() /** * @group 6647 + * @group 6648 */ public function testNotFloat() { From 6c1d3c14defd54aef45b2c2d256339526fb6ee88 Mon Sep 17 00:00:00 2001 From: Chad Gray Date: Sun, 13 Jul 2014 08:04:35 -0400 Subject: [PATCH 4/4] PHPCS fixes for Zend\I18n --- src/Exception/ExtensionNotLoadedException.php | 3 +-- src/Exception/InvalidArgumentException.php | 3 +-- src/Exception/OutOfBoundsException.php | 3 +-- src/Filter/NumberParse.php | 1 - src/Translator/Loader/PhpMemoryArray.php | 17 +++++++---------- src/Translator/Plural/Parser.php | 7 +++---- src/Translator/Plural/Rule.php | 7 +++---- src/Translator/Plural/Symbol.php | 8 ++------ src/Translator/Translator.php | 6 +++--- src/View/Helper/CurrencyFormat.php | 9 +++------ src/View/Helper/DateFormat.php | 4 ++-- src/View/Helper/NumberFormat.php | 6 +++--- 12 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/Exception/ExtensionNotLoadedException.php b/src/Exception/ExtensionNotLoadedException.php index 1b5f8b67..47c121a2 100644 --- a/src/Exception/ExtensionNotLoadedException.php +++ b/src/Exception/ExtensionNotLoadedException.php @@ -11,7 +11,6 @@ use DomainException; -class ExtensionNotLoadedException extends DomainException implements - ExceptionInterface +class ExtensionNotLoadedException extends DomainException implements ExceptionInterface { } diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 229ccc28..c6e2f82b 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -9,7 +9,6 @@ namespace Zend\I18n\Exception; -class InvalidArgumentException extends \InvalidArgumentException implements - ExceptionInterface +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/src/Exception/OutOfBoundsException.php b/src/Exception/OutOfBoundsException.php index fe696ffa..7f97cd37 100644 --- a/src/Exception/OutOfBoundsException.php +++ b/src/Exception/OutOfBoundsException.php @@ -9,7 +9,6 @@ namespace Zend\I18n\Exception; -class OutOfBoundsException extends \OutOfBoundsException implements - ExceptionInterface +class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface { } diff --git a/src/Filter/NumberParse.php b/src/Filter/NumberParse.php index 5f4775a0..0cfb2af2 100644 --- a/src/Filter/NumberParse.php +++ b/src/Filter/NumberParse.php @@ -131,7 +131,6 @@ public function getFormatter() return $this->formatter; } - /** * Defined by Zend\Filter\FilterInterface * diff --git a/src/Translator/Loader/PhpMemoryArray.php b/src/Translator/Loader/PhpMemoryArray.php index f38ab30c..cf04d912 100644 --- a/src/Translator/Loader/PhpMemoryArray.php +++ b/src/Translator/Loader/PhpMemoryArray.php @@ -40,23 +40,20 @@ public function __construct($messages) public function load($locale, $textDomain) { if (!is_array($this->messages)) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected an array, but received %s', - gettype($this->messages) - )); + throw new Exception\InvalidArgumentException( + sprintf('Expected an array, but received %s', gettype($this->messages)) + ); } if (!isset($this->messages[$textDomain])) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected textdomain "%s" to be an array, but it is not set', - $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])) { - throw new Exception\InvalidArgumentException(sprintf( - 'Expected locale "%s" to be an array, but it is not set', - $locale) + throw new Exception\InvalidArgumentException( + sprintf('Expected locale "%s" to be an array, but it is not set', $locale) ); } diff --git a/src/Translator/Plural/Parser.php b/src/Translator/Plural/Parser.php index d3e872e3..21dd98db 100644 --- a/src/Translator/Plural/Parser.php +++ b/src/Translator/Plural/Parser.php @@ -264,10 +264,9 @@ public function expression($rightBindingPower = 0) public function advance($id = null) { if ($id !== null && $this->currentToken->id !== $id) { - throw new Exception\ParseException(sprintf( - 'Expected token with id %s but received %s', - $id, $this->currentToken->id - )); + throw new Exception\ParseException( + sprintf('Expected token with id %s but received %s', $id, $this->currentToken->id) + ); } $this->currentToken = $this->getNextToken(); diff --git a/src/Translator/Plural/Rule.php b/src/Translator/Plural/Rule.php index 98e29cf6..03d12ebf 100644 --- a/src/Translator/Plural/Rule.php +++ b/src/Translator/Plural/Rule.php @@ -62,10 +62,9 @@ public function evaluate($number) $result = $this->evaluateAstPart($this->ast, abs((int) $number)); if ($result < 0 || $result >= $this->numPlurals) { - throw new Exception\RangeException(sprintf( - 'Calculated result %s is between 0 and %d', - $result, ($this->numPlurals - 1) - )); + throw new Exception\RangeException( + sprintf('Calculated result %s is between 0 and %d', $result, ($this->numPlurals - 1)) + ); } return $result; diff --git a/src/Translator/Plural/Symbol.php b/src/Translator/Plural/Symbol.php index 31d6606c..aae00a94 100644 --- a/src/Translator/Plural/Symbol.php +++ b/src/Translator/Plural/Symbol.php @@ -132,9 +132,7 @@ public function setLeftDenotationGetter(Closure $getter) public function getNullDenotation() { if ($this->nullDenotationGetter === null) { - throw new Exception\ParseException(sprintf( - 'Syntax error: %s', $this->id - )); + throw new Exception\ParseException(sprintf('Syntax error: %s', $this->id)); } /** @var callable $function */ @@ -152,9 +150,7 @@ public function getNullDenotation() public function getLeftDenotation($left) { if ($this->leftDenotationGetter === null) { - throw new Exception\ParseException(sprintf( - 'Unknown operator: %s', $this->id - )); + throw new Exception\ParseException(sprintf('Unknown operator: %s', $this->id)); } /** @var callable $function */ diff --git a/src/Translator/Translator.php b/src/Translator/Translator.php index 2bfb5422..c74f6cfe 100644 --- a/src/Translator/Translator.php +++ b/src/Translator/Translator.php @@ -408,9 +408,9 @@ public function translatePlural( ->evaluate($number); if (!isset($translation[$index])) { - throw new Exception\OutOfBoundsException(sprintf( - 'Provided index %d does not exist in plural array', $index - )); + throw new Exception\OutOfBoundsException( + sprintf('Provided index %d does not exist in plural array', $index) + ); } return $translation[$index]; diff --git a/src/View/Helper/CurrencyFormat.php b/src/View/Helper/CurrencyFormat.php index e2c7d83c..7ff1e922 100644 --- a/src/View/Helper/CurrencyFormat.php +++ b/src/View/Helper/CurrencyFormat.php @@ -81,8 +81,8 @@ public function __invoke( $number, $currencyCode = null, $showDecimals = null, - $locale = null, - $pattern = null + $locale = null, + $pattern = null ) { if (null === $locale) { $locale = $this->getLocale(); @@ -136,9 +136,7 @@ protected function formatCurrency( $this->formatters[$formatterId]->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); } - return $this->formatters[$formatterId]->formatCurrency( - $number, $currencyCode - ); + return $this->formatters[$formatterId]->formatCurrency($number, $currencyCode); } /** @@ -163,7 +161,6 @@ public function getCurrencyCode() return $this->currencyCode; } - /** * Set the currency pattern * diff --git a/src/View/Helper/DateFormat.php b/src/View/Helper/DateFormat.php index 0323435b..422ee534 100644 --- a/src/View/Helper/DateFormat.php +++ b/src/View/Helper/DateFormat.php @@ -68,8 +68,8 @@ public function __invoke( $date, $dateType = IntlDateFormatter::NONE, $timeType = IntlDateFormatter::NONE, - $locale = null, - $pattern = null + $locale = null, + $pattern = null ) { if ($locale === null) { $locale = $this->getLocale(); diff --git a/src/View/Helper/NumberFormat.php b/src/View/Helper/NumberFormat.php index eb6301a8..3f3a1b63 100644 --- a/src/View/Helper/NumberFormat.php +++ b/src/View/Helper/NumberFormat.php @@ -80,9 +80,9 @@ public function __construct() public function __invoke( $number, $formatStyle = null, - $formatType = null, - $locale = null, - $decimals = null + $formatType = null, + $locale = null, + $decimals = null ) { if (null === $locale) { $locale = $this->getLocale();