1 | <?php declare(strict_types=1); |
||
43 | abstract class BaseSeedRunner |
||
44 | { |
||
45 | /** Seed column name */ |
||
46 | const SEEDS_COLUMN_ID = 'id'; |
||
47 | |||
48 | /** Seed column name */ |
||
49 | const SEEDS_COLUMN_CLASS = 'class'; |
||
50 | |||
51 | /** Seed column name */ |
||
52 | const SEEDS_COLUMN_SEEDED_AT = 'seeded_at'; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $seedsTable; |
||
58 | |||
59 | /** |
||
60 | * @var null|callable |
||
61 | */ |
||
62 | private $seedInit = null; |
||
63 | |||
64 | /** |
||
65 | * @var IoInterface |
||
66 | */ |
||
67 | private $inOut; |
||
68 | |||
69 | /** |
||
70 | * @return string[] |
||
71 | */ |
||
72 | abstract protected function getSeedClasses(): array; |
||
73 | |||
74 | 2 | /** |
|
75 | * @param IoInterface $inOut |
||
76 | * @param callable $seedInit |
||
|
|||
77 | * @param string $seedsTable |
||
78 | */ |
||
79 | 2 | public function __construct( |
|
91 | |||
92 | /** |
||
93 | * @param ContainerInterface $container |
||
94 | * |
||
95 | * @return void |
||
96 | 1 | * |
|
97 | * @throws ContainerExceptionInterface |
||
98 | 1 | * @throws NotFoundExceptionInterface |
|
99 | 1 | * @throws DBALException |
|
100 | 1 | */ |
|
101 | public function run(ContainerInterface $container): void |
||
112 | |||
113 | /** |
||
114 | * @param ContainerInterface $container |
||
115 | * |
||
116 | * @return Generator |
||
117 | * |
||
118 | * @throws ContainerExceptionInterface |
||
119 | 1 | * @throws NotFoundExceptionInterface |
|
120 | * |
||
121 | 1 | * @SuppressWarnings(PHPMD.ElseExpression) |
|
122 | 1 | * @throws DBALException |
|
123 | */ |
||
124 | 1 | protected function getSeeds(ContainerInterface $container): Generator |
|
143 | |||
144 | /** |
||
145 | * @param ContainerInterface $container |
||
146 | * |
||
147 | 1 | * @return Connection |
|
148 | * |
||
149 | 1 | * @throws ContainerExceptionInterface |
|
150 | * @throws NotFoundExceptionInterface |
||
151 | */ |
||
152 | protected function getConnection(ContainerInterface $container): Connection |
||
156 | |||
157 | /** |
||
158 | 1 | * @param ContainerInterface $container |
|
159 | * @param string $seedClass |
||
160 | 1 | * |
|
161 | 1 | * @return void |
|
162 | */ |
||
163 | protected function executeSeedInit(ContainerInterface $container, string $seedClass): void |
||
169 | |||
170 | 1 | /** |
|
171 | * @return IoInterface |
||
172 | */ |
||
173 | protected function getIO(): IoInterface |
||
177 | |||
178 | 2 | /** |
|
179 | * @param IoInterface $inOut |
||
180 | 2 | * |
|
181 | * @return self |
||
182 | 2 | */ |
|
183 | private function setIO(IoInterface $inOut): self |
||
189 | |||
190 | /** |
||
191 | * @param AbstractSchemaManager $manager |
||
192 | 1 | * |
|
193 | * @return void |
||
194 | 1 | * |
|
195 | * @throws DBALException |
||
196 | */ |
||
197 | 1 | private function createSeedsTable(AbstractSchemaManager $manager): void |
|
216 | |||
217 | 1 | /** |
|
218 | * @param Connection $connection |
||
219 | 1 | * |
|
220 | 1 | * @return array |
|
221 | */ |
||
222 | 1 | private function readSeeded(Connection $connection): array |
|
243 | |||
244 | /** |
||
245 | * @param Connection $connection |
||
246 | * @param string $class |
||
247 | * |
||
248 | 1 | * @return void |
|
249 | * |
||
250 | 1 | * @throws DBALException |
|
251 | 1 | * @throws Exception |
|
252 | 1 | */ |
|
253 | 1 | private function saveSeed(Connection $connection, string $class): void |
|
262 | |||
263 | 1 | /** |
|
264 | * @return string |
||
265 | */ |
||
266 | private function getSeedsTable(): string |
||
270 | } |
||
271 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.