Skip to content

Commit 9054aea

Browse files
committed
Do not fail on calls to MyRepository->findBySomePropNotInModel()
Calling a findByXXX method on a repository tries to get the type of the property from the model. But the reposiory does also allow findBy methods for values that are not defined in the model but only in the database. So if the model does not have the certain property we tread it as type mixed.
1 parent 0af0174 commit 9054aea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Reflection/RepositoryFindByMethodReflection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public function getParameters(): array
8282
{
8383
$modelReflection = $this->broker->getClass($this->getModelName());
8484

85-
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getReadableType();
85+
if ($modelReflection->hasNativeProperty($this->getPropertyName())) {
86+
$type = $modelReflection->getNativeProperty($this->getPropertyName())->getReadableType();
87+
} else {
88+
$type = new \PHPStan\Type\MixedType(\false);
89+
}
8690

8791
return [
8892
new RepositoryFindByParameterReflection('arg', $type),

0 commit comments

Comments
 (0)