From 4fdce3e0198740646637f08439e9e107ec474aaf Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Tue, 6 Aug 2024 19:59:26 +0300 Subject: [PATCH] Lower priority of NativeReflector when reflecting constants --- TyphoonReflector.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/TyphoonReflector.php b/TyphoonReflector.php index a987e06..79d8936 100644 --- a/TyphoonReflector.php +++ b/TyphoonReflector.php @@ -300,14 +300,6 @@ private function reflectConstantData(ConstantId $id): TypedMap return $cachedData; } - $data = $this->nativeReflector->reflectConstant($id); - - if ($data !== null) { - $this->cache->set($id, $data); - - return $data; - } - $resource = $this->locators->locate($id); if ($resource !== null) { @@ -316,6 +308,14 @@ private function reflectConstantData(ConstantId $id): TypedMap return ($this->buffer[$id] ?? throw new DeclarationNotFound($id))($this); } + $nativeData = $this->nativeReflector->reflectConstant($id); + + if ($nativeData !== null) { + $this->cache->set($id, $nativeData); + + return $nativeData; + } + throw new DeclarationNotFound($id); } @@ -341,12 +341,12 @@ private function reflectFunctionData(NamedFunctionId $id): TypedMap return ($this->buffer[$id] ?? throw new DeclarationNotFound($id))($this); } - $data = $this->nativeReflector->reflectNamedFunction($id); + $nativeData = $this->nativeReflector->reflectNamedFunction($id); - if ($data !== null) { - $this->cache->set($id, $data); + if ($nativeData !== null) { + $this->cache->set($id, $nativeData); - return $data; + return $nativeData; } throw new DeclarationNotFound($id); @@ -375,12 +375,12 @@ private function reflectClassData(NamedClassId|AnonymousClassId $id): TypedMap } if ($id instanceof NamedClassId) { - $data = $this->nativeReflector->reflectNamedClass($id); + $nativeData = $this->nativeReflector->reflectNamedClass($id); - if ($data !== null) { - $this->cache->set($id, $data); + if ($nativeData !== null) { + $this->cache->set($id, $nativeData); - return $data; + return $nativeData; } }