Get the PHPDoc type name of a variable.

@param mixed $var
@param int $arrayLevel

@return string
330912
protected function getVarType($var, $arrayLevel = 0)
    {
        $phpType = gettype($var);
        switch ($phpType) {
            case 'boolean':
                $result = 'bool';
                break;
            case 'integer':
                $result = 'int';
                break;
            case 'double':
                $result = 'float';
                break;
            case 'string':
                $result = 'string';
                break;
            case 'array':
                if ($arrayLevel > 1) {
                    $result = 'array';
                } else {
                    $result = null;
                    $first = true;
                    foreach ($var as $item) {
                        $itemType = $this->getVarType($item, $arrayLevel + 1);
                        if ($first) {
                            $result = $itemType;
                            $commonObjectDescriptors = $this->getObjectDescriptors($item);
                            $first = false;
                        } else {
                            if ($result !== $itemType) {
                                $result = null;
                                if (empty($commonObjectDescriptors)) {
                                    break;
                                }
                                if (!empty($commonObjectDescriptors)) {
                                    $commonObjectDescriptors = array_intersect($commonObjectDescriptors, $this->getObjectDescriptors($item));
                                }
                            }
                        }
                    }
                    if ($result !== null) {
                        $result .= '[]';
                    } elseif (!empty($commonObjectDescriptors)) {
                        $result = array_shift($commonObjectDescriptors) . '[]';
                    } else {
                        $result = 'array';
                    }
                }
                break;
            case 'object':
                $result = get_class($var);
                if ($result === false) {
                    $result = 'mixed';
                } else {
                    if ($this->insideNamespace) {
                        $result = '\\' . $result;
                    }
                }
                break;
            case 'resource':
                $result = 'resource';
                break;
            case 'NULL':
                $result = 'null';
                break;
            case 'unknown type':
            default:
                $result = 'mixed';
                break;
        }

        return $result;
    }
1231882
public static function toString($numericLevel = self::NONE)
    {
        if (!is_numeric($numericLevel)) {
            throw new \InvalidArgumentException('The app type "' . $numericLevel . '" is not numeric.');
        }

        return static::nameOf($numericLevel);
    }
578363
public static function getType($var){
        if(is_int($var)){
            return self::T_INTEGER;
        }else if(is_string($var)){
            return self::T_STRING;
        }else if(is_float($var)){
            return self::T_FLOAT;
        }else if(is_bool($var)){
            return self::T_BOOLEAN;
        }else if(is_array($var)){
            return self::T_ARRAY;
        }else if(is_object($var)){
            return self::T_OBJECT;
        }else if(is_resource($var)){
            return self::T_RESOURCE;
        }else if($var === null){
            return self::T_NULL;
        }
        
        return self::T_UNKNOWN;
    }
748828
protected function varToString($var)
    {
        if (is_object($var)) {
            return get_class($var);
        }

        if (is_array($var)) {
            return 'Array';
        }

        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) gettype($var);
    }
999053
public static function getLevelName($level)
    {
        static $levels = [
            Logger::LEVEL_ERROR => 'error',
            Logger::LEVEL_WARNING => 'warning',
            Logger::LEVEL_INFO => 'info',
            Logger::LEVEL_TRACE => 'debug',
            Logger::LEVEL_PROFILE_BEGIN => 'debug',
            Logger::LEVEL_PROFILE_END => 'debug',
        ];

        return isset($levels[$level]) ? $levels[$level] : 'error';
    }
1362970
public function getName($arrayName = null)
    {
        if ($arrayName === null) {
            $arrayName = $this->arrayName;
        }

        if ($arrayName) {
            return $arrayName.'['.implode('][', HtmlHelper::nameToArray($this->fieldName)).']';
        }

        return $this->fieldName;
    }
1092585
public function getSimilar($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['tag'])) {
            $vars = array(
                'method' => 'tag.getsimilar',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);
            $similar = array();
            if ($call = $this->apiGetCall($vars)) {
                $i = 0;
                foreach ($call->similartags->tag as $tag) {
                    $similar[$i]['name'] = (string) $tag->name;
                    $similar[$i]['url'] = (string) $tag->url;
                    $similar[$i]['streamable'] = (string) $tag->streamable;
                    $i++;
                }
                return $similar;
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include tag variable in the call for this method');
        }
    }
891989
function getVariableName()
		{
			$arrBacktrace = debug_backtrace();

			//possible 'included' functions
			$arrInclude = array("include","include_once","require","require_once");

			//check for any included/required files. if found, get array of the last included file (they contain the right line numbers)
			$countBt = count($arrBacktrace);
			for($i = $countBt - 1 ; $i >= 0 ; $i--) {
				$arrCurrent = $arrBacktrace[$i];
				if(Arrays::exists("function", $arrCurrent) && (Arrays::inArray($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], "dbug")))) {
					continue;
				}

				$arrFile = $arrCurrent;

				break;
			}

			if(isset($arrFile)) {
				$arrLines = file($arrFile["file"]);
				$code = $arrLines[($arrFile["line"]-1)];

				//find call to dBug class
				preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);

				return $arrMatches[1];
			}
			return "";
		}
1212647
protected function elementName(string $var_name = ''): string
    {
        if ($this->action) {
            return $this->s::restActionFormElementName($var_name);
        } elseif ($this->cfg->Widget) {
            return $this->cfg->Widget->get_field_name($var_name);
        }
        $parts = $var_name // This is optional.
            ? preg_split('/(\[[^[\]]*\])/u', $var_name, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)
            : []; // An empty value could occur either way.

        if (!$parts) {
            return $this->c::slugToVar($this->cfg->slug);
        } elseif (mb_strpos($parts[0], '[') === 0) {
            return $this->c::slugToVar($this->cfg->slug).implode($parts);
        }
        return $this->c::slugToVar($this->cfg->slug).'['.$parts[0].']'.implode(array_slice($parts, 1));
    }
1165431
public static function getArrayVarId(
        PhpParser\Node\Expr $stmt,
        $this_class_name,
        FileSource $source = null
    ) {
        if ($stmt instanceof PhpParser\Node\Expr\Assign) {
            return self::getArrayVarId($stmt->var, $this_class_name, $source);
        }

        if ($stmt instanceof PhpParser\Node\Expr\ArrayDimFetch) {
            $root_var_id = self::getArrayVarId($stmt->var, $this_class_name, $source);

            $offset = null;

            if ($root_var_id) {
                if ($stmt->dim instanceof PhpParser\Node\Scalar\String_
                    || $stmt->dim instanceof PhpParser\Node\Scalar\LNumber
                ) {
                    $offset = $stmt->dim instanceof PhpParser\Node\Scalar\String_
                        ? '\'' . $stmt->dim->value . '\''
                        : $stmt->dim->value;
                } elseif ($stmt->dim instanceof PhpParser\Node\Expr\Variable
                    && is_string($stmt->dim->name)
                ) {
                    $offset = '$' . $stmt->dim->name;
                } elseif ($stmt->dim instanceof PhpParser\Node\Expr\ConstFetch) {
                    $offset = implode('\\', $stmt->dim->name->parts);
                } elseif (isset($stmt->dim->inferredType)) {
                    if ($stmt->dim->inferredType->isSingleStringLiteral()) {
                        $offset = '\'' . $stmt->dim->inferredType->getSingleStringLiteral()->value . '\'';
                    } elseif ($stmt->dim->inferredType->isSingleIntLiteral()) {
                        $offset = $stmt->dim->inferredType->getSingleIntLiteral()->value;
                    }
                } elseif ($stmt->dim instanceof PhpParser\Node\Expr\ClassConstFetch
                    && $stmt->dim->name instanceof PhpParser\Node\Identifier
                ) {
                    /** @var string|null */
                    $resolved_name = $stmt->dim->class->getAttribute('resolvedName');

                    if ($resolved_name) {
                        $offset = $resolved_name . '::' . $stmt->dim->name;
                    }
                }

                return $root_var_id && $offset !== null ? $root_var_id . '[' . $offset . ']' : null;
            }
        }

        if ($stmt instanceof PhpParser\Node\Expr\PropertyFetch) {
            $object_id = self::getArrayVarId($stmt->var, $this_class_name, $source);

            if (!$object_id) {
                return null;
            }

            if ($stmt->name instanceof PhpParser\Node\Identifier) {
                return $object_id . '->' . $stmt->name;
            } elseif (isset($stmt->name->inferredType) && $stmt->name->inferredType->isSingleStringLiteral()) {
                return $object_id . '->' . $stmt->name->inferredType->getSingleStringLiteral()->value;
            } else {
                return null;
            }
        }

        if ($stmt instanceof PhpParser\Node\Expr\ClassConstFetch
            && $stmt->name instanceof PhpParser\Node\Identifier
        ) {
            /** @var string|null */
            $resolved_name = $stmt->class->getAttribute('resolvedName');

            if ($resolved_name) {
                return $resolved_name . '::' . $stmt->name;
            }
        }

        if ($stmt instanceof PhpParser\Node\Expr\MethodCall
            && $stmt->name instanceof PhpParser\Node\Identifier
            && !$stmt->args
        ) {
            $config = \Psalm\Config::getInstance();

            if ($config->memoize_method_calls) {
                $lhs_var_name = self::getArrayVarId(
                    $stmt->var,
                    $this_class_name,
                    $source
                );

                if (!$lhs_var_name) {
                    return null;
                }

                return $lhs_var_name . '->' . strtolower($stmt->name->name) . '()';
            }
        }

        return self::getVarId($stmt, $this_class_name, $source);
    }
746108
private static function toJson(&$var, array $options, int $level = 0)
    {
        if (\is_bool($var) || null === $var || \is_int($var)) {
            return $var;

        }

        if (\is_float($var)) {
            return \is_finite($var)
                ? (\strpos($tmp = \json_encode($var), '.') ? $var : ['number' => "$tmp.0"])
                : ['type' => (string) $var];

        }

        if (\is_string($var)) {
            return self::encodeString($var, $options[self::TRUNCATE]);
        }

        if (\is_array($var)) {
            static $marker;
            if ($marker === null) {
                $marker = \uniqid("\x00", true);
            }
            if (isset($var[$marker]) || $level >= $options[self::DEPTH]) {
                return [null];
            }
            $res = [];
            $var[$marker] = true;
            foreach ($var as $k => & $v) {
                if ($k !== $marker) {
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $res[] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1)];
                }
            }
            unset($var[$marker]);

            return $res;
        }

        if (\is_object($var)) {
            $obj = &self::$liveStorage[\spl_object_hash($var)];
            if ($obj && $obj['level'] <= $level) {
                return ['object' => $obj['id']];
            }

            $editorInfo = null;
            if ($options[self::LOCATION] & self::LOCATION_CLASS) {
                $rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
                $editor = $rc->getFileName() ? Helpers::editorUri($rc->getFileName(), $rc->getStartLine()) : null;
                $editorInfo = $editor ? [
                    'file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor,
                ] : null;
            }
            static $counter = 1;
            $obj = $obj ?: [
                'id' => self::$livePrefix . '0' . $counter++, // differentiate from resources
                'name' => Helpers::getClass($var),
                'editor' => $editorInfo,
                'level' => $level,
                'object' => $var,
            ];

            if ($level < $options[self::DEPTH] || !$options[self::DEPTH]) {
                $obj['level'] = $level;
                $obj['items'] = [];

                foreach (self::exportObject($var, $options[self::OBJECT_EXPORTERS],
                    $options[self::DEBUGINFO]) as $k => $v) {
                    $vis = 0;
                    if (isset($k[0]) && $k[0] === "\x00") {
                        $vis = $k[1] === '*' ? 1 : 2;
                        $k = \substr($k, \strrpos($k, "\x00") + 1);
                    }
                    $hide = \is_string($k) && isset($options[self::KEYS_TO_HIDE][\strtolower($k)]);
                    $k = \is_int($k) || \preg_match('#^\w{1,50}\z#', $k) ? $k : '"' . self::encodeString($k,
                            $options[self::TRUNCATE]) . '"';
                    $obj['items'][] = [$k, $hide ? self::HIDDEN_VALUE : self::toJson($v, $options, $level + 1), $vis];
                }
            }

            return ['object' => $obj['id']];
        }

        if (\is_resource($var)) {
            $obj = &self::$liveStorage[(string) $var];
            if (!$obj) {
                $type = \get_resource_type($var);
                $obj = ['id' => self::$livePrefix . (int) $var, 'name' => $type . ' resource'];
                if (isset(self::$resources[$type])) {
                    foreach ((self::$resources[$type])($var) as $k => $v) {
                        $obj['items'][] = [$k, self::toJson($v, $options, $level + 1)];
                    }
                }
            }

            return ['resource' => $obj['id']];
        }

        return ['type' => 'unknown type'];
    }
566743
public static function varInfo($var, $type = NULL) {
    if ($var === NULL) return 'NULL';
    
    $type = self::getType($var);
    
    if ($type == 'string') {
      return sprintf(
        'string(%d) "%s"',
        mb_strlen($var),
        (string) $var
      );
    } elseif ($type == 'array') {
      return sprintf('array(%s)', 
        A::implode($var, ', ',function ($item) {
          return Util::varInfo($item);
        })
      );
    } elseif ($var instanceof Info) {
      return $var->getVarInfo();
    } elseif ($var instanceof \stdClass) {
      return '(object) '.json_encode($var);
    } elseif (is_object($var)) {
      return sprintf('%s(%s)', method_exists($var, '__toString') ? $var->__toString() : 'not converted to string', self::typeInfo($var));
    } elseif (is_bool($var)) {
      return sprintf('boolean(%s)',$var ? 'true' : 'false');
    } else {
      return sprintf('%s(%s)', self::typeInfo($var), (string) $var);
    }
  }
266656
public function header(array $var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['header'] = $var;
            $this->content($content);
        }

        return $content['header'];
    }
587978
public static function getLevelName($level)
    {
        if (!isset(static::$levels[$level])) {
            throw new \InvalidArgumentException('Level "' . $level . '" is not defined, use one of: ' . implode(', ', array_keys(static::$levels)));
        }

        return static::$levels[$level];
    }
1006765
public static function getIntArray($name,$vartype=''){
		$i=self::getVar($name,array(),$vartype);
		if(!is_array($i)){
			return array();
			}
		$r=array();
		foreach($i as $elem){
			$r[]=(int)$elem;
			}
		return $r;
		}
1057466
public function getLevelName()
    {
        switch ($this->getLevel()) {
            case self::LEVEL_INFO:
                return 'Info';

            case self::LEVEL_WARNING:
                return 'Warning';

            case self::LEVEL_ERROR:
                return 'Error';

            default:
                throw new \UnexpectedValueException('Level was set to ' . $this->getLevel());
        }
    }
284792
public static function getLevelName(int $level): string
    {
        if (!isset(static::$levels[$level])) {
            throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels)));
        }

        return static::$levels[$level];
    }