Skip to content

Commit

Permalink
Handle $reflectionProperty->getDefaultValueExpression() return null (#…
Browse files Browse the repository at this point in the history
…3446)

* Handle $reflectionProperty->getDefaultValueExpression() return null

* fix

* fix

* pull from BetterReflection
  • Loading branch information
samsonasik committed Mar 3, 2023
1 parent ef959c7 commit 658e48f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/NodeTypeResolver/TypeAnalyzer/ArrayTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,14 @@ private function isPropertyFetchWithArrayDefault(Expr $expr): bool
$phpPropertyReflection = $this->reflectionResolver->resolvePropertyReflectionFromPropertyFetch($expr);
if ($phpPropertyReflection instanceof PhpPropertyReflection) {
$reflectionProperty = $phpPropertyReflection->getNativeReflection();
$betterReflection = $reflectionProperty->getBetterReflection();
$defaultValueExpr = $betterReflection->getDefaultValueExpression();

$defaultValueType = $this->nodeTypeResolver->getType($reflectionProperty->getDefaultValueExpression());
if (! $defaultValueExpr instanceof Expr) {
return false;
}

$defaultValueType = $this->nodeTypeResolver->getType($defaultValueExpr);
return $defaultValueType->isArray()
->yes();
}
Expand Down

0 comments on commit 658e48f

Please sign in to comment.