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\Builder; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use Doctrine\Common\Persistence\ObjectManager; |
||
7 | use Kunstmaan\FixturesBundle\Loader\Fixture; |
||
8 | use Kunstmaan\FixturesBundle\Parser\Parser; |
||
9 | use Kunstmaan\FixturesBundle\Populator\Populator; |
||
10 | |||
11 | class BuildingSupervisor |
||
12 | { |
||
13 | /** |
||
14 | * @var Fixture[] |
||
15 | */ |
||
16 | private $fixtures; |
||
17 | |||
18 | /** |
||
19 | * @var BuilderInterface[] |
||
20 | */ |
||
21 | private $builders; |
||
22 | |||
23 | /** |
||
24 | * @var Parser |
||
25 | */ |
||
26 | private $parser; |
||
27 | |||
28 | private $providers; |
||
29 | |||
30 | /** |
||
31 | * @var Populator |
||
32 | */ |
||
33 | private $populater; |
||
34 | |||
35 | public function __construct(Parser $parser, Populator $populator) |
||
36 | { |
||
37 | $this->fixtures = []; |
||
38 | $this->builders = new ArrayCollection(); |
||
0 ignored issues
–
show
|
|||
39 | $this->providers = new ArrayCollection(); |
||
40 | $this->parser = $parser; |
||
41 | $this->populater = $populator; |
||
42 | } |
||
43 | |||
44 | public function buildFixtures(ObjectManager $manager) |
||
45 | { |
||
46 | foreach ($this->fixtures as $fixture) { |
||
47 | $classname = $fixture->getClass(); |
||
48 | $entity = new $classname(); |
||
49 | $fixture->setEntity($entity); |
||
50 | $this->parser->parseFixture($fixture, $this->providers, $this->fixtures); |
||
51 | |||
52 | foreach ($this->builders as $builder) { |
||
53 | if ($builder->canBuild($fixture)) { |
||
54 | $builder->preBuild($fixture); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | $this->populater->populate($fixture->getEntity(), $fixture->getProperties()); |
||
59 | $manager->persist($entity); |
||
60 | |||
61 | foreach ($this->builders as $builder) { |
||
62 | if ($builder->canBuild($fixture)) { |
||
63 | $builder->postBuild($fixture); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | $manager->flush(); |
||
68 | |||
69 | foreach ($this->fixtures as $fixture) { |
||
70 | foreach ($this->builders as $builder) { |
||
71 | if ($builder->canBuild($fixture)) { |
||
72 | $builder->postFlushBuild($fixture); |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return mixed |
||
0 ignored issues
–
show
|
|||
80 | */ |
||
81 | public function getFixtures() |
||
82 | { |
||
83 | return $this->fixtures; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param mixed $fixtures |
||
88 | * |
||
89 | * @return BuildingSupervisor |
||
90 | */ |
||
91 | public function setFixtures(array $fixtures) |
||
92 | { |
||
93 | $this->fixtures = $fixtures; |
||
94 | |||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | public function addBuilder(BuilderInterface $builder, $alias) |
||
99 | { |
||
100 | $this->builders->set($alias, $builder); |
||
0 ignored issues
–
show
|
|||
101 | |||
102 | return $this; |
||
103 | } |
||
104 | |||
105 | public function addProvider($provider) |
||
106 | { |
||
107 | $this->providers->add($provider); |
||
108 | |||
109 | return $this; |
||
110 | } |
||
111 | } |
||
112 |
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..