8000 [Validator] Throw exception if ObjectInitializer is constructed witho… · symfony/symfony@321d5bb · GitHub
[go: up one dir, main page]

Skip to content

Commit 321d5bb

Browse files
committed
[Validator] Throw exception if ObjectInitializer is constructed without visitors
1 parent 1156bde commit 321d5bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Component/Validator/NodeVisitor/ObjectInitializer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ public function __construct(array $initializers)
3030
{
3131
foreach ($initializers as $initializer) {
3232
if (!$initializer instanceof ObjectInitializerInterface) {
33-
throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.');
33+
throw new \InvalidArgumentException('Validator initializers must implement ObjectInitializerInterface.');
3434
}
3535
}
3636

37+
// If no initializer is present, this visitor should not even be created
38+
if (0 === count($initializers)) {
39+
throw new \InvalidArgumentException('Please pass at least one initializer.');
40+
}
41+
3742
$this->initializers = $initializers;
3843
}
3944

0 commit comments

Comments
 (0)
0