1 | <?php |
||
30 | abstract class AbstractAliceContext implements KernelAwareContext, AliceContextInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $basePath; |
||
36 | |||
37 | /** |
||
38 | * @var string[] |
||
39 | */ |
||
40 | protected $classes; |
||
41 | |||
42 | /** |
||
43 | * @var FixturesFinderInterface |
||
44 | */ |
||
45 | protected $fixturesFinder; |
||
46 | |||
47 | /** |
||
48 | * @var KernelInterface |
||
49 | */ |
||
50 | protected $kernel; |
||
51 | |||
52 | /** |
||
53 | * @var LoaderInterface |
||
54 | */ |
||
55 | protected $loader; |
||
56 | |||
57 | /** |
||
58 | * @var PersisterInterface |
||
59 | */ |
||
60 | protected $persister; |
||
61 | |||
62 | /** |
||
63 | * @param string|null $basePath |
||
64 | */ |
||
65 | public function __construct($basePath = null) |
||
66 | { |
||
67 | $this->basePath = $basePath; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param KernelInterface $kernel |
||
72 | * @param FixturesFinderInterface $fixturesFinder |
||
73 | * @param LoaderInterface $loader |
||
74 | * @param PersisterInterface|ObjectManager $persister |
||
75 | * @param string $basePath |
||
76 | */ |
||
77 | final public function init( |
||
78 | KernelInterface $kernel, |
||
79 | FixturesFinderInterface $fixturesFinder, |
||
80 | LoaderInterface $loader, |
||
81 | PersisterInterface $persister, |
||
82 | $basePath = null |
||
83 | ) { |
||
84 | $this->kernel = $kernel; |
||
85 | $this->fixturesFinder = $fixturesFinder; |
||
86 | $this->loader = $loader; |
||
87 | $this->persister = $persister; |
||
88 | |||
89 | if (null !== $basePath) { |
||
90 | $this->basePath = $basePath; |
||
91 | } |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | abstract public function setKernel(KernelInterface $kernel); |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | final public function setBasePath($basePath) |
||
105 | { |
||
106 | $this->basePath = $basePath; |
||
107 | |||
108 | return $this; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | final public function getBasePath() |
||
115 | { |
||
116 | return $this->basePath; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @Transform /^service$/ |
||
121 | * |
||
122 | * @throws ServiceNotFoundException |
||
123 | */ |
||
124 | public function castServiceIdToService($serviceId) |
||
125 | { |
||
126 | return $this->kernel->getContainer()->get($serviceId); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @Transform /^persister$/ |
||
131 | * |
||
132 | * @throws ServiceNotFoundException |
||
133 | */ |
||
134 | public function castServiceIdToPersister($serviceId) |
||
135 | { |
||
136 | $service = $this->castServiceIdToService($serviceId); |
||
137 | |||
138 | return $this->resolvePersister($service); |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * {@inheritdoc} |
||
143 | */ |
||
144 | public function thereAreFixtures($fixturesFile, $persister = null) |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function thereAreSeveralFixtures(TableNode $fixturesFileRows, $persister = null) |
||
162 | |||
163 | /** |
||
164 | * @param array $fixturesFiles |
||
165 | * @param PersisterInterface $persister |
||
166 | */ |
||
167 | private function loadFixtures($fixturesFiles, $persister = null) |
||
221 | |||
222 | /** |
||
223 | * @param Doctrine|PersisterInterface|null $persister |
||
224 | * |
||
225 | * @return PersisterInterface |
||
226 | * |
||
227 | * @throws \InvalidArgumentException |
||
228 | */ |
||
229 | final protected function resolvePersister($persister) |
||
248 | } |
||
249 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: