From bdac93c7f25700832a520c1f7c4e8f746d421e2d Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 5 Jun 2016 16:37:45 +0200 Subject: [PATCH] Throw exception on no such index --- src/Symfony/Component/PropertyAccess/PropertyAccessor.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index a1ff632231dd2..56d14a36f366b 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -435,6 +435,14 @@ private function readIndex($zval, $index) } elseif (is_object($result[self::VALUE])) { $result[self::REF] = $result[self::VALUE]; } + } else { + $message = sprintf('Undefined index %s.', $index); + + if ($keys = array_keys($zval[self::VALUE])) { + $message .= sprintf('Available indexes are "%s".', print_r($keys, true)); + } + + throw new NoSuchIndexException($message); } return $result;