8000 Merge branch '4.1' · symfony/symfony@d353e4f · GitHub
[go: up one dir, main page]

Skip to content

Commit d353e4f

Browse files
Merge branch '4.1'
* 4.1: [DI] dont fail on missing classes when resource tracking is disabled [Validator] Added the missing constraints instance checks
2 parents d3ba3fb + 17163ab commit d353e4f

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
350350
$resource = new ClassExistenceResource($class, false);
351351
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
352352
} else {
353-
$classReflector = new \ReflectionClass($class);
353+
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false;
354354
}
355355
} catch (\ReflectionException $e) {
356356
if ($throw) {

src/Symfony/Component/Validator/Constraints/BicValidator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Validator\Constraint;
1616
use Symfony\Component\Validator\ConstraintValidator;
1717
use Symfony\Component\Validator\Exception\LogicException;
18+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1819
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1920

2021
/**
@@ -29,6 +30,10 @@ class BicValidator extends ConstraintValidator
2930
*/
3031
public function validate($value, Constraint $constraint)
3132
{
33+
if (!$constraint instanceof Bic) {
34+
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Bic');
35+
}
36+
3237
if (null === $value || '' === $value) {
3338
return;
3439
}

src/Symfony/Component/Validator/Constraints/CountValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class CountValidator extends ConstraintValidator
2525
*/
2626
public function validate($value, Constraint $constraint)
2727
{
28+
if (!$constraint instanceof Count) {
29+
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Count');
30+
}
31+
2832
if (null === $value) {
2933
return;
3034
}

src/Symfony/Component/Validator/Constraints/UuidValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ class UuidValidator extends ConstraintValidator
6767
*/
6868
public function validate($value, Constraint $constraint)
6969
{
70-
if (null === $value || '' === $value) {
71-
return;
72-
}
73-
7470
if (!$constraint instanceof Uuid) {
7571
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Uuid');
7672
}
7773

74+
if (null === $value || '' === $value) {
75+
return;
76+
}
77+
7878
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
7979
throw new UnexpectedValueException($value, 'string');
8080
}

0 commit comments

Comments
 (0)
0