1 | <?php declare(strict_types=1); |
||
2 | /** |
||
3 | * Spiral Framework. |
||
4 | * |
||
5 | * @license MIT |
||
6 | * @author Anton Titov (Wolfy-J) |
||
7 | */ |
||
8 | |||
9 | namespace Cycle\Schema\Generator; |
||
10 | |||
11 | use Cycle\Schema\Exception\EntityException; |
||
12 | use Cycle\Schema\GeneratorInterface; |
||
13 | use Cycle\Schema\Registry; |
||
14 | |||
15 | final class ValidateEntity implements GeneratorInterface |
||
16 | { |
||
17 | /** |
||
18 | * @param Registry $registry |
||
19 | * @return Registry |
||
20 | * |
||
21 | * @throws EntityException |
||
22 | */ |
||
23 | public function run(Registry $registry): Registry |
||
24 | { |
||
25 | foreach ($registry->getIterator() as $entity) { |
||
26 | if (count($entity->getFields()) === 0) { |
||
27 | throw new EntityException( |
||
28 | "Entity `{$entity->getRole()}` is empty" |
||
29 | ); |
||
30 | } |
||
31 | } |
||
0 ignored issues
–
show
|
|||
32 | } |
||
33 | } |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: