Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ResolveNamedArgumentsPass.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\DependencyInjection\Compiler;
013
014 use Symfony\Component\DependencyInjection\Definition;
015 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
016 use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
017 use Symfony\Component\DependencyInjection\Reference;
018
019 /**
020 * Resolves named arguments to their corresponding numeric index.
021 *
022 * @author Kévin Dunglas <dunglas@gmail.com>
023 */
024 class ResolveNamedArgumentsPass extends AbstractRecursivePass
025 {
026 /**
027 * {@inheritdoc}
028 */
029 protected function processValue($value, $isRoot = false)
030 {
031 if (!$value instanceof Definition) {
032 return parent::processValue($value, $isRoot);
033 }
034
035 $calls = $value->getMethodCalls();
036 $calls[] = ['__construct', $value->getArguments()];
037
038 foreach ($calls as $i => $call) {
039 list($method, $arguments) = $call;
040 $parameters = null;
041 $resolvedArguments = [];
042
043 foreach ($arguments as $key => $argument) {
044 if (\is_int($key)) {
045 $resolvedArguments[$key] = $argument;
046 continue;
047 }
048
049 if (null === $parameters) {
050 $r = $this->getReflectionMethod($value, $method);
051 $class = $r instanceof \ReflectionMethod ? $r->class : $this->currentId;
052 $method = $r->getName();
053 $parameters = $r->getParameters();
054 }
055
056 if (isset($key[0]) && '$' === $key[0]) {
057 foreach ($parameters as $j => $p) {
058 if ($key === '$'.$p->name) {
059 $resolvedArguments[$j] = $argument;
060
061 continue 2;
062 }
063 }
064
065 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));
066 }
067
068 if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) {
069 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)));
070 }
071
072 $typeFound = false;
073 foreach ($parameters as $j => $p) {
074 if (!\array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, true) === $key) {
075 $resolvedArguments[$j] = $argument;
076 $typeFound = true;
077 }
078 }
079
080 if (!$typeFound) {
081 throw new InvalidArgumentException(sprintf('Invalid service "%s": method "%s()" has no argument type-hinted as "%s". Check your service definition.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method, $key));
082 }
083 }
084
085 if ($resolvedArguments !== $call[1]) {
086 ksort($resolvedArguments);
087 $calls[$i][1] = $resolvedArguments;
088 }
089 }
090
091 list(, $arguments) = array_pop($calls);
092
093 if ($arguments !== $value->getArguments()) {
094 $value->setArguments($arguments);
095 }
096 if ($calls !== $value->getMethodCalls()) {
097 $value->setMethodCalls($calls);
098 }
099
100 return parent::processValue($value, $isRoot);
101 }
102 }
103