-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDefinitionArgumentsValidator.php
39 lines (30 loc) · 1.01 KB
/
DefinitionArgumentsValidator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Matthias\SymfonyServiceDefinitionValidator;
use Symfony\Component\DependencyInjection\Definition;
class DefinitionArgumentsValidator implements DefinitionArgumentsValidatorInterface
{
private $constructorResolver;
private $argumentsValidator;
public function __construct(
ConstructorResolverInterface $constructorResolver,
ArgumentsValidatorInterface $argumentsValidator
) {
$this->constructorResolver = $constructorResolver;
$this->argumentsValidator = $argumentsValidator;
}
public function validate(Definition $definition)
{
if ($definition->isAbstract()) {
return;
}
if ($definition->isSynthetic()) {
return;
}
$constructor = $this->constructorResolver->resolve($definition);
if ($constructor === null) {
return;
}
$arguments = $definition->getArguments();
$this->argumentsValidator->validate($constructor, array_values($arguments));
}
}