Finds the location where dump was called.

@return array|null [file, line, code]
771392
private static function findLocation(): ?array
    {
        foreach (\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) {
            if (isset($item['class']) && $item['class'] === __CLASS__) {
                $location = $item;
                continue;
            }

            if (isset($item['function'])) {
                try {
                    $reflection = isset($item['class'])
                        ? new \ReflectionMethod($item['class'], $item['function'])
                        : new \ReflectionFunction($item['function']);
                    if ($reflection->isInternal() || \preg_match('#\s@tracySkipLocation\s#',
                            (string) $reflection->getDocComment())) {
                        $location = $item;
                        continue;
                    }
                } catch (\ReflectionException $e) {
                }
            }
            break;
        }

        if (isset($location['file'], $location['line']) && \is_file($location['file'])) {
            $lines = \file($location['file']);
            $line = $lines[$location['line'] - 1];

            return [
                $location['file'],
                $location['line'],
                \trim(\preg_match('#\w*dump(er::\w+)?\(.*\)#i', $line, $m) ? $m[0] : $line),
            ];
        }

        return null;
    }
1094161
protected function dump() {
    $str = '';
    foreach (array_values($this->loadedObjects) as $curObject) {
      $str .= $curObject->dump();
    }
    return $str;
  }
333774
private function findPhpDocumentorPath()
    {
        $phpDocumentorPath = null;
        $directories = ['phpDocumentor', 'phpdocumentor'];
        foreach ($directories as $directory) {
            foreach (Phing::explodeIncludePath() as $path) {
                $testPhpDocumentorPath = $path . DIRECTORY_SEPARATOR . $directory . DIRECTORY_SEPARATOR . 'src';
                if (file_exists($testPhpDocumentorPath)) {
                    $phpDocumentorPath = $testPhpDocumentorPath;
                }
            }
        }

        return $phpDocumentorPath;
    }
1351416
public static function dump()
    {
        if (!self::$enabled_mode) {
            return 0;
        }

        Utils::normalizeAliases(self::$aliases);

        $args = \func_get_args();

        $call_info = self::getCallInfo(self::$aliases, \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), \count($args));

        $statics = self::getStatics();

        if (\in_array('~', $call_info['modifiers'], true)) {
            $statics['enabled_mode'] = self::MODE_TEXT;
        }

        $kintstance = self::createFromStatics($statics);
        if (!$kintstance) {
            // Should never happen
            return 0; // @codeCoverageIgnore
        }

        if (\in_array('-', $call_info['modifiers'], true)) {
            while (\ob_get_level()) {
                \ob_end_clean();
            }
        }

        $kintstance->setStatesFromStatics($statics);
        $kintstance->setStatesFromCallInfo($call_info);

        // If the call is Kint::dump(1) then dump a backtrace instead
        if ($args === array(1) && (!isset($call_info['params'][0]['name']) || '1' === $call_info['params'][0]['name'])) {
            $args = \debug_backtrace(true);
            $trace = array();

            foreach ($args as $index => $frame) {
                if (Utils::traceFrameIsListed($frame, self::$aliases)) {
                    $trace = array();
                }

                $trace[] = $frame;
            }

            if (isset($call_info['callee']['function'])) {
                $tracename = $call_info['callee']['function'].'(1)';
                if (isset($call_info['callee']['class'], $call_info['callee']['type'])) {
                    $tracename = $call_info['callee']['class'].$call_info['callee']['type'].$tracename;
                }
            } else {
                $tracename = 'Kint\\Kint::dump(1)';
            }

            $tracebase = BasicObject::blank($tracename, 'debug_backtrace(true)');

            $output = $kintstance->dumpAll(array($trace), array($tracebase));
        } else {
            $bases = self::getBasesFromParamInfo(
                isset($call_info['params']) ? $call_info['params'] : array(),
                \count($args)
            );
            $output = $kintstance->dumpAll($args, $bases);
        }

        if (self::$return || \in_array('@', $call_info['modifiers'], true)) {
            return $output;
        }

        echo $output;

        if (\in_array('-', $call_info['modifiers'], true)) {
            \flush(); // @codeCoverageIgnore
        }

        return 0;
    }
945897
public static function backtrace($trace = null)
	{
		$trace or $trace = debug_backtrace();

		if (\Fuel::$is_cli) {
			// Special case for CLI since the var_dump of a backtrace is of little use.
			$str = '';
			foreach ($trace as $i => $frame)
			{
				$line = "#$i\t";

				if ( ! isset($frame['file']))
				{
					$line .= "[internal function]";
				}
				else
				{
					$line .= $frame['file'] . ":" . $frame['line'];
				}

				$line .= "\t";

				if (isset($frame['function']))
				{
					if (isset($frame['class']))
					{
						$line .= $frame['class'] . '::';
					}

					$line .= $frame['function'] . "()";
				}

				$str .= $line . "\n";

			}

			return $str;
		}
		else
		{
			return static::dump($trace);
		}
	}
623893
public function loadCallLocationInfo()
    {
        $this->callFile = null;
        $this->callLine = null;

        $backtraceFlags = DEBUG_BACKTRACE_PROVIDE_OBJECT;
        if (version_compare(PHP_VERSION, '5.3.6', '>=')) {
            $backtraceFlags = DEBUG_BACKTRACE_IGNORE_ARGS;
        }

        $backtrace = debug_backtrace($backtraceFlags);

        $backtraceCount = count($backtrace);
        $idx = $backtraceCount - 1;
        $found = false;

        $container = $this->application->container;

        $helpers = array_merge(
            $container->getParameter('helpers'),
            $container->hasParameter('extra_helpers') ? $container->getParameter('extra_helpers') : array()
        );

        while ($idx > 0 && !$found) {
            $callable = isset($backtrace[$idx]['class']) ? $backtrace[$idx]['class'] . ':' . $backtrace[$idx]['function'] : $backtrace[$idx]['function'];

            if (in_array($callable, $helpers)) {
                $this->callFile = isset($backtrace[$idx]['file']) ? $backtrace[$idx]['file'] : null;
                $this->callLine = isset($backtrace[$idx]['line']) ? $backtrace[$idx]['line'] : null;

                if (!is_null($this->callLineFileCallback)) {
                    list($this->callFile, $this->callLine) = call_user_func_array($this->callLineFileCallback, array(
                        $this->callFile,
                        $this->callLine
                    ));
                }

                $xdebugLink = ini_get('xdebug.file_link_format');
                if (!empty($xdebugLink)) {
                    $this->xdebugLink = str_replace(array('%f', '%l'), array($this->callFile, $this->callLine), $xdebugLink);
                }

                return;
            }

            $idx--;
        }

    }
878291
public function locate()
    {
        foreach ($this->paths as $path) {
            $resolvedPath = stream_resolve_include_path($path);
            if (! $resolvedPath) {
                continue;
                
            }
            $configuration = require $resolvedPath;
            if (! $configuration instanceof Configuration) {
                throw new ConfigurationException(
                    "$resolvedPath must return a malkusch\\bav\\Configuration object."
                );

            }
            return $configuration;
            
        }
        return null;
    }
1339288
protected function findSource()
    {
        $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
        foreach ($traces as $trace) {
            if (isset($trace['class']) && isset($trace['file']) && strpos(
                    $trace['file'],
                    DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR
                ) === false
            ) {
                $file = $trace['file'];
                $line = isset($trace['line']) ? $trace['line'] : '?';

                return $this->normalizeFilename($file).':'.$line;
            } elseif (isset($trace['function']) && $trace['function'] == 'Illuminate\Routing\{closure}') {
                return 'Route binding';
            }
        }
    }
118633
public function _dump($value)
    {
        $tests = array(
            'is_null' => '_dumpNull',
            'is_string' => '_dumpString',
            'is_bool' => '_dumpBoolean',
            'is_integer' => '_dumpInteger',
            'is_float' => '_dumpFloat',
            'is_array' => '_dumpArray',
            'is_object' => '_dumpObject'
        );
        
        foreach ($tests as $predicate => $outputMethod) {
            if (call_user_func($predicate, $value))
                return call_user_func(array(
                    $this,
                    $outputMethod
                ), $value);
        }
        
        return $this->_fallback->inspect($value);
    }
222918
private function findPaths()
    {
        $configFilename = $this->projectPath . DIRECTORY_SEPARATOR . $this->configFile;
        $handle         = fopen($configFilename, 'r');
        if (false === $handle) {
            throw new \FileNotFoundException($configFilename . ' could not be found');
        }
        $contents = fread($handle, filesize($configFilename));
        foreach (explode(PHP_EOL, $contents) as $line) {
            if (preg_match('/sass_dir ?= ?"(.*)"/', $line, $matches) !== 0) {
                $this->sassPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1];
            }
            if (preg_match('/css_dir ?= ?"(.*)"/', $line, $matches) !== 0) {
                $this->cssPath = $this->projectPath . DIRECTORY_SEPARATOR . $matches[1];
            }
        }
    }
289251
public static function debugTrail() {
		$trail = debug_backtrace();
		$trail = array_reverse($trail);
		array_pop($trail);

		$path = array();
		foreach ($trail as $dat) {
			$pathFragment = $dat['class'] . $dat['type'] . $dat['function'];
				// add the path of the included file
			if (in_array($dat['function'], array('require', 'include', 'require_once', 'include_once'))) {
				$pathFragment .= '(' . substr($dat['args'][0], strlen(PATH_site)) . '),' . substr($dat['file'], strlen(PATH_site));
			}
			$path[] = $pathFragment . '#' . $dat['line'];
		}

		return implode(' // ', $path);
	}
37362
static public function traceFiles()
    {
        $backtrace = debug_backtrace();
        array_shift($backtrace);
        $message = 'load files:' . PHP_EOL;
        if ($backtrace) foreach ($backtrace as $v) {
            $message .= sprintf('[%s] %s: %s', filesize($v['file']), $v['file'], $v['function']) . PHP_EOL;
        }
        Ioc::logger('trace')->debug(sprintf('[%s]%s', 'file', $message));
    }
741328
public function find(): self
    {
        $preparedPaths = \array_unique(
            \array_merge(
                $this->getPreparedPaths((array) $this->paths['psr0']),
                $this->getPreparedPaths((array) $this->paths['psr4']),
                $this->getPreparedPaths((array) $this->paths['classmap'])
            ),
            \SORT_STRING
        );

        $finder = Finder::create()
            ->files()
            ->in($preparedPaths)
            ->exclude($this->excludes)
            ->name('*.php')
            ->sortByName();

        if ($this->filter !== null) {
            $finder->filter($this->filter);
        }

        /** @var \SplFileInfo $file */
        foreach ($finder as $file) {
            $realPath  = (string) $file->getRealPath();

            $namespace = null;
            $tokens    = \token_get_all((string) \file_get_contents($realPath));

            foreach ($tokens as $key => $token) {
                if (\is_array($token)) {
                    if ($token[0] === \T_NAMESPACE) {
                        $namespace = self::getNamespace($key + 2, $tokens);
                    } elseif ($token[0] === \T_INTERFACE) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->interfaces[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    } elseif ($token[0] === \T_TRAIT) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->traits[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    } elseif ($token[0] === \T_ABSTRACT) {
                        $name = self::getName($key + 4, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->abstractClasses[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;

                        continue 2;
                    } elseif ($token[0] === \T_CLASS) {
                        $name = self::getName($key + 2, $tokens);

                        if ($name === null) {
                            continue 2;
                        }

                        $this->classes[\ltrim($namespace . '\\' . $name, '\\')] = $realPath;
                    }
                }
            }

            unset($tokens);
            // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
            \gc_mem_caches();
        }

        return $this;
    }
638804
protected function resolveDumpPath()
    {
        $path = $this->basePath . '/' . $this->dumpPath;
        $this->ensureDirectory($path);
        return realpath($path) . '/' . $this->dumpFile;
    }
418204
protected function outputPath()
    {
        $source = $this->config
            ->getSourcePath()
        ;
        $destination = $this->ask('Where do you want to save the file? (Press enter for the current directory)');
        $outputPath = null !== $destination ? $destination : $source;

        if (!\file_exists($outputPath)) {
            \mkdir($outputPath, 0744, true);
        }

        return $outputPath;
    }
1001751
public function getFilePosition()
	{
		// Gzipped file... unpack it first
		$position = 0;
		$info     = @ unpack('CCM/CFLG/VTime/CXFL/COS', substr($this->data, $position + 2));

		if (!$info)
		{
			throw new \RuntimeException('Unable to decompress data.');
		}

		$position += 10;

		if ($info['FLG'] & $this->flags['FEXTRA'])
		{
			$XLEN = unpack('vLength', substr($this->data, $position + 0, 2));
			$XLEN = $XLEN['Length'];
			$position += $XLEN + 2;
		}

		if ($info['FLG'] & $this->flags['FNAME'])
		{
			$filenamePos = strpos($this->data, "\x0", $position);
			$position    = $filenamePos + 1;
		}

		if ($info['FLG'] & $this->flags['FCOMMENT'])
		{
			$commentPos = strpos($this->data, "\x0", $position);
			$position   = $commentPos + 1;
		}

		if ($info['FLG'] & $this->flags['FHCRC'])
		{
			$hcrc = unpack('vCRC', substr($this->data, $position + 0, 2));
			$hcrc = $hcrc['CRC'];
			$position += 2;
		}

		return $position;
	}
468548
public function toString()
    {
        ob_start();

        printf(
            "%s:\n\nMessage:\n\t%s\n\n" . "In file '%s' on line %s.\n\n",
            $this->getSeverityString(),
            $this->message,
            $this->file,
            $this->line
        );

        echo "Stack Trace:\n";
        $count = count($this->backtrace);

        foreach ($this->backtrace as $entry) {
            $class = array_key_exists('class', $entry) ? $entry['class'] : null;

            $function = array_key_exists('function', $entry)
                ? $entry['function']
                : null;

            if (array_key_exists('args', $entry)) {
                $arguments = $this->getArguments(
                    $entry['args'],
                    $function,
                    $class
                );
            } else {
                $arguments = '';
            }

            printf(
                "%s. In file '%s' on line %s.\n%sMethod: %s%s%s(%s)\n",
                str_pad(--$count, 6, ' ', STR_PAD_LEFT),
                array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
                array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
                str_repeat(' ', 8),
                $class === null ? '' : $class,
                array_key_exists('type', $entry) ? $entry['type'] : '',
                $function === null ? '' : $function,
                $arguments
            );
        }

        echo "\n";

        return ob_get_clean();
    }