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

Commit

Permalink
Merge branch 'cs/zendframework/zendframework#6982-zend-validator-psr2…
Browse files Browse the repository at this point in the history
…-compliance'

Close zendframework/zendframework#6982
  • Loading branch information
Ocramius committed Dec 8, 2014
2 parents f8d12f3 + e209a59 commit ef9e46c
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 117 deletions.
9 changes: 3 additions & 6 deletions src/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,8 @@ public function getTranslatorTextDomain()
* @return void
* @throws Exception\InvalidArgumentException
*/
public static function setDefaultTranslator(
Translator\TranslatorInterface $translator = null, $textDomain = null
) {
public static function setDefaultTranslator(Translator\TranslatorInterface $translator = null, $textDomain = null)
{
static::$defaultTranslator = $translator;
if (null !== $textDomain) {
self::setDefaultTranslatorTextDomain($textDomain);
Expand Down Expand Up @@ -570,8 +569,6 @@ protected function translateMessage($messageKey, $message)
return $message;
}

return $translator->translate(
$message, $this->getTranslatorTextDomain()
);
return $translator->translate($message, $this->getTranslatorTextDomain());
}
}
149 changes: 75 additions & 74 deletions src/Barcode/Code128.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,52 @@ public function __construct()
{
$this->setLength(-1);
$this->setCharacters(array(
'A' => array(
0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'",
8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/',
16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7',
24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?',
32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G',
40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O',
48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W',
56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_',
64 =>0x00, 65 =>0x01, 66 =>0x02, 67 =>0x03, 68 =>0x04, 69 =>0x05, 70 =>0x06, 71 =>0x07,
72 =>0x08, 73 =>0x09, 74 =>0x0A, 75 =>0x0B, 76 =>0x0C, 77 =>0x0D, 78 =>0x0E, 79 =>0x0F,
80 =>0x10, 81 =>0x11, 82 =>0x12, 83 =>0x13, 84 =>0x14, 85 =>0x15, 86 =>0x16, 87 =>0x17,
88 =>0x18, 89 =>0x19, 90 =>0x1A, 91 =>0x1B, 92 =>0x1C, 93 =>0x1D, 94 =>0x1E, 95 =>0x1F,
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '',
104 => 'ˆ',105 => '',106 => 'Š'),
'B' => array(
0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'",
8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/',
16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7',
24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?',
32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G',
40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O',
48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W',
56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_',
64 => '`', 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g',
72 => 'h', 73 => 'i', 74 => 'j', 75 => 'k', 76 => 'l', 77 => 'm', 78 => 'n', 79 => 'o',
80 => 'p', 81 => 'q', 82 => 'r', 83 => 's', 84 => 't', 85 => 'u', 86 => 'v', 87 => 'w',
88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 =>0x7F,
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '',
104 => 'ˆ',105 => '',106 => 'Š'),
'C' => array(
0 => '00', 1 => '01', 2 => '02', 3 => '03', 4 => '04', 5 => '05', 6 => '06', 7 => '07',
8 => '08', 9 => '09', 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14', 15 => '15',
16 => '16', 17 => '17', 18 => '18', 19 => '19', 20 => '20', 21 => '21', 22 => '22', 23 => '23',
24 => '24', 25 => '25', 26 => '26', 27 => '27', 28 => '28', 29 => '29', 30 => '30', 31 => '31',
32 => '32', 33 => '33', 34 => '34', 35 => '35', 36 => '36', 37 => '37', 38 => '38', 39 => '39',
40 => '40', 41 => '41', 42 => '42', 43 => '43', 44 => '44', 45 => '45', 46 => '46', 47 => '47',
48 => '48', 49 => '49', 50 => '50', 51 => '51', 52 => '52', 53 => '53', 54 => '54', 55 => '55',
56 => '56', 57 => '57', 58 => '58', 59 => '59', 60 => '60', 61 => '61', 62 => '62', 63 => '63',
64 => '64', 65 => '65', 66 => '66', 67 => '67', 68 => '68', 69 => '69', 70 => '70', 71 => '71',
72 => '72', 73 => '73', 74 => '74', 75 => '75', 76 => '76', 77 => '77', 78 => '78', 79 => '79',
80 => '80', 81 => '81', 82 => '82', 83 => '83', 84 => '84', 85 => '85', 86 => '86', 87 => '87',
88 => '88', 89 => '89', 90 => '90', 91 => '91', 92 => '92', 93 => '93', 94 => '94', 95 => '95',
96 => '96', 97 => '97', 98 => '98', 99 => '99',100 => 'ä', 101 => 'à', 102 => 'å', 103 => '',
104 => 'ˆ', 105 => '', 106 => 'Š')));
'A' => array(
0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'",
8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/',
16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7',
24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?',
32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G',
40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O',
48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W',
56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_',
64 =>0x00, 65 =>0x01, 66 =>0x02, 67 =>0x03, 68 =>0x04, 69 =>0x05, 70 =>0x06, 71 =>0x07,
72 =>0x08, 73 =>0x09, 74 =>0x0A, 75 =>0x0B, 76 =>0x0C, 77 =>0x0D, 78 =>0x0E, 79 =>0x0F,
80 =>0x10, 81 =>0x11, 82 =>0x12, 83 =>0x13, 84 =>0x14, 85 =>0x15, 86 =>0x16, 87 =>0x17,
88 =>0x18, 89 =>0x19, 90 =>0x1A, 91 =>0x1B, 92 =>0x1C, 93 =>0x1D, 94 =>0x1E, 95 =>0x1F,
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '',
104 => 'ˆ',105 => '',106 => 'Š'),
'B' => array(
0 => ' ', 1 => '!', 2 => '"', 3 => '#', 4 => '$', 5 => '%', 6 => '&', 7 => "'",
8 => '(', 9 => ')', 10 => '*', 11 => '+', 12 => ',', 13 => '-', 14 => '.', 15 => '/',
16 => '0', 17 => '1', 18 => '2', 19 => '3', 20 => '4', 21 => '5', 22 => '6', 23 => '7',
24 => '8', 25 => '9', 26 => ':', 27 => ';', 28 => '<', 29 => '=', 30 => '>', 31 => '?',
32 => '@', 33 => 'A', 34 => 'B', 35 => 'C', 36 => 'D', 37 => 'E', 38 => 'F', 39 => 'G',
40 => 'H', 41 => 'I', 42 => 'J', 43 => 'K', 44 => 'L', 45 => 'M', 46 => 'N', 47 => 'O',
48 => 'P', 49 => 'Q', 50 => 'R', 51 => 'S', 52 => 'T', 53 => 'U', 54 => 'V', 55 => 'W',
56 => 'X', 57 => 'Y', 58 => 'Z', 59 => '[', 60 => '\\',61 => ']', 62 => '^', 63 => '_',
64 => '`', 65 => 'a', 66 => 'b', 67 => 'c', 68 => 'd', 69 => 'e', 70 => 'f', 71 => 'g',
72 => 'h', 73 => 'i', 74 => 'j', 75 => 'k', 76 => 'l', 77 => 'm', 78 => 'n', 79 => 'o',
80 => 'p', 81 => 'q', 82 => 'r', 83 => 's', 84 => 't', 85 => 'u', 86 => 'v', 87 => 'w',
88 => 'x', 89 => 'y', 90 => 'z', 91 => '{', 92 => '|', 93 => '}', 94 => '~', 95 =>0x7F,
96 => 'Ç', 97 => 'ü', 98 => 'é', 99 => 'â',100 => 'ä',101 => 'à',102 => 'å',103 => '',
104 => 'ˆ',105 => '',106 => 'Š'),
'C' => array(
0 => '00', 1 => '01', 2 => '02', 3 => '03', 4 => '04', 5 => '05', 6 => '06', 7 => '07',
8 => '08', 9 => '09', 10 => '10', 11 => '11', 12 => '12', 13 => '13', 14 => '14', 15 => '15',
16 => '16', 17 => '17', 18 => '18', 19 => '19', 20 => '20', 21 => '21', 22 => '22', 23 => '23',
24 => '24', 25 => '25', 26 => '26', 27 => '27', 28 => '28', 29 => '29', 30 => '30', 31 => '31',
32 => '32', 33 => '33', 34 => '34', 35 => '35', 36 => '36', 37 => '37', 38 => '38', 39 => '39',
40 => '40', 41 => '41', 42 => '42', 43 => '43', 44 => '44', 45 => '45', 46 => '46', 47 => '47',
48 => '48', 49 => '49', 50 => '50', 51 => '51', 52 => '52', 53 => '53', 54 => '54', 55 => '55',
56 => '56', 57 => '57', 58 => '58', 59 => '59', 60 => '60', 61 => '61', 62 => '62', 63 => '63',
64 => '64', 65 => '65', 66 => '66', 67 => '67', 68 => '68', 69 => '69', 70 => '70', 71 => '71',
72 => '72', 73 => '73', 74 => '74', 75 => '75', 76 => '76', 77 => '77', 78 => '78', 79 => '79',
80 => '80', 81 => '81', 82 => '82', 83 => '83', 84 => '84', 85 => '85', 86 => '86', 87 => '87',
88 => '88', 89 => '89', 90 => '90', 91 => '91', 92 => '92', 93 => '93', 94 => '94', 95 => '95',
96 => '96', 97 => '97', 98 => '98', 99 => '99',100 => 'ä', 101 => 'à', 102 => 'å', 103 => '',
104 => 'ˆ', 105 => '', 106 => 'Š')
));
$this->setChecksum('code128');
}

Expand Down Expand Up @@ -128,13 +129,13 @@ public function hasValidCharacters($value)

switch ($char) {
// Function definition
case 'Ç' :
case 'ü' :
case 'å' :
case 'Ç':
case 'ü':
case 'å':
break;

// Switch 1 char between A and B
case 'é' :
case 'é':
if ($set == 'A') {
$read = 'B';
} elseif ($set == 'B') {
Expand All @@ -143,32 +144,32 @@ public function hasValidCharacters($value)
break;

// Switch to C
case 'â' :
case 'â':
$set = 'C';
$read = 'C';
break;

// Switch to B
case 'ä' :
case 'ä':
$set = 'B';
$read = 'B';
break;

// Switch to A
case 'à' :
case 'à':
$set = 'A';
$read = 'A';
break;

// Doubled start character
case '' :
case 'ˆ' :
case '' :
case '':
case 'ˆ':
case '':
return false;
break;

// Chars after the stop character
case 'Š' :
case 'Š':
break 2;

default:
Expand Down Expand Up @@ -226,45 +227,45 @@ protected function code128($value)

switch ($char) {
// Function definition
case 'Ç' :
case 'ü' :
case 'å' :
case 'Ç':
case 'ü':
case 'å':
$sum += ($pos * $this->ord128($char, $set));
break;

case 'é' :
case 'é':
$sum += ($pos * $this->ord128($char, $set));
if ($set == 'A') {
$read = 'B';
} elseif ($set == 'B') {
$read = 'A';
}
if ($set == 'A') {
$read = 'B';
} elseif ($set == 'B') {
$read = 'A';
}
break;

// Switch to C
case 'â' :
case 'â':
$sum += ($pos * $this->ord128($char, $set));
$set = 'C';
$read = 'C';
break;

// Switch to B
case 'ä' :
case 'ä':
$sum += ($pos * $this->ord128($char, $set));
$set = 'B';
$read = 'B';
break;

// Switch to A
case 'à' :
case 'à':
$sum += ($pos * $this->ord128($char, $set));
$set = 'A';
$read = 'A';
break;

case '' :
case 'ˆ' :
case '' :
case '':
case 'ˆ':
case '':
return false;
break;

Expand Down Expand Up @@ -310,13 +311,13 @@ protected function getCodingSet($value)
{
$value = $this->getUtf8StringWrapper()->substr($value, 0, 1);
switch ($value) {
case '' :
case '':
return 'A';
break;
case 'ˆ' :
case 'ˆ':
return 'B';
break;
case '' :
case '':
return 'C';
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/DateStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ public function isValid($value)
if (in_array($intervalUnit, array('years', 'months', 'days'))) {
switch ($intervalUnit) {
case 'years':
if ( 0 == $diffParts['months'] && 0 == $diffParts['days']
&& 0 == $diffParts['hours'] && 0 == $diffParts['minutes']
if (0 == $diffParts['months'] && 0 == $diffParts['days']
&& 0 == $diffParts['hours'] && 0 == $diffParts['minutes']
&& 0 == $diffParts['seconds']
) {
if (($diffParts['years'] % $stepValue) === 0) {
Expand All @@ -245,7 +245,7 @@ public function isValid($value)
}
break;
case 'months':
if ( 0 == $diffParts['days'] && 0 == $diffParts['hours']
if (0 == $diffParts['days'] && 0 == $diffParts['hours']
&& 0 == $diffParts['minutes'] && 0 == $diffParts['seconds']
) {
$months = ($diffParts['years'] * 12) + $diffParts['months'];
Expand All @@ -255,7 +255,7 @@ public function isValid($value)
}
break;
case 'days':
if ( 0 == $diffParts['hours'] && 0 == $diffParts['minutes']
if (0 == $diffParts['hours'] && 0 == $diffParts['minutes']
&& 0 == $diffParts['seconds']
) {
$days = $timeDiff->format('%a'); // Total days
Expand Down
3 changes: 1 addition & 2 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Validator\Exception;

class BadMethodCallException extends \BadMethodCallException
implements ExceptionInterface
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
3 changes: 1 addition & 2 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Validator\Exception;

class InvalidArgumentException extends \InvalidArgumentException
implements ExceptionInterface
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
3 changes: 1 addition & 2 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Zend\Validator\Exception;

class RuntimeException extends \RuntimeException
implements ExceptionInterface
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}
10 changes: 6 additions & 4 deletions src/File/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ public function setMin($min)

$min = (int) $min;
if (($this->getMax() !== null) && ($min > $this->getMax())) {
throw new Exception\InvalidArgumentException("The minimum must be less than or equal to the maximum file count, but $min >"
. " {$this->getMax()}");
throw new Exception\InvalidArgumentException(
"The minimum must be less than or equal to the maximum file count, but $min > {$this->getMax()}"
);
}

$this->options['min'] = $min;
Expand Down Expand Up @@ -158,8 +159,9 @@ public function setMax($max)

$max = (int) $max;
if (($this->getMin() !== null) && ($max < $this->getMin())) {
throw new Exception\InvalidArgumentException("The maximum must be greater than or equal to the minimum file count, but "
. "$max < {$this->getMin()}");
throw new Exception\InvalidArgumentException(
"The maximum must be greater than or equal to the minimum file count, but $max < {$this->getMin()}"
);
}

$this->options['max'] = $max;
Expand Down
1 change: 1 addition & 0 deletions src/File/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Zend\Stdlib\ArrayUtils;
use Zend\Validator\AbstractValidator;
use Zend\Validator\Exception;

/**
* Validator for the file extension of a file
*/
Expand Down
Loading

0 comments on commit ef9e46c

Please sign in to comment.