ASCII printable that allows newline and (default) carriage return.

@param mixed $var
Gets stringified.
@param bool $noCarriageReturn

@return string

@throws \RuntimeException
If native regex function fails.
972289
public function asciiMultiLine($var, $noCarriageReturn = false) : string
    {
        // Remove lower ASCII except newline \x0A and CR \x0D,
        // and remove DEL and upper range.
        $s = preg_replace(
            !$noCarriageReturn ? '/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/' : '/[\x00-\x09\x0B-\x1F\x7F]/',
            '',
            filter_var('' . $var, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH)
        );
        // preg_replace() emits old-school warning on error; we want exception.
        if (!$s && $s === null) {
            throw new \RuntimeException('PHP native regex function failed.');
        }
        return $s;
    }
38433
public static function returnStdObject(&$var)
    {
        // check if $var is already a standard object
        if (self::isInstanceOf($var, AbstractStdObject::class)) {
            return $var;
        }

        // try to map $var to a standard object
        if (self::isString($var)) {
            return new StringObject($var);
        } else {
            if (self::isArray($var)) {
                return new ArrayObject($var);
            }
        }

        // return value as StdObjectWrapper
        return new self($var);
    }
1340161
static function dump($var, $trace = true)
    {
        $d = Debug::getInstance();

        if ($d->level < 1) {
            return;
        }

        if ($d->terminal) {
            $c = $d->console;

            if (!is_array($var)) {
                $c->writeln(print_r($var, 1), 'blue');
            } else {
                $lines = explode("\n", print_r($var, 1));
                foreach ($lines as $line) {
                    preg_match_all('|(.*)\[(.*)\] \=\>(.*)|', $line, $m);
                    
                    if (!isset($m[0][0])) {
                        $c->writeln($line);
                    } else {
                        $c->write($m[1][0] . '[', 'blue');
                        $c->write($m[2][0], 'light_red');
                        $c->write('] =>', 'blue');
                        $c->writeln($m[3][0], 'blue');
                    }
                }
            }

        } else {
            $txt = preg_replace('/\[(.*)\]/u', '[<span style="color:#d00">$1</span>]', print_r($var, 1));
            echo '<pre style="color:blue">' . $txt . "</pre>";
        }

        if ($trace)
            $d->_trace();
    }
1244435
protected function varToString($var)
    {
        if (is_object($var)) {
            return sprintf('Object(%s)', get_class($var));
        }

        if (is_array($var)) {
            $a = array();
            foreach ($var as $k => $v) {
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
            }

            return sprintf("Array(%s)", implode(', ', $a));
        }

        if (is_resource($var)) {
            return sprintf('Resource(%s)', get_resource_type($var));
        }

        if (null === $var) {
            return 'null';
        }

        if (false === $var) {
            return 'false';
        }

        if (true === $var) {
            return 'true';
        }

        return (string) "'$var'";
    }
534075
public function returnRmLine($noLine)
    {
        if ($noLine < 1 || $noLine <= (sizeof($this->getLines()) + 1)) {
            $idTable = $this->getId();
            $params['noLine'] = $noLine;
            $params['maxLine'] = sizeof($this->getLines()) + 1;
            return self::formatRetour($idTable, $idTable, 'rmLineUpdate', $params);
        }
        return false;
    }
1072435
public static function dump($var, $echo = true)
    {
        ob_start();
        var_dump($var);

        $output = ob_get_clean();
        $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);

        if (PHP_SAPI == "cli") {
            $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
        } else {
            $output = "<pre>" . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
        }

        if ($echo) echo($output);

        return $output;
    }
602595
public static function ee($var) {
        if(!Config::$o->debug) return;
        $br = '<pre>';
        //$hr = '<hr>';
        if (Config::$o->sapi=='cli') {
            $br = "\n";
            //$hr = "\n----------------------\n";
        }
        echo $br;
        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        self::ex($var,true,'ee');
        echo $br;
    }
1192836
public function escape($var)
	{
		if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities')))
		{
			return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset);
		}

		return call_user_func($this->_escape, $var);
	}
325709
public static function vd($var, bool $dump = true, bool $stop = true, int $obLevel = 0): void
    {
        if ($stop) {
            while (ob_get_level() > $obLevel) {
                ob_end_clean();
            }
        }
        
        ob_start();
        if (empty($_SERVER['DOCUMENT_ROOT'])) {
            $dump ? var_dump($var) : print_r($var);
            echo PHP_EOL . str_replace("=>\n", '  =>', ob_get_clean());
        } else {
            echo '<pre>';
            $dump ? var_dump($var) : print_r($var);
            echo htmlspecialchars(str_replace("=>\n", '  =>', ob_get_clean()));
            echo '</pre>';
        }
        
        if ($stop) {
            throw new DebugStopExecutionException();
        }
    }
1333095
public static function dumpAsString($variable, $indentLevel = 0) {
        if (is_bool($variable)) {
            $result = $variable ? "true" : "false";
        } elseif (is_null($variable)) {
            $result = "null";
        } elseif (is_array($variable)) {
            $result = 'array (';

            foreach($variable as $key=>$item) {
                $result .= "\n". str_repeat(" ", ($indentLevel+1)*4);
                $result .= self::dumpAsString($key, $indentLevel+1);
                $result .= ' => ';
                $result .= self::dumpAsString($item, $indentLevel+1).',';
            }

            $result .= "\n".str_repeat(" ", ($indentLevel)*4).')';
        } elseif(is_string($variable) && (isset($variable[0]) && $variable[0] != '$')) {
            $result = '"'. (strpos($variable, '$__lv') === false ? str_replace('"', '\"', $variable) : $variable) .'"';
        } else {
            $result = $variable;
        }

        return $result;
    }
1242398
private function extractReturnType(): void
  {
    // Return immediately if designation type is not appropriate for this method.
    if (!in_array($this->designationType, ['function', 'singleton0', 'singleton1'])) return;

    $key = array_search('begin', $this->routineSourceCodeLines);

    if ($key!==false)
    {
      for ($i = 1; $i<$key; $i++)
      {
        $n = preg_match('/^\s*--\s+return:\s*((\w|\|)+)\s*$/',
                        $this->routineSourceCodeLines[$key - $i],
                        $matches);
        if ($n==1)
        {
          $this->returnType = $matches[1];

          break;
        }
      }
    }

    if ($this->returnType===null)
    {
      $this->returnType = 'mixed';

      $this->io->logNote('Unable to find the return type of stored routine');
    }
  }
24322
private static function readRaw($realPath)
    {
        $content = @file_get_contents($realPath);

        if (false === $content) {
            $error = error_get_last();

            throw new \RuntimeException(sprintf(
                'Failed to read content from "%s".%s',
                $realPath,
                $error ? ' '.$error['message'] : ''
            ));
        }

        return $content;
    }
861487
public function toUpperCaseLast($var)
    {
        $v = '' . $var;
        $len = $this->strlen($var);
        if (!$len) {
            return '';
        }
        if (static::$nativeSupport['mbstring']) {
            if ($len > 1) {
                return mb_substr($v, 0, $len - 2) . mb_strtoupper(mb_substr($v, $len - 2));
            }
            return mb_strtoupper($v);
        }
        return $v;
    }
976508
public function setExpectReturn($expecting, Variable $expectingVariable = null)
    {
        $this->expecting = $expecting;
        $this->expectingVariable = $expectingVariable;
    }
605789
public function getString($variable, $default = '', $allowed = "", $escape = true)
    {
        return (string) strip_tags($this->getHtml($variable, $default, $allowed, $escape));
    }
77829
public static function print_r($var, $continue = false, $hide = false, $return = false)
    {
        return self::it($var, AbstractDumper::PRINT_R, $continue, $hide, $return);
    }
1038850
public function toUpperCaseFirst($var)
    {
        $v = '' . $var;
        $len = $this->strlen($var);
        if (!$len) {
            return '';
        }
        if (static::$nativeSupport['mbstring']) {
            if ($len > 1) {
                return mb_strtoupper(mb_substr($v, 0, 1)) . mb_substr($v, 1);
            }
            return mb_strtoupper($v);
        }
        return $v;
    }