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#6540-zend-validator-cs-f…
Browse files Browse the repository at this point in the history
…ixes' into develop

Close zendframework/zendframework#6540
  • Loading branch information
Ocramius committed Sep 22, 2014
3 parents 1fc96f4 + 70cd8e8 + c066ec1 commit 9cb8b87
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 77 deletions.
8 changes: 2 additions & 6 deletions src/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,7 @@ 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) {
Expand Down Expand Up @@ -575,8 +573,6 @@ protected function translateMessage($messageKey, $message)
return $message;
}

return $translator->translate(
$message, $this->getTranslatorTextDomain()
);
return $translator->translate($message, $this->getTranslatorTextDomain());
}
}
50 changes: 25 additions & 25 deletions src/Barcode/Code128.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,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 @@ -144,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 @@ -227,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') {
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 @@ -311,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
1 change: 0 additions & 1 deletion src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Date extends AbstractValidator
*/
protected $format = self::FORMAT_DEFAULT;


/**
* Sets validator options
*
Expand Down
6 changes: 3 additions & 3 deletions src/DateStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function isValid($value)
if (in_array($intervalUnit, array('years', 'months', 'days'))) {
switch ($intervalUnit) {
case 'years':
if ( 0 == $diffParts['months'] && 0 == $diffParts['days']
if (0 == $diffParts['months'] && 0 == $diffParts['days']
&& 0 == $diffParts['hours'] && 0 == $diffParts['minutes']
&& 0 == $diffParts['seconds']
) {
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
6 changes: 3 additions & 3 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

namespace Zend\Validator\Exception;

class BadMethodCallException extends \BadMethodCallException
implements ExceptionInterface
{}
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
3 changes: 2 additions & 1 deletion src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
namespace Zend\Validator\Exception;

interface ExceptionInterface
{}
{
}
3 changes: 2 additions & 1 deletion src/Exception/ExtensionNotLoadedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
namespace Zend\Validator\Exception;

class ExtensionNotLoadedException extends RuntimeException
{}
{
}
6 changes: 3 additions & 3 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

namespace Zend\Validator\Exception;

class InvalidArgumentException extends \InvalidArgumentException
implements ExceptionInterface
{}
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
3 changes: 2 additions & 1 deletion src/Exception/InvalidMagicMimeFileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
namespace Zend\Validator\Exception;

class InvalidMagicMimeFileException extends InvalidArgumentException
{}
{
}
6 changes: 3 additions & 3 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +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
24 changes: 16 additions & 8 deletions src/File/ImageSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ public function getMinWidth()
public function setMinWidth($minWidth)
{
if (($this->getMaxWidth() !== null) && ($minWidth > $this->getMaxWidth())) {
throw new Exception\InvalidArgumentException("The minimum image width must be less than or equal to the "
. " maximum image width, but {$minWidth} > {$this->getMaxWidth()}");
throw new Exception\InvalidArgumentException(
"The minimum image width must be less than or equal to the "
. " maximum image width, but {$minWidth} > {$this->getMaxWidth()}"
);
}

$this->options['minWidth'] = (int) $minWidth;
Expand All @@ -158,8 +160,10 @@ public function getMaxWidth()
public function setMaxWidth($maxWidth)
{
if (($this->getMinWidth() !== null) && ($maxWidth < $this->getMinWidth())) {
throw new Exception\InvalidArgumentException("The maximum image width must be greater than or equal to the "
. "minimum image width, but {$maxWidth} < {$this->getMinWidth()}");
throw new Exception\InvalidArgumentException(
"The maximum image width must be greater than or equal to the "
. "minimum image width, but {$maxWidth} < {$this->getMinWidth()}"
);
}

$this->options['maxWidth'] = (int) $maxWidth;
Expand All @@ -186,8 +190,10 @@ public function getMinHeight()
public function setMinHeight($minHeight)
{
if (($this->getMaxHeight() !== null) && ($minHeight > $this->getMaxHeight())) {
throw new Exception\InvalidArgumentException("The minimum image height must be less than or equal to the "
. " maximum image height, but {$minHeight} > {$this->getMaxHeight()}");
throw new Exception\InvalidArgumentException(
"The minimum image height must be less than or equal to the "
. " maximum image height, but {$minHeight} > {$this->getMaxHeight()}"
);
}

$this->options['minHeight'] = (int) $minHeight;
Expand All @@ -214,8 +220,10 @@ public function getMaxHeight()
public function setMaxHeight($maxHeight)
{
if (($this->getMinHeight() !== null) && ($maxHeight < $this->getMinHeight())) {
throw new Exception\InvalidArgumentException("The maximum image height must be greater than or equal to the "
. "minimum image height, but {$maxHeight} < {$this->getMinHeight()}");
throw new Exception\InvalidArgumentException(
"The maximum image height must be greater than or equal to the "
. "minimum image height, but {$maxHeight} < {$this->getMinHeight()}"
);
}

$this->options['maxHeight'] = (int) $maxHeight;
Expand Down
10 changes: 4 additions & 6 deletions src/File/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public function setMin($min)
$max = $this->getMax(true);
if (($max !== null) && ($min > $max)) {
throw new Exception\InvalidArgumentException(
'The minimum must be less than or equal to the maximum file'
." size, but $min > $max");
"The minimum must be less than or equal to the maximum file size, but {$min} > {$max}"
);
}

$this->options['min'] = $min;
Expand Down Expand Up @@ -194,8 +194,8 @@ public function setMax($max)
$min = $this->getMin(true);
if (($min !== null) && ($max < $min)) {
throw new Exception\InvalidArgumentException(
'The maximum must be greater than or equal to the minimum file'
." size, but $max < $min");
"The maximum must be greater than or equal to the minimum file size, but {$max} < {$min}"
);
}

$this->options['max'] = $max;
Expand Down Expand Up @@ -365,6 +365,4 @@ protected function fromByteString($size)

return $value;
}


}
2 changes: 1 addition & 1 deletion src/File/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setFiles($files = array())
$this->options['files'] = $files;
}

if ($this->options['files'] === NULL) {
if ($this->options['files'] === null) {
$this->options['files'] = array();
}

Expand Down
8 changes: 4 additions & 4 deletions src/File/WordCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ 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 word count, but $min >"
. " {$this->getMax()}");
"The minimum must be less than or equal to the maximum word count, but {$min} > {$this->getMax()}"
);
}

$this->options['min'] = $min;
Expand Down Expand Up @@ -154,8 +154,8 @@ 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 word count, but "
. "$max < {$this->getMin()}");
"The maximum must be greater than or equal to the minimum word count, but {$max} < {$this->getMin()}"
);
}

$this->options['max'] = $max;
Expand Down
3 changes: 1 addition & 2 deletions src/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ public function isValid($value)
// Check input against DNS hostname schema
if ((count($domainParts) > 1)
&& ($utf8StrWrapper->strlen($value) >= 4)
&& ($utf8StrWrapper->strlen($value) <= 254))
{
&& ($utf8StrWrapper->strlen($value) <= 254)) {
$status = false;

do {
Expand Down
Loading

0 comments on commit 9cb8b87

Please sign in to comment.