Are we in developer debug mode?

Note: You need to set "$CFG->debug = (E_ALL | E_STRICT);" in config.php,
the reason is we need to use this before we setup DB connection or caches for CFG.

@return bool
546982
protected static function is_developer() {
        global $CFG;

        // Note we can not rely on $CFG->debug here because DB is not initialised yet.
        if (isset($CFG->config_php_settings['debug'])) {
            $debug = (int)$CFG->config_php_settings['debug'];
        } else {
            return false;
        }

        if ($debug & E_ALL and $debug & E_STRICT) {
            return true;
        }

        return false;
    }
1240490
public function set_debug($dbg = true)
    {
        $this->options['debug'] = $dbg;
        $this->conn->setDebug($dbg, array($this, 'debug_handler'));
    }
139653
public function runningInStrictMode(): bool {
    $strictMode = true;
    $settings   = $this->getSettings();

    if (is_array($settings) && !empty($settings)) {
      $mode = $settings['mode'];

      if ($mode != self::STRICT_MODE) {
        $strictMode = false;
      }
    }

    return $strictMode;
  }
1180561
public function set_debug($enable)
    {
        if ($enable === true || $enable === false) {
            $this->debug = $enable;

            return true;
        }

        trigger_error('Error: the parameter for set_debug() must be boolean');

        return false;
    }
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);
        }
    }
1129950
public function save_cfg()
  {
    if ( $this->check() ){
      $this->db->update(
          $this->class_cfg['tables']['users'],
          [$this->fields['cfg'] => json_encode($this->cfg)],
          [$this->fields['id'] => $this->id]);
    }
    return $this;
  }
1013539
public static function check_config($cfg){
    if ( !\is_array($cfg) ){
      self::$error = "The configuration is not a valid array";
      return false;
    }
    self::$validator->check(bbn\x::to_object($cfg), static::$schema);
    self::$error = '';
    if ( self::$validator->isValid() ){
      return 1;
    }
    foreach ( self::$validator->getErrors() as $error ){
      self::$error .= sprintf("[%s] %s",$error['property'], $error['message']);
      var_dump($cfg);
    }
    return false;
  }
801168
public static boolean isDebuggingEnabled() {
        boolean debuggingEnabled = false;
        if (ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0) {
            debuggingEnabled = true;
        } else if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Xdebug")) {
            debuggingEnabled = true;
        } else if (System.getProperty("debug", "").equals("true")) {
            debuggingEnabled = true;
        }
        return debuggingEnabled;
    }
730508
private function debug()
    {
        if (!empty($this->_errorCallbackFunction)) {
            $error = array("Error" => $this->_error);
            if (!empty($this->_sql))
                $error["SQL Statement"] = $this->_sql;
            if (!empty($this->_bind))
                $error["Bind Parameters"] = trim(print_r($this->_bind, true));

            $backtrace = debug_backtrace();
            if (!empty($backtrace)) {
                foreach ($backtrace as $info) {
                    if (isset($info["file"]) && $info["file"] != __FILE__)
                        $error["Backtrace_Line_" . $info["line"]] = $info["file"] . " at line " . $info["line"];
                }
            }

            $msg = "";

            $msg .= "SQL Error\n" . str_repeat("-", 50);
            foreach ($error as $key => $val) {
                $msg .= "\n\n$key:\n$val";
            }

            $this->logger->error($msg);
        }
    }
6296
private function buildDebugSql()
    {
        $bindParams = $this->bindParams;
        foreach ($bindParams as $key => $val) {
            $bindParams[$key] = str_replace('\\\\', '\\', addslashes($val));
        }
        return vsprintf(str_replace('%s', "'%s'", $this->currentSql), $bindParams);
    }
240814
protected function isDebug()
    {
        if (($this->debugOverride && !$this->debug) || (!$this->debugOverride && !static::$staticDebug)) {
            return false;
        }

        if ($this->debugOverride && $this->debug) {
            return $this->debug;
        }

        return static::$staticDebug;
    }
939583
public function debug()
    {
        Debug::show($this->javascript);
        Debug::show($this->css);
        Debug::show($this->customCSS);
        Debug::show($this->customScript);
        Debug::show($this->customHeadTags);
        Debug::show($this->combinedFiles);
    }
29205
public function isBehatConfigured() {

    // Verify that URIs required for Drupal and Behat are configured correctly.
    $local_behat_config = $this->getLocalBehatConfig();
    if ($this->getConfigValue('project.local.uri') != $local_behat_config->get('local.extensions.Behat\MinkExtension.base_url')) {
      $this->logger->warning('project.local.uri in blt.yml does not match local.extensions.Behat\MinkExtension.base_url in local.yml.');
      $this->logger->warning('project.local.uri = ' . $this->getConfigValue('project.local.uri'));
      $this->logger->warning('local.extensions.Behat\MinkExtension.base_url = ' . $local_behat_config->get('local.extensions.Behat\MinkExtension.base_url'));
      return FALSE;
    }

    // Verify that URIs required for an ad-hoc PHP internal server are
    // configured correctly.
    if ($this->getConfigValue('tests.run-server')) {
      if ($this->getConfigValue('tests.server.url') != $this->getConfigValue('project.local.uri')) {
        $this->logger->warning("tests.run-server is enabled, but the server URL does not match Drupal's base URL.");
        $this->logger->warning('project.local.uri = ' . $this->getConfigValue('project.local.uri'));
        $this->logger->warning('tests.server.url = ' . $this->getConfigValue('tests.server.url'));
        $this->logger->warning('local.extensions.Behat\MinkExtension.base_url = ' . $local_behat_config->get('local.extensions.Behat\MinkExtension.base_url'));

        return FALSE;
      }
    }

    // Verify that required Behat files are present.
    if (!$this->areBehatConfigFilesPresent()) {
      return FALSE;
    }

    return TRUE;
  }
39185
private function _set_cfg(){
    if ( \is_array($this->cfg) ){
      $p =& $this->cfg['params'];
      $components = false;
      if ( !empty($p['components']) ){
        $components = explode(',', $p['components']);
      }
      $this->cfg = bbn\x::merge_arrays($this->cfg, [
        'test' => !empty($p['test']),
        'lang' => empty($p['lang']) ? self::$default_language : $p['lang'],
        'nocompil' => !empty($p['nocompil']),
        'has_css' => !isset($p['css']) || $p['css'],
        'has_dep' => !isset($p['dep']) || $p['dep'],
        'latest' => isset($p['latest']) ? 1 : false,
        'is_component' => !empty($p['components']),
        'components' => $components
      ]);
    }
  }
851083
public static function debug()
    {
        $vars = func_get_args();

        $cloner = new VarCloner();

        $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();

        $dumper->setStyles([
            'default' => 'background-color:#fff; color:#FF8400; line-height:1.2em; 
                font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; 
                white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
            'num' => 'font-weight:bold; color:#1299DA',
            'const' => 'font-weight:bold',
            'str' => 'color:#111111',
            'note' => 'color:#1299DA',
            'ref' => 'color:#A0A0A0',
            'public' => 'color:blue',
            'protected' => 'color:#111',
            'private' => 'color:#478',
            'meta' => 'color:#B729D9',
            'key' => 'color:#212',
            'index' => 'color:#1200DA',
        ]);

        $handler = function ($vars) use ($cloner, $dumper) {
            if (!is_array($vars)) {
                $vars = [$vars];
            }

            foreach ($vars as $var) {
                $dumper->dump($cloner->cloneVar($var));
            }
        };

        call_user_func_array($handler, [$vars]);
    }
358813
public function initConfig() {
		if ( $this->confInitiated ) {
			return false;
		}

		global $kgReq;
		date_default_timezone_set( 'UTC' );

		// User agent (required to get data from wmf domains)
		ini_set( 'user_agent', HttpRequest::getUserAgent() );

		// Allow request parameter to toggle debug mode
		if ( $kgReq->hasKey( 'debug' ) ) {
			$isDebug = $kgReq->getFuzzyBool( 'debug' );

			// Set cookie to remember it in the next request.
			// Also makes it easier to debug by not having to append it to every
			// individual request.
			$kgReq->setCookie( 'debug', $isDebug ? '1' : null );
		} else {
			$isDebug = $kgReq->getCookie( 'debug' ) === '1';
		}

		$this->debugMode = $isDebug;

		$this->confInitiated = true;

		return true;
	}
300958
protected function _initZFDebug()
    {
        if ((APPLICATION_ENV === 'production') || (APPLICATION_ENV === 'acceptance') || Zend_Session::$_unitTestEnabled ) {
            // Never on on production systems
            return;
        }

        $debug = $this->getOption('zfdebug');
        if (! isset($debug['activate']) || ('1' !== $debug['activate'])) {
            // Only turn on when activated
            return;
        }

        # Instantiate the database adapter and cache
        $this->bootstrap('db');
        $db = $this->getPluginResource('db');

        $this->bootstrap('cache');
        $cache = $this->cache;

        $options = array(
            'plugins' => array('Variables',
                'Database' => array('adapter' => $db->getDbAdapter()),
                'File'     => array('basePath' => GEMS_ROOT_DIR),
                'Cache'    => array('backend' => $cache->getBackend()),
                'Exception')
        );

        $debugPlugin = new \ZFDebug_Controller_Plugin_Debug($options);

        $this->bootstrap('frontController');
        $frontController = $this->getResource('frontController');
        $frontController->registerPlugin($debugPlugin);
    }