DeprecatedArray.php

Same filename and directory in other branches
  1. 8.9.x core/lib/Drupal/Component/Utility/DeprecatedArray.php
  2. 10 core/lib/Drupal/Component/Utility/DeprecatedArray.php
  3. 11.x core/lib/Drupal/Component/Utility/DeprecatedArray.php

Namespace

Drupal\Component\Utility

File

core/lib/Drupal/Component/Utility/DeprecatedArray.php

View source
<?php

namespace Drupal\Component\Utility;


/**
 * An array that triggers a deprecation warning when accessed.
 */
class DeprecatedArray extends \ArrayObject {
    
    /**
     * The deprecation message.
     *
     * @var string
     */
    protected $message;
    
    /**
     * DeprecatedArray constructor.
     *
     * @param array $values
     *   The array values.
     * @param $message
     *   The deprecation message.
     */
    public function __construct(array $values, $message) {
        $this->message = $message;
        parent::__construct($values);
    }
    
    /**
     * {@inheritdoc}
     */
    public function offsetExists($offset) {
        @trigger_error($this->message, E_USER_DEPRECATED);
        return parent::offsetExists($offset);
    }
    
    /**
     * {@inheritdoc}
     */
    public function offsetGet($offset) {
        @trigger_error($this->message, E_USER_DEPRECATED);
        return parent::offsetGet($offset);
    }
    
    /**
     * {@inheritdoc}
     */
    public function offsetSet($offset, $value) {
        @trigger_error($this->message, E_USER_DEPRECATED);
        parent::offsetSet($offset, $value);
    }
    
    /**
     * {@inheritdoc}
     */
    public function offsetUnset($offset) {
        @trigger_error($this->message, E_USER_DEPRECATED);
        parent::offsetUnset($offset);
    }
    
    /**
     * {@inheritdoc}
     */
    public function getIterator() {
        @trigger_error($this->message, E_USER_DEPRECATED);
        return parent::getIterator();
    }
    
    /**
     * {@inheritdoc}
     */
    public function unserialize($serialized) {
        @trigger_error($this->message, E_USER_DEPRECATED);
        parent::unserialize($serialized);
    }
    
    /**
     * {@inheritdoc}
     */
    public function serialize() {
        @trigger_error($this->message, E_USER_DEPRECATED);
        return parent::serialize();
    }
    
    /**
     * {@inheritdoc}
     */
    public function count() {
        @trigger_error($this->message, E_USER_DEPRECATED);
        return parent::count();
    }

}

Classes

Title Deprecated Summary
DeprecatedArray An array that triggers a deprecation warning when accessed.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.