Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / HelperContainer / Argument / AutowiringResolver.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\HelperContainer\Argument;
12
13 use Behat\Behat\Context\Argument\ArgumentResolver;
14 use Behat\Behat\HelperContainer\ArgumentAutowirer;
15 use Psr\Container\ContainerInterface;
16 use ReflectionClass;
17
18 /**
19  * Resolves arguments that weren't resolved before by autowiring.
20  *
21  * @see ContextFactory
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class AutowiringResolver implements ArgumentResolver
26 {
27     /**
28      * @var ArgumentAutowirer
29      */
30     private $autowirer;
31
32     /**
33      * Initialises resolver.
34      *
35      * @param ContainerInterface $container
36      */
37     public function __construct(ContainerInterface $container)
38     {
39         $this->autowirer = new ArgumentAutowirer($container);
40     }
41
42     /**
43      * {@inheritdoc}
44      */
45     public function resolveArguments(ReflectionClass $classReflection, array $arguments)
46     {
47         if ($constructor = $classReflection->getConstructor()) {
48             return $this->autowirer->autowireArguments($constructor, $arguments);
49         }
50
51         return $arguments;
52     }
53 }