Count number of objects and create a unique table for strings
@param $value The value to count and unique
@return void
185037
protected function uniqueAndCountValues($value)
    {
      // no uniquing for other types than CFString and CFData
        if ($value instanceof CFNumber) {
            $val = $value->getValue();
            if (intval($val) == $val && !is_float($val) && strpos($val, '.') === false) {
                $this->intSize += self::bytesInt($val);
            } else {
                $this->miscSize += 9; // 9 bytes (8 + marker byte) for real
            }
            $this->countObjects++;
            return;
        } elseif ($value instanceof CFDate) {
            $this->miscSize += 9; // since date in plist is real, we need 9 byte (8 + marker byte)
            $this->countObjects++;
            return;
        } elseif ($value instanceof CFBoolean) {
            $this->countObjects++;
            $this->miscSize += 1;
            return;
        } elseif ($value instanceof CFArray) {
            $cnt = 0;
            foreach ($value as $v) {
                ++$cnt;
                $this->uniqueAndCountValues($v);
                $this->objectRefs++; // each array member is a ref
            }

            $this->countObjects++;
            $this->intSize += self::bytesSizeInt($cnt);
            $this->miscSize++; // marker byte for array
            return;
        } elseif ($value instanceof CFDictionary) {
            $cnt = 0;
            foreach ($value as $k => $v) {
                ++$cnt;
                if (!isset($this->uniqueTable[$k])) {
                    $this->uniqueTable[$k] = 0;
                    $len = self::binaryStrlen($k);
                    $this->stringSize += $len + 1;
                    $this->intSize += self::bytesSizeInt(self::charsetStrlen($k, 'UTF-8'));
                }

                $this->objectRefs += 2; // both, key and value, are refs
                $this->uniqueTable[$k]++;
                $this->uniqueAndCountValues($v);
            }

            $this->countObjects++;
            $this->miscSize++; // marker byte for dict
            $this->intSize += self::bytesSizeInt($cnt);
            return;
        } elseif ($value instanceof CFData) {
            $val = $value->getValue();
            $len = strlen($val);
            $this->intSize += self::bytesSizeInt($len);
            $this->miscSize += $len + 1;
            $this->countObjects++;
            return;
        } else {
            $val = $value->getValue();
        }

        if (!isset($this->uniqueTable[$val])) {
            $this->uniqueTable[$val] = 0;
            $len = self::binaryStrlen($val);
            $this->stringSize += $len + 1;
            $this->intSize += self::bytesSizeInt(self::charsetStrlen($val, 'UTF-8'));
        }
        $this->uniqueTable[$val]++;
    }
640652
public function onSessionInit($value) {
        if(!$value->offsetExists("value")) {
            return;
        }

        $value = $value->offsetGet("value");

        foreach($this->getFormElements() as $name => $child) {
            if(!$value->offsetExists($name)) continue;

            $newvalue = $value->offsetGet($name);

            $child->setValue($newvalue);

            //check if child did some processing/initializing on object values - keep sync

            $childvalue = $child->getValue();

            if($newvalue !== $childvalue) {
                $value->offsetSet($name, $childvalue);
            }
        }
    }
1166116
public function setValue($value)
    {
        $value = $this->preformatValue($value);
        $manager = $this->getManager();
        $manager->clean();
        foreach ($value as $linkModel) {
            if (
                false === ($linkModel instanceof ModelInterface) &&
                !is_a($linkModel, $this->modelClass)) {
                $linkModel = call_user_func([$this->modelClass, 'objects'])->get(['pk' => $linkModel]);
            }

            if ($linkModel instanceof ModelInterface) {
                $manager->link($linkModel);
            } else {
                throw new Exception('ManyToMany field can set only arrays of Models or existing primary keys');
            }
        }
    }
67654
public static function repeat($value, $count){
		
		$list = new static();
		
		for($i = 0; $i < $count; ++$i){
			$list->_Arr[$i] = Functions\Object::copy($value);
		}
		
		return $list;
		
	}
526882
public function setDiscounts($value)
    {
        if (is_array($value)) {
            $bag = new Bag();
            foreach ($value as $discountParameters) {
                $bag->add(new Discount($discountParameters));
            }
            $value = $bag;
        }
        return $this->setParameter('discounts', $value);
    }
113818
public function addKeys($value)
    {
        if ($this->Keys === null) {
            $this->Keys = new \Protobuf\ScalarCollection();
        }

        $this->Keys->add($value);
    }
1104222
public function push($value)
    {
        $this->offsetSet($this->count(), $value);
        $this->seek($this->count() - 1);
    }
559689
public function setJsonValue(array $value)
    {
        // Removing colons from value.
        $value = str_replace(
            ':',
            '',
            $value
        );

        if (1 === count($value)) {
            $this->setValue(reset($value));
        } else {
            $this->setValue($value);
        }
    }
884526
public function addCustomsDeclarationNumbers($value)
    {
        if ($this->CustomsDeclarationNumbers === null) {
            $this->CustomsDeclarationNumbers = new \Protobuf\ScalarCollection();
        }

        $this->CustomsDeclarationNumbers->add($value);
    }
149219
public function setLanguage($value)
    {
        $value = strtolower($value);
        if (!isset($this->_models[$value])) {
            $this->_models[$value] = $this->loadTranslation($value);
        }
        $this->_language = $value;
    }
161058
public function addValue($value)
    {
        $this->values = array_values(
            array_unique(
                array_merge($this->values, $this->prepareValues($value))
            )
        );
    }
1353395
public function setId($value)
    {
        $this->_validateNotNull('Id', $value);
        $this->_validateInt('Id', $value);

        if ($this->data['id'] === $value) {
            return;
        }

        $this->data['id'] = $value;

        $this->_setModified('id');
    }
1277048
public function setCount( $count )
	{
		if ( $count == $this->getCount() ) { return; }

		$this->_values['count'] = (string) $count;
		$this->setModified();
	}
909052
public function setValue($value)
    {
        if (is_array($value)) {
            if (1 === count($value)) {
                $this->value = $value[0];
            } else {
                throw new \InvalidArgumentException('The argument must either be a string or an array with only one child');
            }
        } else {
            $this->value = $value;
        }
    }
1186969
protected function _addLog($value)
    {
        if ($this->_maximumLog >= 0 && count($this->_log) >= $this->_maximumLog) {
            array_shift($this->_log);
        }

        $this->_log[] = $value;
    }
1286276
public static function isCountable($value): bool
    {
        if (is_array($value)) {
            return true;
        }

        if (is_object($value) && ($value instanceof Countable)) {
            return true;
        }

        return false;
    }
82043
public function value($value): void
    {
        $obj = array_pop($this->stack);
        if (!empty($this->keys[$this->level])) {
            $obj[$this->keys[$this->level]] = $value;
            $this->keys[$this->level] = null;
        } else {
            $obj[] = $value;
        }
        $this->stack[] = $obj;
    }