Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a06897

Browse filesBrowse files
committed
[Validator] Update callable validation and exception thrown
1 parent 960ef60 commit 3a06897
Copy full SHA for 3a06897

File tree

14 files changed

+37
-30
lines changed
Filter options

14 files changed

+37
-30
lines changed

‎src/Symfony/Component/Validator/Constraints/Email.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Email.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Egulias\EmailValidator\EmailValidator as StrictEmailValidator;
1515
use Symfony\Component\Validator\Constraint;
16+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1617
use Symfony\Component\Validator\Exception\LogicException;
1718

1819
/**
@@ -90,7 +91,7 @@ public function __construct($options = null)
9091
}
9192

9293
if (\is_array($options) && array_key_exists('mode', $options) && !\in_array($options['mode'], self::$validationModes, true)) {
93-
throw new \InvalidArgumentException('The "mode" parameter value is not valid.');
94+
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
9495
}
9596

9697
parent::__construct($options);
@@ -100,8 +101,8 @@ public function __construct($options = null)
100101
@trigger_error(sprintf('Using the "%s" constraint without the "egulias/email-validator" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
101102
}
102103

103-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
104-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
104+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
105+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
105106
}
106107
}
107108
}

‎src/Symfony/Component/Validator/Constraints/Ip.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Ip.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
16+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1617

1718
/**
1819
* Validates that a value is a valid IP address.
@@ -85,8 +86,8 @@ public function __construct($options = null)
8586
throw new ConstraintDefinitionException(sprintf('The option "version" must be one of "%s"', implode('", "', self::$versions)));
8687
}
8788

88-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
89-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
89+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
90+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
9091
}
9192
}
9293
}

‎src/Symfony/Component/Validator/Constraints/Length.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Length.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1516
use Symfony\Component\Validator\Exception\MissingOptionsException;
1617

1718
/**
@@ -56,8 +57,8 @@ public function __construct($options = null)
5657
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), array('min', 'max'));
5758
}
5859

59-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
60-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
60+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
61+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
6162
}
6263
}
6364
}

‎src/Symfony/Component/Validator/Constraints/NotBlank.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/NotBlank.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1516

1617
/**
1718
* @Annotation
@@ -34,8 +35,8 @@ public function __construct($options = null)
3435
{
3536
parent::__construct($options);
3637

37-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
38-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
38+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
39+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
3940
}
4041
}
4142
}

‎src/Symfony/Component/Validator/Constraints/Regex.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Regex.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1516

1617
/**
1718
* @Annotation
@@ -37,8 +38,8 @@ public function __construct($options = null)
3738
{
3839
parent::__construct($options);
3940

40-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
41-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
41+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
42+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
4243
}
4344
}
4445

‎src/Symfony/Component/Validator/Constraints/Url.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Url.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1516

1617
/**
1718
* @Annotation
@@ -120,8 +121,8 @@ public function __construct($options = null)
120121

121122
parent::__construct($options);
122123

123-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
124-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
124+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
125+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
125126
}
126127
}
127128
}

‎src/Symfony/Component/Validator/Constraints/Uuid.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Uuid.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15+
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1516

1617
/**
1718
* @Annotation
@@ -81,8 +82,8 @@ public function __construct($options = null)
8182
{
8283
parent::__construct($options);
8384

84-
if (null !== $this->normalizer && !\is_callable($options['normalizer'])) {
85-
throw new \InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
85+
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
86+
throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', \is_object($this->normalizer) ? \get_class($this->normalizer) : \gettype($this->normalizer)));
8687
}
8788
}
8889
}

‎src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/EmailTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testConstructorStrict()
3535
}
3636

3737
/**
38-
* @expectedException \InvalidArgumentException
38+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3939
* @expectedExceptionMessage The "mode" parameter value is not valid.
4040
*/
4141
public function testUnknownModesTriggerException()
@@ -51,7 +51,7 @@ public function testNormalizerCanBeSet()
5151
}
5252

5353
/**
54-
* @expectedException \InvalidArgumentException
54+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
5555
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
5656
*/
5757
public function testInvalidNormalizerThrowsException()
@@ -60,7 +60,7 @@ public function testInvalidNormalizerThrowsException()
6060
}
6161

6262
/**
63-
* @expectedException \InvalidArgumentException
63+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
6464
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
6565
*/
6666
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/IpTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/IpTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizerCanBeSet()
2727
}
2828

2929
/**
30-
* @expectedException \InvalidArgumentException
30+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3131
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
3232
*/
3333
public function testInvalidNormalizerThrowsException()
@@ -36,7 +36,7 @@ public function testInvalidNormalizerThrowsException()
3636
}
3737

3838
/**
39-
* @expectedException \InvalidArgumentException
39+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
4040
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
4141
*/
4242
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/LengthTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizerCanBeSet()
2727
}
2828

2929
/**
30-
* @expectedException \InvalidArgumentException
30+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3131
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
3232
*/
3333
public function testInvalidNormalizerThrowsException()
@@ -36,7 +36,7 @@ public function testInvalidNormalizerThrowsException()
3636
}
3737

3838
/**
39-
* @expectedException \InvalidArgumentException
39+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
4040
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
4141
*/
4242
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/NotBlankTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizerCanBeSet()
2727
}
2828

2929
/**
30-
* @expectedException \InvalidArgumentException
30+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3131
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
3232
*/
3333
public function testInvalidNormalizerThrowsException()
@@ -36,7 +36,7 @@ public function testInvalidNormalizerThrowsException()
3636
}
3737

3838
/**
39-
* @expectedException \InvalidArgumentException
39+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
4040
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
4141
*/
4242
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/RegexTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testNormalizerCanBeSet()
9494
}
9595

9696
/**
97-
* @expectedException \InvalidArgumentException
97+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
9898
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
9999
*/
100100
public function testInvalidNormalizerThrowsException()
@@ -103,7 +103,7 @@ public function testInvalidNormalizerThrowsException()
103103
}
104104

105105
/**
106-
* @expectedException \InvalidArgumentException
106+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
107107
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
108108
*/
109109
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UrlTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizerCanBeSet()
2727
}
2828

2929
/**
30-
* @expectedException \InvalidArgumentException
30+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3131
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
3232
*/
3333
public function testInvalidNormalizerThrowsException()
@@ -36,7 +36,7 @@ public function testInvalidNormalizerThrowsException()
3636
}
3737

3838
/**
39-
* @expectedException \InvalidArgumentException
39+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
4040
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
4141
*/
4242
public function testInvalidNormalizerObjectThrowsException()

‎src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UuidTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizerCanBeSet()
2727
}
2828

2929
/**
30-
* @expectedException \InvalidArgumentException
30+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
3131
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("string" given).
3232
*/
3333
public function testInvalidNormalizerThrowsException()
@@ -36,7 +36,7 @@ public function testInvalidNormalizerThrowsException()
3636
}
3737

3838
/**
39-
* @expectedException \InvalidArgumentException
39+
* @expectedException \Symfony\Component\Validator\Exception\InvalidArgumentException
4040
* @expectedExceptionMessage The "normalizer" option must be a valid callable ("stdClass" given).
4141
*/
4242
public function testInvalidNormalizerObjectThrowsException()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.