File tree Expand file tree Collapse file tree
src/Reflection/BetterReflection/Reflector Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use Roave \BetterReflection \Reflection \Reflection ;
66use Roave \BetterReflection \Reflector \ClassReflector ;
7+ use Throwable ;
78
89final class MemoizingClassReflector extends ClassReflector
910{
1011
11- /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionClass> */
12+ /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionClass|\Throwable > */
1213 private $ reflections = [];
1314
1415 /**
@@ -21,9 +22,18 @@ final class MemoizingClassReflector extends ClassReflector
2122 public function reflect (string $ className ): Reflection
2223 {
2324 if (isset ($ this ->reflections [$ className ])) {
25+ if ($ this ->reflections [$ className ] instanceof Throwable) {
26+ throw $ this ->reflections [$ className ];
27+ }
2428 return $ this ->reflections [$ className ];
2529 }
26- return $ this ->reflections [$ className ] = parent ::reflect ($ className );
30+
31+ try {
32+ return $ this ->reflections [$ className ] = parent ::reflect ($ className );
33+ } catch (Throwable $ e ) {
34+ $ this ->reflections [$ className ] = $ e ;
35+ throw $ e ;
36+ }
2737 }
2838
2939}
Original file line number Diff line number Diff line change 44
55use Roave \BetterReflection \Reflection \Reflection ;
66use Roave \BetterReflection \Reflector \ConstantReflector ;
7+ use Throwable ;
78
89final class MemoizingConstantReflector extends ConstantReflector
910{
1011
11- /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionConstant> */
12+ /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionConstant|\Throwable > */
1213 private $ reflections = [];
1314
1415 /**
@@ -21,9 +22,18 @@ final class MemoizingConstantReflector extends ConstantReflector
2122 public function reflect (string $ constantName ): Reflection
2223 {
2324 if (isset ($ this ->reflections [$ constantName ])) {
25+ if ($ this ->reflections [$ constantName ] instanceof Throwable) {
26+ throw $ this ->reflections [$ constantName ];
27+ }
2428 return $ this ->reflections [$ constantName ];
2529 }
26- return $ this ->reflections [$ constantName ] = parent ::reflect ($ constantName );
30+
31+ try {
32+ return $ this ->reflections [$ constantName ] = parent ::reflect ($ constantName );
33+ } catch (Throwable $ e ) {
34+ $ this ->reflections [$ constantName ] = $ e ;
35+ throw $ e ;
36+ }
2737 }
2838
2939}
Original file line number Diff line number Diff line change 44
55use Roave \BetterReflection \Reflection \Reflection ;
66use Roave \BetterReflection \Reflector \FunctionReflector ;
7+ use Throwable ;
78
89final class MemoizingFunctionReflector extends FunctionReflector
910{
1011
11- /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionFunction> */
12+ /** @var array<string, \Roave\BetterReflection\Reflection\ReflectionFunction|\Throwable > */
1213 private $ reflections = [];
1314
1415 /**
@@ -21,9 +22,18 @@ final class MemoizingFunctionReflector extends FunctionReflector
2122 public function reflect (string $ functionName ): Reflection
2223 {
2324 if (isset ($ this ->reflections [$ functionName ])) {
25+ if ($ this ->reflections [$ functionName ] instanceof Throwable) {
26+ throw $ this ->reflections [$ functionName ];
27+ }
2428 return $ this ->reflections [$ functionName ];
2529 }
26- return $ this ->reflections [$ functionName ] = parent ::reflect ($ functionName );
30+
31+ try {
32+ return $ this ->reflections [$ functionName ] = parent ::reflect ($ functionName );
33+ } catch (Throwable $ e ) {
34+ $ this ->reflections [$ functionName ] = $ e ;
35+ throw $ e ;
36+ }
2737 }
2838
2939}
You can’t perform that action at this time.
0 commit comments