original_string: public function withReplaced(int $idx, Element $el): self
      {
          if (!isset($this->_elements[$idx])) {
              throw new \OutOfBoundsException(
                  "Structure doesn't have element at index $idx.");
          }
          $obj = clone $this;
          $obj->_elements[$idx] = $el;
          return $obj;
      }
code: public function withReplaced(int $idx, Element $el): self
      {
          if (!isset($this->_elements[$idx])) {
              throw new \OutOfBoundsException(
                  "Structure doesn't have element at index $idx.");
          }
          $obj = clone $this;
          $obj->_elements[$idx] = $el;
          return $obj;
      }
code_tokens: public function withReplaced ( int $ idx , Element $ el ) : self { if ( ! isset ( $ this -> _elements [ $ idx ] ) ) { throw new \ OutOfBoundsException ( "Structure doesn't have element at index $idx." ) ; } $ obj = clone $ this ; $ obj -> _elements [ $ idx ] = $ el ; return $ obj ; }
docstring: Get self with an element at the given index replaced by another.
  
  @param int $idx Element index
  @param Element $el New element to insert into the structure
  @throws \OutOfBoundsException
  @return self
docstring_tokens: Get self with an element at the given index replaced by another .