From 25cb765aca4c9a3ab05fee99ff3295b61ccaf7c0 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 4 Oct 2021 18:44:13 +0200 Subject: [PATCH] This caused bad memory leak --- .../Reflector/MemoizingClassReflector.php | 12 ++---------- .../Reflector/MemoizingConstantReflector.php | 12 ++---------- .../Reflector/MemoizingFunctionReflector.php | 12 ++---------- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php b/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php index d34a77a86f..8aeddfbadb 100644 --- a/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php +++ b/src/Reflection/BetterReflection/Reflector/MemoizingClassReflector.php @@ -8,7 +8,7 @@ final class MemoizingClassReflector extends ClassReflector { - /** @var array */ + /** @var array */ private array $reflections = []; /** @@ -22,18 +22,10 @@ public function reflect(string $className): Reflection { $lowerClassName = strtolower($className); if (isset($this->reflections[$lowerClassName])) { - if ($this->reflections[$lowerClassName] instanceof \Throwable) { - throw $this->reflections[$lowerClassName]; - } return $this->reflections[$lowerClassName]; } - try { - return $this->reflections[$lowerClassName] = parent::reflect($className); - } catch (\Throwable $e) { - $this->reflections[$lowerClassName] = $e; - throw $e; - } + return $this->reflections[$lowerClassName] = parent::reflect($className); } } diff --git a/src/Reflection/BetterReflection/Reflector/MemoizingConstantReflector.php b/src/Reflection/BetterReflection/Reflector/MemoizingConstantReflector.php index aca5db5d44..312f9a8af2 100644 --- a/src/Reflection/BetterReflection/Reflector/MemoizingConstantReflector.php +++ b/src/Reflection/BetterReflection/Reflector/MemoizingConstantReflector.php @@ -8,7 +8,7 @@ final class MemoizingConstantReflector extends ConstantReflector { - /** @var array */ + /** @var array */ private array $reflections = []; /** @@ -21,18 +21,10 @@ final class MemoizingConstantReflector extends ConstantReflector public function reflect(string $constantName): Reflection { if (isset($this->reflections[$constantName])) { - if ($this->reflections[$constantName] instanceof \Throwable) { - throw $this->reflections[$constantName]; - } return $this->reflections[$constantName]; } - try { - return $this->reflections[$constantName] = parent::reflect($constantName); - } catch (\Throwable $e) { - $this->reflections[$constantName] = $e; - throw $e; - } + return $this->reflections[$constantName] = parent::reflect($constantName); } } diff --git a/src/Reflection/BetterReflection/Reflector/MemoizingFunctionReflector.php b/src/Reflection/BetterReflection/Reflector/MemoizingFunctionReflector.php index 078392ef1b..7fa5e1ba7a 100644 --- a/src/Reflection/BetterReflection/Reflector/MemoizingFunctionReflector.php +++ b/src/Reflection/BetterReflection/Reflector/MemoizingFunctionReflector.php @@ -8,7 +8,7 @@ final class MemoizingFunctionReflector extends FunctionReflector { - /** @var array */ + /** @var array */ private array $reflections = []; /** @@ -22,18 +22,10 @@ public function reflect(string $functionName): Reflection { $lowerFunctionName = strtolower($functionName); if (isset($this->reflections[$lowerFunctionName])) { - if ($this->reflections[$lowerFunctionName] instanceof \Throwable) { - throw $this->reflections[$lowerFunctionName]; - } return $this->reflections[$lowerFunctionName]; } - try { - return $this->reflections[$lowerFunctionName] = parent::reflect($functionName); - } catch (\Throwable $e) { - $this->reflections[$lowerFunctionName] = $e; - throw $e; - } + return $this->reflections[$lowerFunctionName] = parent::reflect($functionName); } }