Add with reference

@param string $arg1
@param string $arg2
@param int $scale
@return string
341563
public static function add2(& $arg1, $arg2, $scale = null) : string {
		$arg1 = self::add($arg1, $arg2, $scale);
		return $arg1;
	}
386558
public static function compare($arg1, $arg2, $scale = null) : int {
		return bccomp($arg1 . '', $arg2 . '', $scale ?? self::$scale);
	}
82931
public static function add(callable ...$args): callable
    {
        $sum = function ($x, ... $args) {
            $function = 0;
            foreach ($args as $arg) {
                $function += $arg($x);
            }
            return $function;
        };

        return function ($x) use ($args, $sum) {
            return $sum(...array_merge([$x], $args));
        };
    }
953532
public static function subtract($arg1, $arg2, $scale = null) : string {
		return self::__operator('bcsub', $arg1, $arg2, $scale ?? self::$scale);
	}
1241480
public static <T1, T2> void addInPlace(TwoDimensionalCounter<T1, T2> target, TwoDimensionalCounter<T1, T2> arg, double scale) {
    for (T1 outer : arg.firstKeySet())
      for (T2 inner : arg.secondKeySet()) {
        target.incrementCount(outer, inner, scale * arg.getCount(outer, inner));
      }
  }
1249743
public static function truncate($arg1, $scale = null) : string {
		$scale = $scale ?? self::$scale;
		if (($position = strpos($arg1 . '', '.')) !== false) {
			return substr($arg1 . '', 0, $position + 1 + $scale);
		}
		return $val;
	}
307057
public function addReference($p1, $p2 = null)
    {
        if (is_array($p1)) {
            $this->addReference(@$p1["local"], @$p1["foreign"]);
        } else {
            if ($p1 instanceof Column) {
                $p1 = $p1->getName();
            }
            if ($p2 instanceof Column) {
                $p2 = $p2->getName();
            }
            $this->localColumns[] = $p1;
            $this->foreignColumns[] = $p2;
        }
    }
765195
protected function setVar($arg1, $arg2 = null)
    {
        // One argument has to be an assoc array
        if (!isset($arg2) && is_array($arg1)) {
            foreach ($arg1 as $var => $value) {
                $this->vars[$var] = $this->varHandleObject($value);
            }
        }
        elseif (isset($arg2)) {
            $this->vars[$arg1] = $this->varHandleObject($arg2);
        }
        else {
            Throw new ControllerException('The vars to set are not correct.', 1001);
        }

        return $this;
    }
1230269
private function addTo(string $func, $args)
    {
        // Only already existing attributes can get filled with the args
        if (!isset($this->{$func})) {
            Throw new HtmlException(sprintf('Type "%s" is not allowed as html property/attribute', $func));
        }

        // Do we have one argument or two?
        if (count($args) == 1) {

            // One argument and not an array means we have one single value to add
            // This is when you set attributes without values like selected, disabled etc.
            if (!is_array($args[0])) {
                $this->{$func}[$args[0]] = false;
            }
            else {
                // Check the arguments for assoc array and add arguments according to the
                // result of check as key, val or only as val
                $array = new IsAssoc($args[0]);

                if ($array->isAssoc()) {
                    foreach ($args[0] as $key => $val) {
                        $this->{$func}[$key] = $val;
                    }
                }
                else {
                    foreach ($args[0] as $val) {
                        $this->{$func}[$val] = false;
                    }
                }
            }
        }
        else {
            $this->{$func}[$args[0]] = $args[1];
        }
    }
557077
public static function add(&$set, $args)
    {
        self::assertArgsNumber(1, $args);

        $value = $args[0];

        foreach ($set as $item) {
            if ($item === $value) {
                return;
            }
        }

        $set[] = $value;
    }
937268
public static function merge2(...$args): array
    {
        /** @var array[] $args */
        $res = array_shift($args);

        while (!empty($args)) {
            /** @var array $next */
            $next = array_shift($args);

            foreach ($next as $k => $v) {
                if (\is_int($k)) {
                    if (isset($res[$k])) {
                        $res[] = $v;
                    } else {
                        $res[$k] = $v;
                    }
                } elseif (\is_array($v) && isset($res[$k]) && \is_array($res[$k])) {
                    $res[$k] = self::merge2($res[$k], $v);
                } else {
                    $res[$k] = $v;
                }
            }
        }

        return $res;
    }
1161108
public static function multiply(BigNumber $lft, BigNumber $rgt, $scale = 10, $mutable = true)
    {
        $bigNumber = new BigNumber($lft, $scale, $mutable);

        return $bigNumber->multiply($rgt);
    }
825238
protected static function paramsValidation($value, int $scale = null)
    {
        if (null === $value) {
            throw new \InvalidArgumentException('$value must be a non null number');
        }

        if (null !== $scale && $scale < 0) {
            throw new \InvalidArgumentException('$scale must be a positive integer');
        }
    }
984029
public function subtract($arg1) : \Object\Value\Math {
		\Math::subtract2($this->result, $arg1, $this->scale);
		return $this;
	}
971640
public function addUses($args)
    {
        foreach ((array)$args as $key => $value) {
            $value = str_replace('/', '\\', $value);
            if (is_int($key)) {
                // namespace or class import
                if (class_exists($value)) {
                    // class import
                    $this->aliases[StringHelper::basename($value)] = $value;
                } else {
                    // namespace
                    $this->namespaces[] = $value;
                }
            } else {
                // aliased class import
                $this->aliases[$key] = $value;
            }
        }
    }
1300343
public function addArguments(?string $arguments = null)
    {
        $args = [];
        preg_match_all('/(?P<argument>\w+):(?P<value>[\w+\-]+)/', $arguments, $matches);
        if (isset($matches['argument'])) {
            foreach ($matches['argument'] as $key => $argKey) {
                if (isset($matches['value'][$key])) {
                    $args[$argKey] = $matches['value'][$key];
                }
            }
        }
        $this->arguments = $args;
    }
1116845
public function setScale($scale)
    {
        if (!$this->isMutable()) {
            throw new RuntimeException(sprintf(
                'Cannot set the scale to "%s" since the numbere is immutable.',
                $scale
            ));
        }

        // Convert to a string to make sure that the __toString method is called for objects.
        $scaleValue = (string)$scale;
        if (!ctype_digit($scaleValue)) {
            throw new InvalidArgumentException(sprintf(
                'Cannot set the scale to "%s". Invalid value.',
                $scaleValue
            ));
        }

        $this->scale = (int)$scaleValue;

        return $this;
    }