protected function updateProperty(&$objectOrArray, $currentIndex, $value)
{
$property = $this->elements[$currentIndex];
if (is_object($objectOrArray) && $this->isIndex[$currentIndex]) {
if (!$objectOrArray instanceof \ArrayAccess) {
throw new InvalidPropertyException(sprintf('Index "%s" cannot be modified in object of type "%s" because it doesn\'t implement \ArrayAccess', $property, get_class($objectOrArray)));
}
$objectOrArray[$property] = $value;
} else if (is_object($objectOrArray)) {
$reflClass = new \ReflectionClass($objectOrArray);
$setter = 'set'.$this->camelize($property);
if ($reflClass->hasMethod($setter)) {
if (!$reflClass->getMethod($setter)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->getName()));
}
$objectOrArray->$setter($value);
} else if ($reflClass->hasProperty($property)) {
if (!$reflClass->getProperty($property)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "set%s()"?', $property, $reflClass->getName(), ucfirst($property)));
}
$objectOrArray->$property = $value;
} else if (property_exists($objectOrArray, $property) || $reflClass->hasMethod('__get')) {
// needed to support \stdClass instances
$objectOrArray->$property = $value;
} else {
throw new InvalidPropertyException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $reflClass->getName()));
}
} else {
$objectOrArray[$property] = $value;
}
}