Adds string to output string array with "tab" prefix

@var string $str
496113
public function addStr($str)
    {
        $str = str_replace($this->tab, '', $str);
        $this->outputStringArray[] = str_repeat($this->tab, $this->tabLevel) . $str;
    }
878876
static function markString(string $text, int $position, int $length, array $mark) : string
    {
        $text = substr_replace($text, $mark[0], $position, 0);
        $text = substr_replace($text, $mark[1], $position + $length + strlen($mark[0]), 0);

        return $text;
    }
1251863
protected function modifyHost(string $str): string
    {
        return (string) $this->filterHost($str)->append($this->label);
    }
885138
public static function nailDecode(String $str) : String
    {
        $str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);

        return $str;
    }
334487
public void add(String str) {
        String[] tmp;

        if (size == data.length) {
            tmp = new String[data.length + GROW];
            System.arraycopy(data, 0, tmp, 0, data.length);
            data = tmp;
        }
        data[size] = str;
        size++;
    }
32399
public function add($str)
    {
        $i = count($this->values);
        $this->values[$i] = $str;
        return $i;
    }
1222732
public void append(final String str) {
        final String s = str != null ? str : "null";
        final int strlen = s.length();
        final int newlen = this.len + strlen;
        if (newlen > this.array.length) {
            expand(newlen);
        }
        s.getChars(0, strlen, this.array, this.len);
        this.len = newlen;
    }
1275421
public static function webappPrefixTooShort(string $str)
    {
        $length = strlen($str);
        if ($length === 0) {
            return new self(sprintf(
                'The WebApp Prefix must be at least 3 characters. You supplied an empty Prefix.'
            ));
        } else {
            return new self(sprintf(
                'The WebApp Prefix must be at least 3 characters. You supplied a %s character Prefix: %s',
                $length,
                $str
            ));
        }
    }
700554
function loadStrings($strings) {
        // Load some commonly used strings
        if (get_string_manager()->string_exists($this->title, 'tool_xmldb')) {
            $this->str['title'] = get_string($this->title, 'tool_xmldb');
        } else {
            $this->str['title'] = $this->title;
        }

        // Now process the $strings array loading it in the $str atribute
        if ($strings) {
            foreach ($strings as $key => $module) {
                $this->str[$key] = get_string($key, $module);
            }
        }
    }
1290923
private function string(string $str): void
    {
        $this->sql = $str;
        $this->prepare = $str;
        $this->param = [];
    }
926733
protected function modifyHost(string $str): string
    {
        return (string) $this->filterHost($str, $this->resolver)->withRegisterableDomain($this->label);
    }
821856
protected function edebug($str)
    {
        switch ($this->Debugoutput) {
            case 'error_log':
                //Don't output, just log
                error_log($str);
                break;
            case 'html':
                //Cleans up output a bit for a better looking, HTML-safe output
                echo htmlentities(
                    preg_replace('/[\r\n]+/', '', $str),
                    ENT_QUOTES,
                    'UTF-8'
                )
                . "<br>\n";
                break;
            case 'echo':
            default:
                echo gmdate('Y-m-d H:i:s')."\t".trim($str)."\n";
        }
    }
336227
public static function trim(&$str='') {
		if (\is_array($str)) {
			foreach ($str as $k=>$v) {
				static::trim($str[$k]);
			}
		}
		else {
			cast::string($str, true);
			$str = \preg_replace('/(^\s+|\s+$)/u', '', $str);
		}
	}
156037
private function debug($str)
        {
            $this->log($str);
            if ($this->debug == true) {
                if (PHP_SAPI != 'cli') {
                    $str = '<br/><pre>' . htmlspecialchars($str) . '</pre>';
                }
                echo "\n" . $str;
            }
        }
1089915
public static function transform($str, $prefix='$')
    {
        $len = strlen($str);
        $state = self::ST_WHITE;
        $result = '';
        $i = 0;
        $inString = false;
        $backslashed = false;
        $instanceof = false;
        $eval = false;


        for ($i = 0; $i <= $len; $i++) {
            if ($i == $len) $c = "\0";
            else $c = $str[$i];

            switch ($state) {

                // after whitespace a variable-variable may start, ${var} → $ctx->{$ctx->var}
                case self::ST_WHITE:
                    if ($c === '$' && $i+1 < $len && $str[$i+1] === '{')
                    {
                        $result .= $prefix;
                        $state = self::ST_NONE;
                        break;
                    }
                    /* NO BREAK - ST_WHITE is almost the same as ST_NONE */

                // no specific state defined, just eat char and see what to do with it.
                case self::ST_NONE:
                    // begin of eval without {
                    if ($c === '$' && $i+1 < $len && self::isAlpha($str[$i+1])) {
                        $state = self::ST_EVAL;
                        $mark = $i+1;
                        $result .= $prefix.'{';
                    }
                    elseif (self::isDigit($c))
                    {
                        $state = self::ST_NUM;
                        $mark = $i;
                    }
                    // that an alphabetic char, then it should be the begining
                    // of a var or static
                    // && !self::isDigit($c) checked earlier
                    elseif (self::isVarNameChar($c)) {
                        $state = self::ST_VAR;
                        $mark = $i;
                    }
                    // begining of double quoted string
                    elseif ($c === '"') {
                        $state = self::ST_ESTR;
                        $mark = $i;
                        $inString = true;
                    }
                    // begining of single quoted string
                    elseif ($c === '\'') {
                        $state = self::ST_STR;
                        $mark = $i;
                        $inString = true;
                    }
                    // closing a method, an array access or an evaluation
                    elseif ($c === ')' || $c === ']' || $c === '}') {
                        $result .= $c;
                        // if next char is dot then an object member must
                        // follow
                        if ($i+1 < $len && $str[$i+1] === '.') {
                            $result .= '->';
                            $state = self::ST_MEMBER;
                            $mark = $i+2;
                            $i+=2;
                        }
                    }
                    // @ is an access to some defined variable
                    elseif ($c === '@') {
                        $state = self::ST_DEFINE;
                        $mark = $i+1;
                    }
                    elseif (ctype_space($c)) {
                        $state = self::ST_WHITE;
                        $result .= $c;
                    }
                    // character we don't mind about
                    else {
                        $result .= $c;
                    }
                    break;

                // $xxx
                case self::ST_EVAL:
                    if (!self::isVarNameChar($c)) {
                        $result .= $prefix . substr($str, $mark, $i-$mark);
                        $result .= '}';
                        $state = self::ST_NONE;
                    }
                    break;

                // single quoted string
                case self::ST_STR:
                    if ($c === '\\') {
                        $backslashed = true;
                    } elseif ($backslashed) {
                        $backslashed = false;
                    }
                    // end of string, back to none state
                    elseif ($c === '\'') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $inString = false;
                        $state = self::ST_NONE;
                    }
                    break;

                // double quoted string
                case self::ST_ESTR:
                    if ($c === '\\') {
                        $backslashed = true;
                    } elseif ($backslashed) {
                        $backslashed = false;
                    }
                    // end of string, back to none state
                    elseif ($c === '"') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $inString = false;
                        $state = self::ST_NONE;
                    }
                    // instring interpolation, search } and transform the
                    // interpollation to insert it into the string
                    elseif ($c === '$' && $i+1 < $len && $str[$i+1] === '{') {
                        $result .= substr($str, $mark, $i-$mark) . '{';

                        $sub = 0;
                        for ($j = $i; $j<$len; $j++) {
                            if ($str[$j] === '{') {
                                $sub++;
                            } elseif ($str[$j] === '}' && (--$sub) == 0) {
                                $part = substr($str, $i+2, $j-$i-2);
                                $result .= self::transform($part, $prefix);
                                $i = $j;
                                $mark = $i;
                            }
                        }
                    }
                    break;

                // var state
                case self::ST_VAR:
                    if (self::isVarNameChar($c)) {
                    }
                    // end of var, begin of member (method or var)
                    elseif ($c === '.') {
                        $result .= $prefix . substr($str, $mark, $i-$mark);
                        $result .= '->';
                        $state = self::ST_MEMBER;
                        $mark = $i+1;
                    }
                    // static call, the var is a class name
                    elseif ($c === ':' && $i+1 < $len && $str[$i+1] === ':') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $mark = $i+1;
                        $i++;
                        $state = self::ST_STATIC;
                        break;
                    }
                    // function invocation, the var is a function name
                    elseif ($c === '(') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $state = self::ST_NONE;
                    }
                    // array index, the var is done
                    elseif ($c === '[') {
                        if ($str[$mark]==='_') { // superglobal?
                            $result .= '$' . substr($str, $mark, $i-$mark+1);
                        } else {
                            $result .= $prefix . substr($str, $mark, $i-$mark+1);
                        }
                        $state = self::ST_NONE;
                    }
                    // end of var with non-var-name character, handle keywords
                    // and populate the var name
                    else {
                        $var = substr($str, $mark, $i-$mark);
                        $low = strtolower($var);
                        // boolean and null
                        if ($low === 'true' || $low === 'false' || $low === 'null') {
                            $result .= $var;
                        }
                        // lt, gt, ge, eq, ...
                        elseif (array_key_exists($low, self::$TranslationTable)) {
                            $result .= self::$TranslationTable[$low];
                        }
                        // instanceof keyword
                        elseif ($low === 'instanceof') {
                            $result .= $var;
                            $instanceof = true;
                        }
                        // previous was instanceof
                        elseif ($instanceof) {
                            // last was instanceof, this var is a class name
                            $result .= $var;
                            $instanceof = false;
                        }
                        // regular variable
                        else {
                            $result .= $prefix . $var;
                        }
                        $i--;
                        $state = self::ST_NONE;
                    }
                    break;

                // object member
                case self::ST_MEMBER:
                    if (self::isVarNameChar($c)) {
                    }
                    // eval mode ${foo}
                    elseif ($c === '$' && ($i >= $len-2 || $str[$i+1] !== '{')) {
                        $result .= '{' . $prefix;
                        $mark++;
                        $eval = true;
                    }
                    // x.${foo} x->{foo}
                    elseif ($c === '$') {
                        $mark++;
                    }
                    // end of var member var, begin of new member
                    elseif ($c === '.') {
                        $result .= substr($str, $mark, $i-$mark);
                        if ($eval) { $result .='}'; $eval = false; }
                        $result .= '->';
                        $mark = $i+1;
                        $state = self::ST_MEMBER;
                    }
                    // begin of static access
                    elseif ($c === ':') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        if ($eval) { $result .='}'; $eval = false; }
                        $state = self::ST_STATIC;
                        break;
                    }
                    // the member is a method or an array
                    elseif ($c === '(' || $c === '[') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        if ($eval) { $result .='}'; $eval = false; }
                        $state = self::ST_NONE;
                    }
                    // regular end of member, it is a var
                    else {
                        $var = substr($str, $mark, $i-$mark);
                        if ($var !== '' && !preg_match('/^[a-z][a-z0-9_\x7f-\xff]*$/i',$var)) {
                            throw new PHPTAL_ParserException("Invalid field name '$var' in expression php:$str");
                        }
                        $result .= $var;
                        if ($eval) { $result .='}'; $eval = false; }
                        $state = self::ST_NONE;
                        $i--;
                    }
                    break;

                // wait for separator
                case self::ST_DEFINE:
                    if (self::isVarNameChar($c)) {
                    } else {
                        $state = self::ST_NONE;
                        $result .= substr($str, $mark, $i-$mark);
                        $i--;
                    }
                    break;

                // static call, can be const, static var, static method
                // Klass::$static
                // Klass::const
                // Kclass::staticMethod()
                //
                case self::ST_STATIC:
                    if (self::isVarNameChar($c)) {
                    }
                    // static var
                    elseif ($c === '$') {
                    }
                    // end of static var which is an object and begin of member
                    elseif ($c === '.') {
                        $result .= substr($str, $mark, $i-$mark);
                        $result .= '->';
                        $mark = $i+1;
                        $state = self::ST_MEMBER;
                    }
                    // end of static var which is a class name
                    elseif ($c === ':') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $state = self::ST_STATIC;
                        break;
                    }
                    // static method or array
                    elseif ($c === '(' || $c === '[') {
                        $result .= substr($str, $mark, $i-$mark+1);
                        $state = self::ST_NONE;
                    }
                    // end of static var or const
                    else {
                        $result .= substr($str, $mark, $i-$mark);
                        $state = self::ST_NONE;
                        $i--;
                    }
                    break;

                // numeric value
                case self::ST_NUM:
                    if (!self::isDigitCompound($c)) {
                        $var = substr($str, $mark, $i-$mark);

                        if (self::isAlpha($c) || $c === '_') {
                            throw new PHPTAL_ParserException("Syntax error in number '$var$c' in expression php:$str");
                        }
                        if (!is_numeric($var)) {
                            throw new PHPTAL_ParserException("Syntax error in number '$var' in expression php:$str");
                        }

                        $result .= $var;
                        $state = self::ST_NONE;
                        $i--;
                    }
                    break;
            }
        }

        $result = trim($result);

        // CodeWriter doesn't like expressions that look like blocks
        if ($result[strlen($result)-1] === '}') return '('.$result.')';

        return $result;
    }
391022
protected function modifyHost(string $str): string
    {
        return (string) $this->filterHost($str)->withoutLabels($this->keys);
    }
1085838
static function escape_string($str)
    {
        if (is_array($str) && count($str) > 1) {
            foreach ($str as $idx => $val)
                $str[$idx] = self::escape_string($val);

            return '[' . implode(',', $str) . ']';
        }
        else if (is_array($str)) {
            $str = array_pop($str);
        }

        // multi-line string
        if (preg_match('/[\r\n\0]/', $str)) {
            return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str));
        }
        // quoted-string
        else {
            return '"' . addcslashes($str, '\\"') . '"';
        }
    }