Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Definition/PropertyDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,34 @@ public function loadLazyProperties() {
}
}

public function offsetExists($offset) {
/**
* {@inheritdoc}
*/
public function offsetExists(mixed $offset): bool {
dump($this);
throw new \Exception("Accessing definition $this->name as array with offsetExists $offset.");
}

public function offsetGet($offset) {
/**
* {@inheritdoc}
*/
public function offsetGet(mixed $offset): mixed {
dump($this);
throw new \Exception("Accessing definition $this->name as array with offsetGet $offset.");
}

public function offsetSet($offset, $value) {
/**
* {@inheritdoc}
*/
public function offsetSet(mixed $offset, mixed $value): void {
dump($this);
throw new \Exception("Accessing definition $this->name as array with offsetSet $offset.");
}

public function offsetUnset($offset){
/**
* {@inheritdoc}
*/
public function offsetUnset(mixed $offset): void {
dump($this);
throw new \Exception("Accessing definition $this->name as array with offsetUnset $offset.");
}
Expand Down
22 changes: 17 additions & 5 deletions MutableTypedData/Data/DataItemArrayAccessTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
*/
trait DataItemArrayAccessTrait {

public function offsetExists($offset) {
/**
* {@inheritdoc}
*/
public function offsetExists(mixed $offset): bool {
return isset($this->value[$offset]);
}

public function offsetGet($offset) {
/**
* {@inheritdoc}
*/
public function offsetGet(mixed $offset): mixed {
if (!isset($this->properties[$offset])) {
throw new \Exception(sprintf("No property %s at address %s. Valid properties are: %s.",
$offset,
Expand Down Expand Up @@ -44,20 +50,26 @@ public function offsetGet($offset) {
}
}

public function offsetSet($offset, $value) {
/**
* {@inheritdoc}
*/
public function offsetSet(mixed $offset, mixed $value): void {
throw new \Exception(sprintf(
"Attempt to set array key %s at %s.",
$offset,
$this->getAddress()
));
}

public function offsetUnset($offset) {
/**
* {@inheritdoc}
*/
public function offsetUnset(mixed $offset): void {
throw new \Exception(sprintf(
"Attempt to unset array key %s at %s.",
$offset,
$this->getAddress()
));
}

}
}