Summarises an array

@param array $var
@return string
432108
private static function summariseArray(array $var, $depth = 1)
    {
        static $depth = 1;

        if ($depth == 2) {
            return 'Array('.count($var).')';
        }
        elseif (($count = count($var)) > 0) {

            $key = array_keys($var);
            $key = $key[0];
            $value = array_values($var);
            $value = $value[0];

            $mask = 'Array(%1$s){';
            if (is_string($key)) {
                $mask .= '%2$s: ';
            }
            $mask .= '%3$s}';

            $depth = 2;
            $return = sprintf(
                $mask,
                $count,
                $key,
                self::summarise($value)
            );
            $depth = 1;
            return $return;
        }

        return 'Array(0){}';
    }
125551
public function toBody($var)
    {
        $results = '';

        foreach ($this->getParser()->toArray() as $name => $types) {
            if (in_array($name, $this->ignores)) {
                continue;
            }

            $results .= "\t\t\t\t\t".'<td>{!! $'.$var.'->'.$name.' !!}</td>'.PHP_EOL;
        }

        return $results;
    }
155971
protected function _parseVar() {
        $this->_content = preg_replace('`' . preg_quote($this->markup['vars'][0]) . $this->_space . '([\\\[\]\(\)A-Za-z0-9\$\'"_\>\+\-]+)' . $this->_space . preg_quote($this->markup['vars'][1]) . '`ism', '<?php echo ($1); ?>', $this->_content);
    }
328024
protected function filter($var)
    {
        switch (true) {
            case strpos(trim($var), "#") === 0:
                return null;
            case strpos($var, "=") !== false:
                list($key, $val) = array_map("trim", explode("=", $var ,2));
                return array($key, $val);
            default:
                return null;
        }
    }
480772
protected function handleSemanticsVar($var)
    {
        list($var) = array_map("trim", explode("#", $var));
        switch (true) {
            case $var === "":
                return $var;
            case is_numeric($var):
                return $var;
            default:
                $beginStr = substr($var, 0, 1);
                if (in_array($beginStr, array('\'','"')) && $beginStr == substr($var, -1, 1)) {
                    return substr($var, 1, -1);
                }
                return $var;
        }
    }
1115088
public function renderSummary()
	{
		if(($count=$this->dataProvider->getItemCount())<=0)
			return;

		echo CHtml::openTag($this->summaryTagName, array('class'=>$this->summaryCssClass));
		if($this->enablePagination)
		{
			$pagination=$this->dataProvider->getPagination();
			$total=$this->dataProvider->getTotalItemCount();
			$start=$pagination->currentPage*$pagination->pageSize+1;
			$end=$start+$count-1;
			if($end>$total)
			{
				$end=$total;
				$start=$end-$count+1;
			}
			if(($summaryText=$this->summaryText)===null)
				$summaryText=Yii::t('zii','Displaying {start}-{end} of 1 result.|Displaying {start}-{end} of {count} results.',$total);
			echo strtr($summaryText,array(
				'{start}'=>$start,
				'{end}'=>$end,
				'{count}'=>$total,
				'{page}'=>$pagination->currentPage+1,
				'{pages}'=>$pagination->pageCount,
			));
		}
		else
		{
			if(($summaryText=$this->summaryText)===null)
				$summaryText=Yii::t('zii','Total 1 result.|Total {count} results.',$count);
			echo strtr($summaryText,array(
				'{count}'=>$count,
				'{start}'=>1,
				'{end}'=>$count,
				'{page}'=>1,
				'{pages}'=>1,
			));
		}
		echo CHtml::closeTag($this->summaryTagName);
	}
146531
private function _printVar($var)
    {
        if (is_string($var)) {
            $search = array("\x00", "\x0a", "\x0d", "\x1a", "\x09");
            $replace = array('\0', '\n', '\r', '\Z', '\t');

            return ('"'.str_replace($search, $replace, $var).'"');
        } elseif (is_bool($var)) {
            if ($var) {
                return ('true');
            } else {
                return ('false');
            }
        } elseif (is_array($var)) {
            $strResult = 'array( ';
            $strComma = '';
            foreach ($var as $key=>$val) {
                $strResult .= $strComma.$this->_printVar($key).' => '.$this->_printVar($val);
                $strComma = ', ';
            }
            $strResult .= ' )';

            return ($strResult);
        }
        // anything else, just let php try to print it
        return (var_export($var, true));
    }
990067
private static function groupBy($array) {
        $origin = $array;
        if(count($array) > 1) {
            self::calls(array_shift($array));
        }
        return ' GROUP BY ' . $origin[0] . (intval($origin[1]) > 0 ? ', ' . $origin[1] : '');
    }
647562
protected static function var_dump_to_string($var) {
		if(is_string($var))
			return $var;

		ob_start();
		var_dump($var);
		if(ob_get_length() > 1024)
			$str = '['.(is_object($var) ? get_class($var):gettype($var)).' - too big to display]';
		else
			$str = ob_get_contents();
		ob_end_clean();
		return $str;
	}
859134
public function sanitize($var)
	{
		global $smcFunc;

		if (is_array($var))
		{
			foreach ($var as $k => $v)
				$var[$k] = $this->sanitize($v);

			return $var;
		}

		else
		{
			$var = (string) $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($var), ENT_QUOTES);

			if (ctype_digit($var))
				$var = (int) $var;

			if (empty($var))
				$var = false;
		}

		return $var;
	}
423376
public static function getArray($var)
    {
        if (is_null($var) || empty($var)) {
            return [];
        }

        foreach ($var as $value) {
            if ((gettype($value) == 'object')
                && (get_class($value) == 'SimpleXMLElement')
            ) {
                return (array) $var;
            } elseif (!is_array($value)) {
                return [$var];
            }
        }

        return $var;
    }
392238
private function sanitizeParam($var): array
    {
        if (is_object($var)) {
            if ($var instanceof QueryInterface) {
                $query = [
                    'querystring' => $var->getStatement(),
                    'language' => $var->getLanguage(),
                ];
                if ($var instanceof Query) {
                    $query['limit'] = $var->getLimit();
                    $query['offset'] = $var->getOffset();
                }

                return $query;
            }

            return [sprintf('Object(%s)', get_class($var)), false];
        }

        if (is_array($var)) {
            $a = [];
            $original = true;
            foreach ($var as $k => $v) {
                list($value, $orig) = $this->sanitizeParam($v);
                $original = $original && $orig;
                $a[$k] = $value;
            }

            return [$a, $original];
        }

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

        return [$var, true];
    }
524103
public function dump_it($var) {
		$adapter = '\alkemann\hl\debug\util\adapters\\'. $this->options['mode'];
        if (is_array($var))
            return $adapter::dump_array($var, $this);
        elseif (is_object($var))
            return $adapter::dump_object($var, $this);
        else
            return $adapter::dump_other($var);
    }
503605
protected static function export(array $value)
	{
		$pairs = [];
		foreach ($value as $k => $v)
		{
			$pairs[] = var_export($k, true) . '=>' . var_export($v, true);
		}

		return '[' . implode(',', $pairs) . ']';
	}
584333
public static function varToText($var) {
				
		$type = gettype($var);
		$text = is_null($type) ? 'NULL' : $type . ':';
		
		switch ($type) {

			case 'boolean':
				$text .= $var ? 'TRUE' : 'FALSE';
				break;

			default:
				$text .= $var;
				break;
				
			case 'array':
				$parts = array();
				foreach ($var as $k=>$v) {
					$parts[] = $k . '=>' . self::varToText($v);
				}
				$text .= 'array:[' . implode(',', $parts) . ']';
				break;
				
			case 'object':
				$text .= get_class($var);
				break;
				
			case 'NULL':
				break;

		}
					
		return $text;
		
	}
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'";
    }
234994
protected function defineParam($var, $default = null)
    {
        $values = ['value' => null];
        if (!is_array($default) || !array_key_exists('value', $default)) {
            $values['value'] = $default;
        } else {
            $values = $default;
        }

        if (isset($this->defaultParams[$var])) {
            $values = array_merge($values, $this->defaultParams[$var]);
        }

        $this->defaultParams[$var] = $values;

        return $this;
    }