Increate PHPStan level to 6

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-04 01:09:49 +01:00
parent 103a47e134
commit 4519739f8b
No known key found for this signature in database
GPG key ID: 221E9281655813A6
4 changed files with 13 additions and 12 deletions

View file

@ -178,10 +178,11 @@ class NestedValidationException extends ValidationException implements IteratorA
}
$exceptions = $this->getIterator();
/** @var ValidationException $exception */
foreach ($exceptions as $exception) {
$messages[] = sprintf(
'%s- %s',
str_repeat(' ', ($exceptions[$exception] - $leveler) * 2),
str_repeat(' ', (int) ($exceptions[$exception] - $leveler) * 2),
$exception->getMessage()
);
}

View file

@ -87,7 +87,7 @@ final class Length extends AbstractRule
private function extractLength($input): ?int
{
if (is_string($input)) {
return mb_strlen($input, mb_detect_encoding($input));
return (int) mb_strlen($input, mb_detect_encoding($input));
}
if (is_array($input) || $input instanceof CountableInterface) {

View file

@ -29,7 +29,7 @@ class Size extends AbstractRule
public $minSize;
/**
* @var int
* @var float
*/
public $minValue;
@ -39,7 +39,7 @@ class Size extends AbstractRule
public $maxSize;
/**
* @var int
* @var float
*/
public $maxValue;
@ -60,9 +60,9 @@ class Size extends AbstractRule
*
* @param mixed $size
*
* @return int
* @return float
*/
private function toBytes($size)
private function toBytes($size): float
{
$value = $size;
$units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb'];
@ -75,18 +75,18 @@ class Size extends AbstractRule
}
if (!is_numeric($value)) {
throw new ComponentException(sprintf('"%s" is not a recognized file size.', $size));
throw new ComponentException(sprintf('"%s" is not a recognized file size.', (string) $size));
}
return $value;
return (float) $value;
}
/**
* @param int $size
* @param float $size
*
* @return bool
*/
private function isValidSize($size)
private function isValidSize(float $size): bool
{
if (null !== $this->minValue && null !== $this->maxValue) {
return $size >= $this->minValue && $size <= $this->maxValue;
@ -109,7 +109,7 @@ class Size extends AbstractRule
}
if (is_string($input)) {
return $this->isValidSize(filesize($input));
return $this->isValidSize((int) filesize($input));
}
return false;

View file

@ -8,7 +8,7 @@ parameters:
ignoreErrors:
- '/Call to an undefined static method Respect\\Validation\\Validator::iDoNotExistSoIShouldThrowException/'
- '/Parameter #2 $locale of function setlocale expects array|string|null, int given./'
level: 5
level: 6
paths:
- library/
- tests/