Skip to content

Commit 17163ab

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

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
@@ -348,7 +348,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
348348
$resource = new ClassExistenceResource($class, false);
349349
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
350350
} else {
351-
$classReflector = new \ReflectionClass($class);
351+
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false;
352352
}
353353
} catch (\ReflectionException $e) {
354354
if ($throw) {

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

Lines changed: 5 additions & 0 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\ConstraintValidator;
16+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
1617

1718
/**
1819
* @author Michael Hirschler <michael.vhirsch@gmail.com>
@@ -26,6 +27,10 @@ class BicValidator extends ConstraintValidator
2627
*/
2728
public function validate($value, Constraint $constraint)
2829
{
30+
if (!$constraint instanceof Bic) {
31+
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Bic');
32+
}
33+
2934
if (null === $value || '' === $value) {
3035
return;
3136
}

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
@@ -66,14 +66,14 @@ class UuidValidator extends ConstraintValidator
6666
*/
6767
public function validate($value, Constraint $constraint)
6868
{
69-
if (null === $value || '' === $value) {
70-
return;
71-
}
72-
7369
if (!$constraint instanceof Uuid) {
7470
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Uuid');
7571
}
7672

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

0 commit comments

Comments
 (0)