* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** * Checks if arguments of methods are properly configured. * * @author Kévin Dunglas * @author Nicolas Grekas */ class CheckArgumentsValidityPass extends AbstractRecursivePass { private $throwExceptions; public function __construct($throwExceptions = true) { $this->throwExceptions = $throwExceptions; } /** * {@inheritdoc} */ protected function processValue($value, $isRoot = false) { if (!$value instanceof Definition) { return parent::processValue($value, $isRoot); } $i = 0; foreach ($value->getArguments() as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { $msg = sprintf('Invalid constructor argument for service "%s": integer expected but found string "%s". Check your service definition.', $this->currentId, $k); $value->addError($msg); if ($this->throwExceptions) { throw new RuntimeException($msg); } break; } $msg = sprintf('Invalid constructor argument %d for service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $this->currentId, $i); $value->addError($msg); if ($this->throwExceptions) { throw new RuntimeException($msg); } } } foreach ($value->getMethodCalls() as $methodCall) { $i = 0; foreach ($methodCall[1] as $k => $v) { if ($k !== $i++) { if (!is_int($k)) { $msg = sprintf('Invalid argument for method call "%s" of service "%s": integer expected but found string "%s". Check your service definition.', $methodCall[0], $this->currentId, $k); $value->addError($msg); if ($this->throwExceptions) { throw new RuntimeException($msg); } break; } $msg = sprintf('Invalid argument %d for method call "%s" of service "%s": argument %d must be defined before. Check your service definition.', 1 + $k, $methodCall[0], $this->currentId, $i); $value->addError($msg); if ($this->throwExceptions) { throw new RuntimeException($msg); } } } } } } __halt_compiler();----SIGNATURE:----pNtJ4Z+4IaLABrzxrrx4B7m3LGD7qvKxNsRq5YMtBV7CqoIGwV23fTqjCharbV7dW6XpXQvGvVOxCyYAtrzeFES+9w3I9yFT/u1nh0NMvVEOBJI0f2m5lw0F/3GHnO5w3cNgflgIO08T0vebjK7wkVEOd0o1HDp8xrtyc8bp9PEYXLFDoyq+Ra4xOwivgXyKQcXkzTKmlCRHxREPSA4PdM+YeWIuv7htqJHDwB3Rwgg5BP6tnG5FxLRx4eyHOpKn2toHASHndPBInyQfZRImDiFGyjY/Ne7P70JXRAog09L4+FG0KVzvgAn4LCij4JTbN40fZkNXBvnwkqzVZCgdtD98iueGd4rQybtC/KA7C2dHFBSK1TSAHEHoC1upW63Yl7IR1lAqTb2+N7Hfd8BfQYpf7FNPzkEKricQBQcYSIGcZhkhugQzZEmBP9B3xllbmEeVKQNLm3huXvrpXABeRELFWx65Qeu255H1QUmk9gMziSbEyMCMurQxKKQ92+3x5kIljQppe56u6OgRfzSRQDOVcYdBitTJ6GjSFpCxrNXC+xwdiBgO3YGUNY+bj7KSzz7rCMV/ZQahktIQZcMUfl6KhAhtEFbka9SSV5+LX8BoiX5KaX8UQhSxNAm/g5+dwBZaA5zMkHNILUMQDWl3QuOefinwR/sija03gdIAh7M=----ATTACHMENT:----NzI1MjExNzUwMjI2OTc0MiAxNDE5MjExODA4OTE3MzIyIDI2NDI4MzU3MDg0NDgzNzA=