These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\FixturesBundle\Populator; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use Kunstmaan\FixturesBundle\Populator\Methods\MethodInterface; |
||
7 | |||
8 | class Populator |
||
9 | { |
||
10 | /** |
||
11 | * @var MethodInterface[] |
||
12 | */ |
||
13 | private $populators; |
||
14 | |||
15 | public function __construct() |
||
16 | { |
||
17 | $this->populators = new ArrayCollection(); |
||
0 ignored issues
–
show
|
|||
18 | } |
||
19 | |||
20 | public function populate($entity, $data) |
||
21 | { |
||
22 | foreach ($data as $property => $value) { |
||
23 | foreach ($this->populators as $populator) { |
||
24 | if ($populator->canSet($entity, $property, $value)) { |
||
25 | if ($value instanceof \Kunstmaan\FixturesBundle\Loader\Fixture) { |
||
26 | $populator->set($entity, $property, $value->getEntity()); |
||
27 | } elseif (is_array($value)) { |
||
28 | foreach ($value as &$item) { |
||
29 | if ($item instanceof \Kunstmaan\FixturesBundle\Loader\Fixture) { |
||
30 | $item = $item->getEntity(); |
||
31 | } |
||
32 | } |
||
33 | $populator->set($entity, $property, $value); |
||
34 | } else { |
||
35 | $populator->set($entity, $property, $value); |
||
36 | } |
||
37 | |||
38 | break; |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | public function addPopulator(MethodInterface $populator, $alias) |
||
45 | { |
||
46 | $this->populators->set($alias, $populator); |
||
0 ignored issues
–
show
|
|||
47 | |||
48 | return $this; |
||
49 | } |
||
50 | } |
||
51 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..