src/AbstractMessage.php
final public function removeFromListAt($fieldName, $index)
    {
        $this->guardFrozenMessage();
        $field = static::schema()->getField($fieldName);
        Assertion::true($field->isAList(), sprintf('Field [%s] must be a list.', $fieldName), $fieldName);
        $index = (int) $index;

        if (empty($this->data[$fieldName])) {
            return $this;
        }

        array_splice($this->data[$fieldName], $index, 1);
        if (empty($this->data[$fieldName])) {
            $this->clearedFields[$fieldName] = true;
            return $this;
        }

        // reset the numerical indexes
        // todo: review, does this need to be optimized?
        $this->data[$fieldName] = array_values($this->data[$fieldName]);
        return $this;
    }
final public function removeFromListAt($fieldName, $index)
    {
        $this->guardFrozenMessage();
        $field = static::schema()->getField($fieldName);
        Assertion::true($field->isAList(), sprintf('Field [%s] must be a list.', $fieldName), $fieldName);
        $index = (int) $index;

        if (empty($this->data[$fieldName])) {
            return $this;
        }

        array_splice($this->data[$fieldName], $index, 1);
        if (empty($this->data[$fieldName])) {
            $this->clearedFields[$fieldName] = true;
            return $this;
        }

        // reset the numerical indexes
        // todo: review, does this need to be optimized?
        $this->data[$fieldName] = array_values($this->data[$fieldName]);
        return $this;
    }
final public function removeFromListAt ( $ fieldName , $ index ) { $ this -> guardFrozenMessage ( ) ; $ field = static :: schema ( ) -> getField ( $ fieldName ) ; Assertion :: true ( $ field -> isAList ( ) , sprintf ( 'Field [%s] must be a list.' , $ fieldName ) , $ fieldName ) ; $ index = ( int ) $ index ; if ( empty ( $ this -> data [ $ fieldName ] ) ) { return $ this ; } array_splice ( $ this -> data [ $ fieldName ] , $ index , 1 ) ; if ( empty ( $ this -> data [ $ fieldName ] ) ) { $ this -> clearedFields [ $ fieldName ] = true ; return $ this ; } // reset the numerical indexes // todo: review, does this need to be optimized? $ this -> data [ $ fieldName ] = array_values ( $ this -> data [ $ fieldName ] ) ; return $ this ; }
{@inheritdoc}
@return static
{