diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index ba3523f187..3ed3cbba95 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -49,19 +49,19 @@ class File extends Constraint if ($this->maxSize) { if (ctype_digit((string) $this->maxSize)) { $this->maxSize = (int) $this->maxSize; - $this->binaryFormat = $this->binaryFormat === null ? false : $this->binaryFormat; + $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; } elseif (preg_match('/^\d++k$/i', $this->maxSize)) { $this->maxSize = $this->maxSize * 1000; - $this->binaryFormat = $this->binaryFormat === null ? false : $this->binaryFormat; + $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; } elseif (preg_match('/^\d++M$/i', $this->maxSize)) { $this->maxSize = $this->maxSize * 1000000; - $this->binaryFormat = $this->binaryFormat === null ? false : $this->binaryFormat; - } elseif (preg_match('/^\d++ki$/i', $this->maxSize)) { + $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; + } elseif (preg_match('/^\d++Ki$/i', $this->maxSize)) { $this->maxSize = $this->maxSize << 10; - $this->binaryFormat = $this->binaryFormat === null ? true : $this->binaryFormat; + $this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat; } elseif (preg_match('/^\d++Mi$/i', $this->maxSize)) { $this->maxSize = $this->maxSize << 20; - $this->binaryFormat = $this->binaryFormat === null ? true : $this->binaryFormat; + $this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat; } else { throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $this->maxSize)); } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 7927865ac4..2c1378e588 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -54,7 +54,7 @@ class FileValidator extends ConstraintValidator switch ($value->getError()) { case UPLOAD_ERR_INI_SIZE: if ($constraint->maxSize) { - $limitInBytes = min(UploadedFile::getMaxFilesize(), (int) $constraint->maxSize); + $limitInBytes = min(UploadedFile::getMaxFilesize(), $constraint->maxSize); } else { $limitInBytes = UploadedFile::getMaxFilesize(); } @@ -118,7 +118,7 @@ class FileValidator extends ConstraintValidator if (0 === $sizeInBytes) { $this->context->addViolation($constraint->disallowEmptyMessage); } elseif ($constraint->maxSize) { - $limitInBytes = (int) $constraint->maxSize; + $limitInBytes = $constraint->maxSize; if ($sizeInBytes > $limitInBytes) { // Convert the limit to the smallest possible number