Skip to content

Commit 9cacecb

Browse files
committed
[PropertyAccess] the property path constructor already implements the type check
1 parent 4e11c07 commit 9cacecb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ public function __construct($magicCall = false)
4040
*/
4141
public function getValue($objectOrArray, $propertyPath)
4242
{
43-
if (is_string($propertyPath)) {
43+
if (!$propertyPath instanceof PropertyPathInterface) {
4444
$propertyPath = new PropertyPath($propertyPath);
45-
} elseif (!$propertyPath instanceof PropertyPathInterface) {
46-
throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface');
4745
}
4846

4947
$propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength());
@@ -56,10 +54,8 @@ public function getValue($objectOrArray, $propertyPath)
5654
*/
5755
public function setValue(&$objectOrArray, $propertyPath, $value)
5856
{
59-
if (is_string($propertyPath)) {
57+
if (!$propertyPath instanceof PropertyPathInterface) {
6058
$propertyPath = new PropertyPath($propertyPath);
61-
} elseif (!$propertyPath instanceof PropertyPathInterface) {
62-
throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface');
6359
}
6460

6561
$propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1);

0 commit comments

Comments
 (0)