Problem/Motivation
The \Drupal\Core\TypedData\DataDefinition
implements ArrayAccess with a 'this is for bc support only' comment thus:
/**
* {@inheritdoc}
*
* This is for BC support only.
* @todo: Remove in https://www.drupal.org/node/1928868.
*/
public function offsetExists($offset) {
// PHP's array access does not work correctly with isset(), so we have to
// bake isset() in here. See https://bugs.php.net/bug.php?id=41727.
return array_key_exists($offset, $this->definition) && isset($this->definition[$offset]);
}
/**
* {@inheritdoc}
*
* This is for BC support only.
* @todo: Remove in https://www.drupal.org/node/1928868.
*/
public function &offsetGet($offset) {
if (!isset($this->definition[$offset])) {
$this->definition[$offset] = NULL;
}
return $this->definition[$offset];
}
/**
* {@inheritdoc}
*
* This is for BC support only.
* @todo: Remove in https://www.drupal.org/node/1928868.
*/
public function offsetSet($offset, $value) {
$this->definition[$offset] = $value;
}
/**
* {@inheritdoc}
*
* This is for BC support only.
* @todo: Remove in https://www.drupal.org/node/1928868.
*/
public function offsetUnset($offset) {
unset($this->definition[$offset]);
}
However the referenced issue is closed - fixed - #1928868: Typed config incorrectly implements Typed Data interfaces
So do we want to remove it or just remove the comment?
Proposed resolution
- throw deprecation in ArrayAccess
methods (like patch in comment #7)
- add deprecation test
- file issue to get rid of the methods in next major core release
Doing the deprecation-dance breaks just about every test known to Drupal CI: See #18.
Let's remove the comment and leave it in.
Let's trigger a deprecation error and observe what fails?
Result from #18: https://dispatcher.drupalci.org/job/drupal_patches/203233/#showFailuresLink
Test Result (2,578 failures / +2576)
It means ~10% so challenging but doable
Remaining tasks
patch/review/commit
User interface changes
no
API changes
accessing ArrayAccess
methods directly or indirectly will throw deprecation
- \Drupal\Core\TypedData\DataDefinition::offsetExists()
- \Drupal\Core\TypedData\DataDefinition::offsetGet()
- \Drupal\Core\TypedData\DataDefinition::offsetSet()
- \Drupal\Core\TypedData\DataDefinition::offsetUnset()
Data model changes
no