Skip to content

Commit 5499151

Browse files
author
Ruud Seberechts
committed
[PropertyAccess] Improve PropertyAccessor::setValue param docs
Added param-out for the $objectOrArray argument so static code analysis does not assume the passed object can change type or become an array
1 parent b28732e commit 5499151

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

PropertyAccessor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public function getValue(object|array $objectOrArray, string|PropertyPathInterfa
109109
return $propertyValues[\count($propertyValues) - 1][self::VALUE];
110110
}
111111

112+
/**
113+
* @template T of object|array
114+
* @param T $objectOrArray
115+
* @param-out ($objectOrArray is array ? array : T) $objectOrArray
116+
*/
112117
public function setValue(object|array &$objectOrArray, string|PropertyPathInterface $propertyPath, mixed $value): void
113118
{
114119
if (\is_object($objectOrArray) && (false === strpbrk((string) $propertyPath, '.[') || $objectOrArray instanceof \stdClass && property_exists($objectOrArray, $propertyPath))) {

0 commit comments

Comments
 (0)