File tree Expand file tree Collapse file tree 3 files changed +12
-22
lines changed
Expand file tree Collapse file tree 3 files changed +12
-22
lines changed Original file line number Diff line number Diff line change 44
55namespace Tempest \Reflection ;
66
7+ use Closure ;
78use ReflectionClass as PHPReflectionClass ;
89use ReflectionMethod as PHPReflectionMethod ;
910use ReflectionProperty as PHPReflectionProperty ;
1415final class ClassReflector implements Reflector
1516{
1617 use HasAttributes;
17- use HasMemoization;
18+
19+ private array $ memoize = [];
1820
1921 private readonly PHPReflectionClass $ reflectionClass ;
2022
@@ -167,4 +169,13 @@ public function implements(string $interface): bool
167169 {
168170 return $ this ->isInstantiable () && $ this ->getType ()->matches ($ interface );
169171 }
172+
173+ private function memoize (string $ key , Closure $ closure ): mixed
174+ {
175+ if (! isset ($ this ->memoize [$ key ])) {
176+ $ this ->memoize [$ key ] = $ closure ();
177+ }
178+
179+ return $ this ->memoize [$ key ];
180+ }
170181}
Original file line number Diff line number Diff line change 1313
1414trait HasAttributes
1515{
16- use HasMemoization;
17-
1816 abstract public function getReflection (): PHPReflectionClass |PHPReflectionMethod |PHPReflectionProperty |PHPReflectionParameter ;
1917
2018 /**
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments