From 91e49ca364cf102b6d2a321a6079c809d86a97e5 Mon Sep 17 00:00:00 2001 From: Pablo Gancharov Date: Thu, 18 Dec 2014 18:12:03 -0200 Subject: [PATCH] Added Exception handling: InvalidArgumentException --- zray.php | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/zray.php b/zray.php index 9bccac8..b48c7be 100644 --- a/zray.php +++ b/zray.php @@ -234,27 +234,28 @@ private function collectConfig($config, &$storage) { * * @return array */ - private function makeArraySerializable($data) - { - $serializable = array(); - - foreach (ArrayUtils::iteratorToArray($data) as $key => $value) { - if ($value instanceof Traversable || is_array($value)) { - $serializable[$key] = $this->makeArraySerializable($value); - - continue; - } - - if ($value instanceof Closure) { - $serializable[$key] = new ClosureStub(); - - continue; - } - - $serializable[$key] = $value; - } - - return $serializable; + private function makeArraySerializable($data) { + $serializable = array(); + try { + foreach (ArrayUtils::iteratorToArray($data) as $key => $value) { + if ($value instanceof Traversable || is_array($value)) { + $serializable[$key] = $this->makeArraySerializable($value); + + continue; + } + + if ($value instanceof Closure) { + $serializable[$key] = new ClosureStub(); + continue; + } + + $serializable[$key] = $value; + } + } catch (\InvalidArgumentException $e) { + return $serializable; + } + + return $serializable; } private function reorderArray($config) {