Skip to content

Commit b31482e

Browse files
authored
Merge pull request #14 from cego/niza/fix-rule-crashing-for-vendor-data-files
niza/fox-rule-crashing-for-vendor-files
2 parents ee85576 + 16e4e3e commit b31482e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/SpatieLaravelData/Rules/ValidTypeRule.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function processNode(Node $node, Scope $scope): array
6060
// Flatten from a list of calls pr. file, to just a list of calls.
6161
->flatten(1)
6262
->map(Call::unserialize(...))
63+
// Make sure the rule does not crash in case a specific data class has not been analyzed - This can happen with data classes in the vendor folder
64+
->filter(fn (Call $call) => isset($classCollector[$call->target]))
6365
// Check each call for errors
6466
->map(fn (Call $call) => $this->compareTypes($call, $castCollector, $classCollector[$call->target]))
6567
// Flatten from a list of errors pr. call, to just a list of errors.

0 commit comments

Comments
 (0)