From 3ea927fa914d984cdf5b9d168be19d289b1dcc04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=9F=D0=B0?= =?UTF-8?q?=D1=86=D1=83=D1=80=D0=B0?= Date: Tue, 9 Sep 2014 20:39:47 +1000 Subject: [PATCH] Rewrite code for service with parameters --- src/Application.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Application.php b/src/Application.php index aec3d68..5490e56 100644 --- a/src/Application.php +++ b/src/Application.php @@ -122,7 +122,13 @@ public function registerServices() $service = $class; } else if (isset($serviceParameters['__construct'])) { $shared = true; - $service = new $class($serviceParameters['__construct']); + + if (!is_array($serviceParameters)) { + throw new \Exception('Parameters for service : "' . $serviceName . '" must be array'); + } + + $reflector = new \ReflectionClass($class); + $service = $reflector->newInstanceArgs($serviceParameters); } else { if ($shared) { $service = new $class();