Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractCollection.php

function AbstractCollection::offsetSet

Throws

InvalidArgumentException if $element is of the wrong type.

Overrides AbstractArray::offsetSet

2 calls to AbstractCollection::offsetSet()
AbstractSet::offsetSet in vendor/ramsey/collection/src/AbstractSet.php
Sets the given value to the given offset in the array.
AbstractSet::offsetSet in vendor/ramsey/collection/src/AbstractSet.php
Sets the given value to the given offset in the array.
1 method overrides AbstractCollection::offsetSet()
AbstractSet::offsetSet in vendor/ramsey/collection/src/AbstractSet.php
Sets the given value to the given offset in the array.

File

vendor/ramsey/collection/src/AbstractCollection.php, line 75

Class

AbstractCollection
This class provides a basic implementation of `CollectionInterface`, to minimize the effort required to implement this interface

Namespace

Ramsey\Collection

Code

public function offsetSet(mixed $offset, mixed $value) : void {
    if ($this->checkType($this->getType(), $value) === false) {
        throw new InvalidArgumentException('Value must be of type ' . $this->getType() . '; value is ' . $this->toolValueToString($value));
    }
    if ($offset === null) {
        $this->data[] = $value;
    }
    else {
        $this->data[$offset] = $value;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal