Fix elements that should accumulate/increment values.

@return $this
493668
public function fixRepeatingArguments() {
        $either = [];
        foreach (static::transform($this)->children as $child) {
            $either[] = $child->children;
        }

        foreach ($either as $case) {
            $counts = [];
            foreach ($case as $child) {
                $ser = serialize($child);
                if (!isset($counts[$ser])) {
                    $counts[$ser] = ['cnt'=>0, 'items'=>[]];
                }

                $counts[$ser]['cnt']++;
                $counts[$ser]['items'][] = $child;
            }

            $repeatedCases = [];
            foreach ($counts as $child) {
                if ($child['cnt'] > 1) {
                    $repeatedCases = array_merge($repeatedCases, $child['items']);
                }
            }

            foreach ($repeatedCases as $e) {
                if ($e instanceof Argument || ($e instanceof Option && $e->argcount)) {
                    if (!$e->value) {
                        $e->value = [];
                    }
                    elseif (!is_array($e->value) && !$e->value instanceof \Traversable) {
                        $e->value = preg_split('/\s+/', $e->value);
                    }
                }
                if ($e instanceof Command || ($e instanceof Option && !$e->argcount)) {
                    $e->value = 0;
                }
            }
        }
        return $this;
    }
1321898
public function calculateTotal()
    {
        $this->total = $this->getItemsTotal() + $this->getAdjustmentTotal();

        if ($this->total < 0) {
            $this->total = 0;
        }

        return $this;
    }
20563
public function addRow($values=array()) {
		$row=$this->getBody()->addRow($this->_colCount);
		$row->setValues(\array_values($values));
		return $this;
	}
1098669
public function addValues(array $values = [])
    {
        $this->assertCanHaveMultipleValues();

        foreach ($values as $value) {
            $this->addValue($value);
        }

        return $this;
    }
1110628
public function update($value)
        {
            $this->validate($value);
            if ($this->chaining) {
                $this->chain = $value;
            } else {
                $this->current = $value;
            }
            return $this;
        }
577574
public function addExisting()
    {
        $classes = $this->blockManager->getBlockClasses();

        $this->addComponent($add = new GridFieldAddExistingSearchButton());
        $add->setSearchList(Block::get()->filter(array(
            'ClassName' => array_keys($classes),
        )));

        return $this;
    }
126713
public function moveLower()
    {
        $lowerItem = $this->lowerItem();

        if ( ! $lowerItem) return $this;

        $this->getConnection()->transaction(function() use($lowerItem) {

            $this->increment($this->positionColumn());

            // Decrement is not guaranteed to work with global scopes
            $lowerItem->{$this->positionColumn()} = $lowerItem->{$this->positionColumn()} - 1;
            $lowerItem->save();
        });

        return $this;
    }
1234854
public function withoutDuplicates(): self
    {
        if (count($this->pairs) === count(array_count_values(array_column($this->pairs, 0)))) {
            return $this;
        }

        $pairs = array_reduce($this->pairs, [$this, 'removeDuplicates'], []);
        if ($pairs === $this->pairs) {
            return $this;
        }

        $clone = clone $this;
        $clone->pairs = $pairs;

        return $clone;
    }
398212
public function cleanup(): self
    {
        foreach ($this->original as $key => $value) {
            ini_set($key, $value);
        }

        $this->original = [];

        return $this;
    }
51250
public function refresh() : self {
      $newCode = $this->collection->assemble();
      $tokens = Helper::getTokensFromString($newCode);

      $this->collection->setItems($tokens);
      return $this;
    }
331278
public function incrementMajor($amount = 1)
    {
        $this->major += $amount;
        $this->minor = 0;
        $this->patch = 0;

        return $this;
    }
1016250
public function updateTotals()
    {
        if (is_array($this->totals)) {
            foreach ($this->totals as $key => $val) {
                if (is_object($this->current_row[$key])) {
                    continue;
                }
                $this->totals[$key] = $val + $this->current_row[$key];
            }
        }
    }
1008345
protected function fill_old_values() {
		if ( ! $this->session ) {
			return;
		}

		if ( 0 === count( (array) $this->session->get_old_input() ) ) {
			return;
		}

		foreach ( $this->fields as $key => $field ) {
			if ( ! is_null( $old = $this->session->get_old_input( $key ) ) ) {
				$field->set_value( $old );
			}
		}
	}
935664
public function add(...$elements) : self
    {
        foreach ($elements as $element) {
            $this->elements[] = $element;
        }

        return $this;
    }
1306147
public function setValue($value)
    {

        if (isset($this->element)) {
            $this->element->setValue($value);
        }

        return $this;
    }
913385
private function addPending()
    {
        while (count($this->inProcess) < $this->concurrency) {

            $item = $this->getUnprocessed();

            if (empty($item)) {

                break;
            }

            $this->inProcess[$item['index']] = $item['process'];

            $item['process']->start();

            if (count($this->inProcess) >= $this->concurrency) {

                break;
            }
        }
    }
1121322
public function incrementMemberCount($value){
        if(!is_integer($value)){
            return $this;
        }
        $this->count_members = $this->count_members + $value;
        return $this;
    }