* * 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:----GvIv7+XknPB/ecPf5zUXKgRK4vvyd1X9QoK6YYwWMVPicpXrDYV2xgk1yM0MN0wr4Q1tzjKMvNIKz0eidLt+E451rFy59zcScRtShooFcyjkocbXC3P3mmsEJuzvS6/00prh40kjtYNC6U4zIdZFm7/UXLJh4mwbDq3iA/DnJXH4x3eztthrxlRujp2LV5IICVJybN/C/l5bFjdqktGekNBy7ESryaAKwFmDI3zCS1hrMj72rHPW8jx6uFDGo6yaIQWLehwNVNvMNuGmitD5+CyiwwCfsavEWHq6GgXN7sGEF1D447xoGi+YooZ34gELzYhM+gHecMeIkGr8xbXv8Atf02jJGDFW7O2k0vfRLqXCMP6iW8J/VrvEzGB5yIrKE3Fq11S+fPyi0KMYAw4mEtciaGFUpfZ/n92MvNzPIs8c1GYBC/A9H0XZn0Zu6ZpouIoP/H/vdcpxDk0w/r8vZtSaqhSIwucZ4jh6T6vPd+hHpxlMplCj76vXVvd40BPsvEmJQuzJcYCJhCrdiJG0B88HvQfGk1HhELD0fblgeBeYfKItCFdbnlG0HVw9AhZCUXfsC/RyBHbArTRk/Z+GSARIvTeqVTVk0StF41yVV3JGjZCPaE+El+VoKnQe2aKnYwhS6eGy3ldecCyTp92JByfYJX0PUYHbmL7pMBYLZA0=----ATTACHMENT:----NDczMjkxMzI3MTE3OTc5OCAxNjc1Mzg4OTI2MTE3OTc0IDM2NzY3MjI1NTkxMTY2MTU=