$element) { if (is_object($element)) { $this->_decorateArrayObject($element, $keyIsFirst, 0 === $index, $forceSetAll || 0 === $index); $this->_decorateArrayObject($element, $keyIsOdd, !$isEven, $forceSetAll || !$isEven); $this->_decorateArrayObject($element, $keyIsEven, $isEven, $forceSetAll || $isEven); $isEven = !$isEven; $index++; $this->_decorateArrayObject( $element, $keyIsLast, $index === $count, $forceSetAll || $index === $count ); } elseif (is_array($element)) { if ($forceSetAll || 0 === $index) { $array[$key][$keyIsFirst] = 0 === $index; } if ($forceSetAll || !$isEven) { $array[$key][$keyIsOdd] = !$isEven; } if ($forceSetAll || $isEven) { $array[$key][$keyIsEven] = $isEven; } $isEven = !$isEven; $index++; if ($forceSetAll || $index === $count) { $array[$key][$keyIsLast] = $index === $count; } } } return $array; } /** * Mark passed object with specified flag and appropriate value. * * @param \Magento\Framework\DataObject $element * @param string $key * @param bool $value * @param bool $isSkipped * @return void */ private function _decorateArrayObject($element, $key, $value, $isSkipped) { if ($isSkipped && $element instanceof \Magento\Framework\DataObject) { $element->setData($key, $value); } } }