Şimdi bir proje üzerinde çalışıyorum ve ben ArrayAccess arabirimini uygulayan bir sınıf var.
: Husus, ben diyor benim uygulaması bir hata alıyorum
must be compatible with that of ArrayAccess::offsetSet().
Benim uygulama şöyle:
public function offsetSet($offset, $value) {
  if (!is_string($offset)) {
    throw new \LogicException("...");
  }
  $this->params[$offset] = $value;
}
Benim uygulaması doğru gibi yani, bana görünüyor. Herhangi bir fikir ne yanlış? Çok teşekkürler!
Sınıfı bu gibi görünür:
class HttpRequest implements \ArrayAccess {
  // tons of private variables, methods for working
  // with current http request etc. Really nothing that
  // could interfere with that interface.
  // ArrayAccess implementation
  public function offsetExists($offset) {
    return isset ($this->params[$offset]);
  }
  public function offsetGet($offset) {
    return isset ($this->params[$offset]) ? $this->params[$offset] : NULL;
  }
  public function offsetSet($offset, $value) {
     if (!is_string($offset)) {
      throw new \LogicException("You can only assing to params using specified key.");
     }
     $this->params[$offset] = $value;
  }
  public function offsetUnset($offset) {
    unset ($this->params[$offset]);
  }
}
Sınıfı bu gibi görünür:
class HttpRequest implements \ArrayAccess {
  // tons of private variables, methods for working
  // with current http request etc. Really nothing that
  // could interfere with that interface.
  // ArrayAccess implementation
  public function offsetExists($offset) {
    return isset ($this->params[$offset]);
  }
  public function offsetGet($offset) {
    return isset ($this->params[$offset]) ? $this->params[$offset] : NULL;
  }
  public function offsetSet($offset, $value) {
     if (!is_string($offset)) {
      throw new \LogicException("You can only assing to params using specified key.");
     }
     $this->params[$offset] = $value;
  }
  public function offsetUnset($offset) {
    unset ($this->params[$offset]);
  }
}
 
			