1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Cycle\ORM\Parser; |
||||
6 | |||||
7 | use Cycle\ORM\Exception\ParserException; |
||||
8 | |||||
9 | /** |
||||
10 | * Node with ability to push it's data into referenced tree location. |
||||
11 | * |
||||
12 | * @internal |
||||
13 | */ |
||||
14 | final class SingularNode extends AbstractNode |
||||
15 | { |
||||
16 | /** |
||||
17 | * @param string[] $columns |
||||
18 | * @param string[] $primaryKeys |
||||
19 | * @param string[] $innerKeys Inner relation keys (for example user_id) |
||||
20 | * @param string[]|null $outerKeys Outer (parent) relation keys (for example id = parent.id) |
||||
21 | */ |
||||
22 | 2386 | public function __construct( |
|||
23 | array $columns, |
||||
24 | array $primaryKeys, |
||||
25 | protected array $innerKeys, |
||||
26 | ?array $outerKeys, |
||||
27 | ) { |
||||
28 | 2386 | parent::__construct($columns, $outerKeys); |
|||
29 | 2386 | $this->setDuplicateCriteria($primaryKeys); |
|||
30 | } |
||||
31 | |||||
32 | 2348 | protected function push(array &$data): void |
|||
33 | { |
||||
34 | 2348 | if ($this->parent === null) { |
|||
35 | 2 | throw new ParserException('Unable to register data tree, parent is missing.'); |
|||
36 | } |
||||
37 | |||||
38 | 2346 | foreach ($this->innerKeys as $key) { |
|||
39 | 2346 | if ($data[$key] === null) { |
|||
40 | //No data was loaded |
||||
41 | 354 | return; |
|||
42 | } |
||||
43 | } |
||||
44 | |||||
45 | 2338 | $this->parent->mount( |
|||
46 | 2338 | $this->container, |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
47 | 2338 | $this->indexName, |
|||
0 ignored issues
–
show
It seems like
$this->indexName can also be of type null ; however, parameter $index of Cycle\ORM\Parser\AbstractNode::mount() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
48 | 2338 | $this->intersectData($this->innerKeys, $data), |
|||
49 | $data, |
||||
50 | ); |
||||
51 | } |
||||
52 | } |
||||
53 |