Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/dependency-injection/Compiler/ResolveNamedArgumentsPass.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
31 if (!$value instanceof Definition) { | 31 if (!$value instanceof Definition) { |
32 return parent::processValue($value, $isRoot); | 32 return parent::processValue($value, $isRoot); |
33 } | 33 } |
34 | 34 |
35 $calls = $value->getMethodCalls(); | 35 $calls = $value->getMethodCalls(); |
36 $calls[] = array('__construct', $value->getArguments()); | 36 $calls[] = ['__construct', $value->getArguments()]; |
37 | 37 |
38 foreach ($calls as $i => $call) { | 38 foreach ($calls as $i => $call) { |
39 list($method, $arguments) = $call; | 39 list($method, $arguments) = $call; |
40 $parameters = null; | 40 $parameters = null; |
41 $resolvedArguments = array(); | 41 $resolvedArguments = []; |
42 | 42 |
43 foreach ($arguments as $key => $argument) { | 43 foreach ($arguments as $key => $argument) { |
44 if (is_int($key)) { | 44 if (\is_int($key)) { |
45 $resolvedArguments[$key] = $argument; | 45 $resolvedArguments[$key] = $argument; |
46 continue; | 46 continue; |
47 } | 47 } |
48 | 48 |
49 if (null === $parameters) { | 49 if (null === $parameters) { |
50 $r = $this->getReflectionMethod($value, $method); | 50 $r = $this->getReflectionMethod($value, $method); |
51 $class = $r instanceof \ReflectionMethod ? $r->class : $this->currentId; | 51 $class = $r instanceof \ReflectionMethod ? $r->class : $this->currentId; |
52 $method = $r->getName(); | |
52 $parameters = $r->getParameters(); | 53 $parameters = $r->getParameters(); |
53 } | 54 } |
54 | 55 |
55 if (isset($key[0]) && '$' === $key[0]) { | 56 if (isset($key[0]) && '$' === $key[0]) { |
56 foreach ($parameters as $j => $p) { | 57 foreach ($parameters as $j => $p) { |
63 | 64 |
64 throw new InvalidArgumentException(sprintf('Invalid service "%s": method "%s()" has no argument named "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method, $key)); | 65 throw new InvalidArgumentException(sprintf('Invalid service "%s": method "%s()" has no argument named "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method, $key)); |
65 } | 66 } |
66 | 67 |
67 if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { | 68 if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { |
68 throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of %s or an instance of %s, %s given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, gettype($argument))); | 69 throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of %s or an instance of %s, %s given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, \gettype($argument))); |
69 } | 70 } |
70 | 71 |
71 $typeFound = false; | 72 $typeFound = false; |
72 foreach ($parameters as $j => $p) { | 73 foreach ($parameters as $j => $p) { |
73 if (!array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, true) === $key) { | 74 if (!array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, true) === $key) { |