/** * Replaces a sub-path by a different (sub-) path. * * @param integer $offset The offset at which to replace. * @param integer $length The length of the piece to replace. * @param PropertyPathInterface $path The path to insert. * @param integer $pathOffset The offset where the inserted piece * starts in $path. * @param integer $pathLength The length of the inserted piece. * If 0, the full path is inserted. * * @throws \OutOfBoundsException If the offset is invalid. */ public function replace($offset, $length, PropertyPathInterface $path, $pathOffset = 0, $pathLength = 0) { if (!isset($this->elements[$offset])) { throw new \OutOfBoundsException('The offset ' . $offset . ' is not within the property path'); } if (0 === $pathLength) { $pathLength = $path->getLength() - $pathOffset; } $this->resize($offset, $length, $pathLength); for ($i = 0; $i < $pathLength; ++$i) { $this->elements[$offset + $i] = $path->getElement($pathOffset + $i); $this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i); } }