src/Traits/ArrayAccessTrait.php
public function offsetSet($offset, $value)
    {
        if (!is_scalar($offset) && !is_null($offset)) {
            return;
        }

        $isNew = $this->offsetIsNew($offset);
        $oldData = $isNew ? null : $this->offsetGet($offset);
        $index = $isNew ? $this->arrayAccessMapIndex++ : array_search($offset, $this->baseArrayMap);
        $hook = $isNew ? 'insert' : 'update';

        if (is_null($offset)) {
            $offset = $this->arrayAccessConcreteIndex;
        }

        //filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php
        $offset = is_numeric($offset) || is_bool($offset) ? intval($offset) : (string)$offset;

        if (!$this->internalFilterHooks($offset, $value, 'input')) {
            return;
        }

        if (is_numeric($offset) && $offset >= $this->arrayAccessConcreteIndex) {
            $this->arrayAccessConcreteIndex = $offset + 1;
        }
        $value = $this->internalSanitizeHooks($offset, $value, 'input');
        $this->baseConcreteData[$offset] = $value;
        $this->baseArrayMap[$index] = $offset;
        $this->internalChangingHooks($offset, $value, $oldData, $hook);
    }
public function offsetSet($offset, $value)
    {
        if (!is_scalar($offset) && !is_null($offset)) {
            return;
        }

        $isNew = $this->offsetIsNew($offset);
        $oldData = $isNew ? null : $this->offsetGet($offset);
        $index = $isNew ? $this->arrayAccessMapIndex++ : array_search($offset, $this->baseArrayMap);
        $hook = $isNew ? 'insert' : 'update';

        if (is_null($offset)) {
            $offset = $this->arrayAccessConcreteIndex;
        }

        //filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php
        $offset = is_numeric($offset) || is_bool($offset) ? intval($offset) : (string)$offset;

        if (!$this->internalFilterHooks($offset, $value, 'input')) {
            return;
        }

        if (is_numeric($offset) && $offset >= $this->arrayAccessConcreteIndex) {
            $this->arrayAccessConcreteIndex = $offset + 1;
        }
        $value = $this->internalSanitizeHooks($offset, $value, 'input');
        $this->baseConcreteData[$offset] = $value;
        $this->baseArrayMap[$index] = $offset;
        $this->internalChangingHooks($offset, $value, $oldData, $hook);
    }
public function offsetSet ( $ offset , $ value ) { if ( ! is_scalar ( $ offset ) && ! is_null ( $ offset ) ) { return ; } $ isNew = $ this -> offsetIsNew ( $ offset ) ; $ oldData = $ isNew ? null : $ this -> offsetGet ( $ offset ) ; $ index = $ isNew ? $ this -> arrayAccessMapIndex ++ : array_search ( $ offset , $ this -> baseArrayMap ) ; $ hook = $ isNew ? 'insert' : 'update' ; if ( is_null ( $ offset ) ) { $ offset = $ this -> arrayAccessConcreteIndex ; } //filtering the key ($offset) based on http://www.php.net/manual/en/language.types.array.php $ offset = is_numeric ( $ offset ) || is_bool ( $ offset ) ? intval ( $ offset ) : ( string ) $ offset ; if ( ! $ this -> internalFilterHooks ( $ offset , $ value , 'input' ) ) { return ; } if ( is_numeric ( $ offset ) && $ offset >= $ this -> arrayAccessConcreteIndex ) { $ this -> arrayAccessConcreteIndex = $ offset + 1 ; } $ value = $ this -> internalSanitizeHooks ( $ offset , $ value , 'input' ) ; $ this -> baseConcreteData [ $ offset ] = $ value ; $ this -> baseArrayMap [ $ index ] = $ offset ; $ this -> internalChangingHooks ( $ offset , $ value , $ oldData , $ hook ) ; }
this is necessary for ArrayAccess Interface and save and element to array by offset
@param mixed $offset
@param mixed $value
@return void
this is necessary for ArrayAccess Interface and save and element to array by offset