public static function set($key, $value): void
    {
        Assert::nullOrScalar($value, 'ini values must be scalar or null. Got: %s');

        $iniValue = $value === false ? '0' : (string) $value;

        $result = false;
        $ex = null;
        try {
            $result = Thrower::call('ini_set', $key, $iniValue);
        } catch (\Throwable $ex) {
        }

        if ($result === false || $ex !== null) {
            if (! static::has($key)) {
                throw new \RuntimeException(
                    "The ini option '${key}' does not exist. New ini options cannot be added.",
                    0,
                    $ex
                );
            }
            if (! static::$keys[$key]) {
                throw new \RuntimeException(
                    "Unable to change ini option '${key}', because it is not editable at runtime.",
                    0,
                    $ex
                );
            }

            $value = Assert::valueToString($value);
            throw new \RuntimeException(sprintf('Unable to change ini option "%s" to %s.', $key, $value), 0, $ex);
        }

        // HHVM sets values w/o error, but the change is not actually applied.
        if (ini_get($key) !== $iniValue) {
            $value = Assert::valueToString($value);
            throw new \RuntimeException(sprintf('Unable to change ini option "%s" to %s.', $key, $value), 0, $ex);
        }
    }