From 5815d5e6e68e1a7a838ea8f102c86441ac4daa76 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 15 Nov 2024 09:44:30 +0100 Subject: [PATCH] Fix types --- src/QueryReflection/ReflectionCache.php | 3 +++ src/SqlAst/ParserInference.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/QueryReflection/ReflectionCache.php b/src/QueryReflection/ReflectionCache.php index 840fedd88..204a0d822 100644 --- a/src/QueryReflection/ReflectionCache.php +++ b/src/QueryReflection/ReflectionCache.php @@ -157,6 +157,9 @@ private function readCachedRecords(bool $useReadLock): ?array // the schemaHash is only available in replay-and-record mode. if (null === $this->schemaHash) { + if (! is_string($cache['schemaHash'])) { + throw new ShouldNotHappenException(); + } $this->schemaHash = $cache['schemaHash']; } elseif ($this->schemaHash !== $cache['schemaHash']) { return null; diff --git a/src/SqlAst/ParserInference.php b/src/SqlAst/ParserInference.php index 273316574..7264283bf 100644 --- a/src/SqlAst/ParserInference.php +++ b/src/SqlAst/ParserInference.php @@ -74,6 +74,10 @@ public function narrowResultType(string $queryString, ConstantArrayType $resultT $fromTable = $this->schemaReflection->getTable($fromName); } elseif ($from instanceof Join) { while (1) { + if (!$from instanceof Join || !method_exists($from, 'getCondition')) { + return $resultType; + } + if ($from->getCondition() === null) { if (QueryReflection::getRuntimeConfiguration()->isDebugEnabled()) { throw new UnresolvableAstInQueryException('Cannot narrow down types null join conditions: ' . $queryString);