8000 [Validator] smaller CS fixes by Tobion · Pull Request #11140 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] smaller CS fixes #11140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/Choice.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class Choice extends Constraint
public $callback;
public $multiple = false;
public $strict = false;
public $min = null;
public $max = null;
public $min;
public $max;
public $message = 'The value you selected is not a valid choice.';
public $multipleMessage = 'One or more of the given values is invalid.';
public $minMessage = 'You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.';
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class Email extends Constraint
public $message = 'This value is not a valid email address.';
public $checkMX = false;
public $checkHost = false;
public $strict = null;
public $strict;
}
16 changes: 8 additions & 8 deletions src/Symfony/Component/Validator/Constraints/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/
class File extends Constraint
{
public $maxSize = null;
public $binaryFormat = null;
public $maxSize;
public $binaryFormat;
public $mimeTypes = array();
public $notFoundMessage = 'The file could not be found.';
public $notReadableMessage = 'The file is not readable.';
Expand All @@ -49,19 +49,19 @@ public function __construct($options = null)
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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/FileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function validate($value, Constraint $constraint)
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();
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public function validate($value, Constraint $constraint)
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
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Validator/Constraints/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
class Image extends File
{
public $mimeTypes = 'image/*';
public $minWidth = null;
public $maxWidth = null;
public $maxHeight = null;
public $minHeight = null;
public $maxRatio = null;
public $minRatio = null;
public $minWidth;
public $maxWidth;
public $maxHeight;
public $minHeight;
public $maxRatio;
public $minRatio;
public $allowSquare = true;
public $allowLandscape = true;
public $allowPortrait = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Regex extends Constraint
{
public $message = 'This value is not valid.';
public $pattern;
public $htmlPattern = null;
public $htmlPattern;
public $match = true;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
/**
* The loader for loading the class metadata
*
* @var LoaderInterface
* @var LoaderInterface|null
*/
protected $loader;

/**
* The cache for caching class metadata
*
* @var CacheInterface
* @var CacheInterface|null
*/
protected $cache;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class XmlFileLoader extends FileLoader
/**
* An array of SimpleXMLElement instances.
*
* @var \SimpleXMLElement[]
* @var \SimpleXMLElement[]|null
*/
protected $classes = null;
protected $classes;

/**
* {@inheritdoc}
Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Component/Validator/ValidatorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ class ValidatorBuilder implements ValidatorBuilderInterface
private $methodMappings = array();

/**
* @var Reader
* @var Reader|null
*/
private $annotationReader = null;
private $annotationReader;

/**
* @var MetadataFactoryInterface
* @var MetadataFactoryInterface|null
*/
private $metadataFactory;

/**
* @var ConstraintValidatorFactoryInterface
* @var ConstraintValidatorFactoryInterface|null
*/
private $validatorFactory;

/**
* @var CacheInterface
* @var CacheInterface|null
*/
private $metadataCache;

/**
* @var TranslatorInterface
* @var TranslatorInterface|null
*/
private $translator;

Expand All @@ -92,12 +92,12 @@ class ValidatorBuilder implements ValidatorBuilderInterface
private $translationDomain;

/**
* @var PropertyAccessorInterface
* @var PropertyAccessorInterface|null
*/
private $propertyAccessor;

/**
* @var int
* @var int|null
*/
private $apiVersion;

Expand Down
0