99use ReflectionMethod ;
1010use ReflectionFunctionAbstract ;
1111use ReflectionParameter ;
12- use Throwable ;
1312use ReflectionClass ;
1413use Featherbits \ServiceContainer \Contract \Activator as ActivatorContract ;
1514
@@ -26,28 +25,20 @@ public function __construct(ContainerContract $container)
2625
2726 public function call (callable $ callable )
2827 {
29- try {
30- $ reflection = self ::getCallableReflectionFunctionAbstract ($ callable );
31- return $ this ->track (self ::getFunctionIdentifier ($ reflection ), function () use ($ reflection , $ callable ) {
32- return call_user_func_array ($ callable , $ this ->getArguments ($ reflection ));
33- });
34- } catch (Throwable $ e ) {
35- throw new ContainerException ('Failed to call function ' , 0 , $ e );
36- }
28+ $ reflection = self ::getCallableReflectionFunctionAbstract ($ callable );
29+ return $ this ->track (self ::getFunctionIdentifier ($ reflection ), function () use ($ reflection , $ callable ) {
30+ return call_user_func_array ($ callable , $ this ->getArguments ($ reflection ));
31+ });
3732 }
3833
3934 public function instantiate (string $ type ): object
4035 {
41- try {
42- return $ this ->track ($ type , function () use ($ type ) {
43- $ reflection = new ReflectionClass ($ type );
44- return ($ constructor = $ reflection ->getConstructor ())
45- ? $ reflection ->newInstanceArgs ($ this ->getArguments ($ constructor ))
46- : $ reflection ->newInstance ();
47- });
48- } catch (Throwable $ e ) {
49- throw new ContainerException ('Failed to instantiate ' . $ type , 0 , $ e );
50- }
36+ return $ this ->track ($ type , function () use ($ type ) {
37+ $ reflection = new ReflectionClass ($ type );
38+ return ($ constructor = $ reflection ->getConstructor ())
39+ ? $ reflection ->newInstanceArgs ($ this ->getArguments ($ constructor ))
40+ : $ reflection ->newInstance ();
41+ });
5142 }
5243
5344 private function track (string $ identifier , callable $ callable )
0 commit comments