From 9cacecbf790b563a60e464c622b4364b7e8af9c7 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 19 Feb 2015 13:40:39 +0100 Subject: [PATCH] [PropertyAccess] the property path constructor already implements the type check --- src/Symfony/Component/PropertyAccess/PropertyAccessor.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index a71789f7e7..2aeb1a8a6e 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -40,10 +40,8 @@ class PropertyAccessor implements PropertyAccessorInterface */ public function getValue($objectOrArray, $propertyPath) { - if (is_string($propertyPath)) { + if (!$propertyPath instanceof PropertyPathInterface) { $propertyPath = new PropertyPath($propertyPath); - } elseif (!$propertyPath instanceof PropertyPathInterface) { - throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface'); } $propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength()); @@ -56,10 +54,8 @@ class PropertyAccessor implements PropertyAccessorInterface */ public function setValue(&$objectOrArray, $propertyPath, $value) { - if (is_string($propertyPath)) { + if (!$propertyPath instanceof PropertyPathInterface) { $propertyPath = new PropertyPath($propertyPath); - } elseif (!$propertyPath instanceof PropertyPathInterface) { - throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface'); } $propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1);