diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index f063e8f007438..aae083e4b7f0d 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -82,11 +82,16 @@ public function __construct(bool $magicCall = false, bool $throwExceptionOnInval */ public function getValue($objectOrArray, $propertyPath) { - $propertyPath = $this->getPropertyPath($propertyPath); - $zval = [ self::VALUE => $objectOrArray, ]; + + if (\is_object($objectOrArray) && false === strpbrk((string) $propertyPath, '.[')) { + return $this->readProperty($zval, $propertyPath)[self::VALUE]; + } + + $propertyPath = $this->getPropertyPath($propertyPath); + $propertyValues = $this->readPropertiesUntil($zval, $propertyPath, $propertyPath->getLength(), $this->ignoreInvalidIndices); return $propertyValues[\count($propertyValues) - 1][self::VALUE]; @@ -97,6 +102,22 @@ public function getValue($objectOrArray, $propertyPath) */ public function setValue(&$objectOrArray, $propertyPath, $value) { + if (\is_object($objectOrArray) && false === strpbrk((string) $propertyPath, '.[')) { + $zval = [ + self::VALUE => $objectOrArray, + ]; + + try { + $this->writeProperty($zval, $propertyPath, $value); + + return; + } catch (\TypeError $e) { + self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $propertyPath); + // It wasn't thrown in this class so rethrow it + throw $e; + } + } + $propertyPath = $this->getPropertyPath($propertyPath); $zval = [
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: