Check and normalize various PHP settings/values

@param array $cfg (optional) configuration

@return void
976216
public static function bootstrap($cfg = array())
    {
        self::normalizeServerVar();
        $debug = Debug::getInstance();
        $hasLog = $debug->internal->hasLog();
        $collectWas = $debug->setCfg('collect', true);
        self::setCfg($cfg);
        self::checkSettings();
        self::checkRequestVars();
        $debug->setCfg('collect', $collectWas);
        if (!$hasLog) {
            $entryCount = $debug->getData('entryCount');
            $debug->setData('entryCountInitial', $entryCount);
        }
    }
786985
public function initialize(array $config)
    {
        $config = Hash::merge($this->_defaultConfig, $config);
        $this->setConfig($config);
    }
951933
private function configure(array $config = []): void
    {
        foreach ($config as $param => $value) {
            $property = $this->toCamelCase($param);
            if (property_exists(self::class, $property)) {
                $this->$property = $value;
            }
        }
    }
312903
public function get_delete(array $cfg): string
  {
    $res = '';
    if ( count($cfg['tables']) === 1 ){
      $res = 'DELETE '.( $cfg['ignore'] ? 'IGNORE ' : '' ).
        'FROM '.$this->table_full_name(current($cfg['tables']), true).PHP_EOL;
    }
    return $res;
  }
917050
private function checkConfig($config){
		$config = Hash::merge($this->configDef,$config);
		$this->include = $config['include'];
		unset($config['include']);
    	$this->config= $config;
	}
762843
private function fixConfigLanguage(array $config)
    {
        if (!isset($config['language']) && ($language = $this->getLanguage()) !== null) {
            $config['language'] = $language;
        }

        if (isset($config['language'])) {
            $config['language'] = strtolower(str_replace('_', '-', $config['language']));
        }

        return $config;
    }
1151310
protected function configureDefaults(array $config)
    {
        $defaults = [
            'http_errors' => true,
            'decode_content' => true,
            'verify' => true,
        ];

        // TODO finish defaults config feature

        $this->configs = array_replace($defaults, $config);

        // TODO add cookies settings after session and cookies feature finished
    }
717351
public function get_where(array $cfg): string
  {
    $res = $this->get_conditions($cfg['filters'] ?? [], $cfg);
    if ( !empty($res) ){
      $res = 'WHERE '.$res;
    }
    return $res;
  }
414392
private function _connect_ssh(array $cfg): bool
  {
    if ( isset($cfg['host']) ){
      $param = [];
      if ( isset($cfg['public'], $cfg['private']) ){
        $param['hostkey'] = 'ssh-rsa';
      }
      $this->cn = @ssh2_connect($cfg['host'], $cfg['port'] ?? 22, $param, [
        'debug' => function($message, $language, $always_display){
          bbn\x::log([$message, $language, $always_display]);
        },
        'disconnect' => function($reason, $message, $language){
          bbn\x::log([$reason, $message, $language]);
        }
      ]);
      if ( !$this->cn ){
        $this->error = _("Could not connect through SSH.");
      }
      else if ( isset($cfg['user'], $cfg['public'], $cfg['private']) ){
        /*
        $fingerprint = ssh2_fingerprint($this->cn, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
        if ( strcmp($this->ssh_server_fp, $fingerprint) !== 0 ){
          $this->error = _('Unable to verify server identity!');
        }
        */
        if ( !ssh2_auth_pubkey_file($this->cn, $cfg['user'], $cfg['public'], $cfg['private'], $cfg['pass'] ?? null) ){
          $this->error = _('Authentication rejected by server');
        }
        else if ( $this->stream = @ssh2_sftp($this->cn) ){
          $this->current = ssh2_sftp_realpath($this->stream, '.');
          return true;
        }
        else{
          $this->error = _("Could not connect through SFTP.");
        }
      }
      else if ( isset($cfg['user'], $cfg['pass']) && @ssh2_auth_password($this->cn, $cfg['user'], $cfg['pass']) ){
        //die(_("Could not authenticate with username and password."));
        $this->stream = @ssh2_sftp($this->cn);
        if ( $this->stream ){
          $this->current = ssh2_sftp_realpath($this->stream, '.');
          return true;
        }
        $this->error = _("Could not initialize SFTP subsystem.");
      }
      else{
        $this->error = _("Could not authenticate with username and password.");
      }
    }
    return false;
  }
656846
public function processConfig($config = array())
    {
        foreach (array_keys($config) as $setting) {
            if (array_key_exists($setting, $this->settings)) {
                $prop = $this->settings[$setting];
                $this->$prop = $config[$setting];
            }
        }
    }
918499
static public function setConfig(array $config)
    {
        foreach ($config as $k => $v) {
            self::$_config[$k] = $v;
        }
    }
1109278
private function setLaravelConfigs(array $config)
    {
        if (empty($config)) {
            return;
        }

        foreach ($config as $name => $value) {
            config([$name => $value]);
        }
    }
1290797
public function setConfig($config)
    {
        if (is_array($config)) {
            $this->config = $config;
        } else {
            $this->config = (array) gplcart_config_get((string) $config);
            $this->setDb($this->config['database']);
            $this->config = array_merge($this->config, $this->select());
        }
    }
993835
protected function has($key, $cfg = null) {
        if (!$cfg)
            $cfg = $this->cfg;
        return array_key_exists($key, $cfg);
    }
982815
private function applyConfig(array $config): void
    {
        // override
        if ($this->config != null) {
            $config = Config::merge($config, $this->config->getData());
        }
        $this->config = new Config($config);

        // set/reset logger options
        $loggerOptions = $this->config->get('logger');
        if ($loggerOptions != null) {
            isset($loggerOptions['level']) && $this->logger->setLevel($loggerOptions['level']);
            isset($loggerOptions['directory']) && $this->logger->setDirectory($loggerOptions['directory']);
        }
    }
1145411
public static function init($config = [])
    {
        if (!self::$config) {
            self::$config = include __DIR__ ."/default-config.php";
        }
        self::$config = Arr::array_merge_multi(self::$config, $config);
    }
319402
private function _add_primary(array &$cfg): void
  {
    // Inserting a row without primary when primary is needed and no auto-increment
    if (
      !empty($cfg['primary']) &&
      empty($cfg['auto_increment']) &&
      (($idx = array_search($cfg['primary'], $cfg['fields'], true)) > -1) &&
      (count($cfg['values']) === (count($cfg['fields']) - 1))
    ){
      $val = false;
      switch ( $cfg['primary_type'] ){
        case 'int':
          $val = random_int(
            ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] - 3 : 1) / 2),
            ceil(10 ** ($cfg['primary_length'] > 3 ? $cfg['primary_length'] : 1) / 2)
          );
          break;
        case 'binary':
          if ( $cfg['primary_length'] === 16 ){
            x::log($cfg['tables'], 'add_options');
            $val = $this->get_uid();
            x::log($val, 'add_options');
          }
          break;
      }
      if ( $val ){
        array_splice($cfg['values'], $idx, 0, $val);
        $this->set_last_insert_id($val);
        x::log(['v' => $cfg['values'], 'f' => $cfg['fields']], 'add_options');
      }
    }
  }