File manager - Edit - /home/autoph/public_html/projects/Rating-AutoHub/public/css/backtrace.zip
Back
PK �0�Z`;�9B B LICENSE.mdnu �[��� The MIT License (MIT) Copyright (c) Spatie bvba <info@spatie.be> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK �0�Z��Kʤ � composer.jsonnu �[��� { "name": "spatie/backtrace", "description": "A better backtrace", "keywords": [ "spatie", "backtrace" ], "homepage": "https://github.com/spatie/backtrace", "license": "MIT", "authors": [ { "name": "Freek Van de Herten", "email": "freek@spatie.be", "homepage": "https://spatie.be", "role": "Developer" } ], "require": { "php": "^7.3|^8.0" }, "require-dev": { "ext-json": "*", "phpunit/phpunit": "^9.3", "spatie/phpunit-snapshot-assertions": "^4.2", "symfony/var-dumper": "^5.1" }, "autoload": { "psr-4": { "Spatie\\Backtrace\\": "src" } }, "autoload-dev": { "psr-4": { "Spatie\\Backtrace\\Tests\\": "tests" } }, "scripts": { "psalm": "vendor/bin/psalm", "test": "vendor/bin/phpunit", "test-coverage": "vendor/bin/phpunit --coverage-html coverage", "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" }, "config": { "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, "funding": [ { "type": "github", "url": "https://github.com/sponsors/spatie" }, { "type": "other", "url": "https://spatie.be/open-source/support-us" } ] } PK �0�Z�,7�� � src/CodeSnippet.phpnu �[��� <?php namespace Spatie\Backtrace; use RuntimeException; class CodeSnippet { /** @var int */ protected $surroundingLine = 1; /** @var int */ protected $snippetLineCount = 9; public function surroundingLine(int $surroundingLine): self { $this->surroundingLine = $surroundingLine; return $this; } public function snippetLineCount(int $snippetLineCount): self { $this->snippetLineCount = $snippetLineCount; return $this; } public function get(string $fileName): array { if (! file_exists($fileName)) { return []; } try { $file = new File($fileName); [$startLineNumber, $endLineNumber] = $this->getBounds($file->numberOfLines()); $code = []; $line = $file->getLine($startLineNumber); $currentLineNumber = $startLineNumber; while ($currentLineNumber <= $endLineNumber) { $code[$currentLineNumber] = rtrim(substr($line, 0, 250)); $line = $file->getNextLine(); $currentLineNumber++; } return $code; } catch (RuntimeException $exception) { return []; } } public function getAsString(string $fileName): string { $snippet = $this->get($fileName); $snippetStrings = array_map(function (string $line, string $number) { return "{$number} {$line}"; }, $snippet, array_keys($snippet)); return implode(PHP_EOL, $snippetStrings); } protected function getBounds(int $totalNumberOfLineInFile): array { $startLine = max($this->surroundingLine - floor($this->snippetLineCount / 2), 1); $endLine = $startLine + ($this->snippetLineCount - 1); if ($endLine > $totalNumberOfLineInFile) { $endLine = $totalNumberOfLineInFile; $startLine = max($endLine - ($this->snippetLineCount - 1), 1); } return [$startLine, $endLine]; } } PK �0�ZEsra a src/Frame.phpnu �[��� <?php namespace Spatie\Backtrace; class Frame { /** @var string */ public $file; /** @var int */ public $lineNumber; /** @var array|null */ public $arguments = null; /** @var bool */ public $applicationFrame; /** @var string|null */ public $method; /** @var string|null */ public $class; public function __construct( string $file, int $lineNumber, ?array $arguments, string $method = null, string $class = null, bool $isApplicationFrame = false ) { $this->file = $file; $this->lineNumber = $lineNumber; $this->arguments = $arguments; $this->method = $method; $this->class = $class; $this->applicationFrame = $isApplicationFrame; } public function getSnippet(int $lineCount): array { return (new CodeSnippet()) ->surroundingLine($this->lineNumber) ->snippetLineCount($lineCount) ->get($this->file); } public function getSnippetAsString(int $lineCount): string { return (new CodeSnippet()) ->surroundingLine($this->lineNumber) ->snippetLineCount($lineCount) ->getAsString($this->file); } public function getSnippetProperties(int $lineCount): array { $snippet = $this->getSnippet($lineCount); return array_map(function (int $lineNumber) use ($snippet) { return [ 'line_number' => $lineNumber, 'text' => $snippet[$lineNumber], ]; }, array_keys($snippet)); } } PK �0�Z� 1� � src/File.phpnu �[��� <?php namespace Spatie\Backtrace; use SplFileObject; class File { /** @var \SplFileObject */ protected $file; public function __construct(string $path) { $this->file = new SplFileObject($path); } public function numberOfLines(): int { $this->file->seek(PHP_INT_MAX); return $this->file->key() + 1; } public function getLine(int $lineNumber = null): string { if (is_null($lineNumber)) { return $this->getNextLine(); } $this->file->seek($lineNumber - 1); return $this->file->current(); } public function getNextLine(): string { $this->file->next(); return $this->file->current(); } } PK �0�Z�:�H� � src/Backtrace.phpnu �[��� <?php namespace Spatie\Backtrace; use Closure; use Throwable; class Backtrace { /** @var bool */ protected $withArguments = false; /** @var bool */ protected $withObject = false; /** @var string|null */ protected $applicationPath; /** @var int */ protected $offset = 0; /** @var int */ protected $limit = 0; /** @var \Closure|null */ protected $startingFromFrameClosure = null; /** @var \Throwable|null */ protected $throwable = null; public static function create(): self { return new static(); } public static function createForThrowable(Throwable $throwable): self { return (new static())->forThrowable($throwable); } protected function forThrowable(Throwable $throwable): self { $this->throwable = $throwable; return $this; } public function withArguments(): self { $this->withArguments = true; return $this; } public function withObject(): self { $this->withObject = true; return $this; } public function applicationPath(string $applicationPath): self { $this->applicationPath = rtrim($applicationPath, '/'); return $this; } public function offset(int $offset): self { $this->offset = $offset; return $this; } public function limit(int $limit): self { $this->limit = $limit; return $this; } public function startingFromFrame(Closure $startingFromFrameClosure) { $this->startingFromFrameClosure = $startingFromFrameClosure; return $this; } /** * @return \Spatie\Backtrace\Frame[] */ public function frames(): array { $rawFrames = $this->getRawFrames(); return $this->toFrameObjects($rawFrames); } public function firstApplicationFrameIndex(): ?int { foreach ($this->frames() as $index => $frame) { if ($frame->applicationFrame) { return $index; } } return null; } protected function getRawFrames(): array { if ($this->throwable) { return $this->throwable->getTrace(); } $options = null; if (! $this->withArguments) { $options = $options | DEBUG_BACKTRACE_IGNORE_ARGS; } if ($this->withObject()) { $options = $options | DEBUG_BACKTRACE_PROVIDE_OBJECT; } $limit = $this->limit; if ($limit !== 0) { $limit += 3; } return debug_backtrace($options, $limit); } /** * @return \Spatie\Backtrace\Frame[] */ protected function toFrameObjects(array $rawFrames): array { $currentFile = $this->throwable ? $this->throwable->getFile() : ''; $currentLine = $this->throwable ? $this->throwable->getLine() : 0; $frames = []; foreach ($rawFrames as $rawFrame) { $frames[] = new Frame( $currentFile, $currentLine, $rawFrame['args'] ?? null, $rawFrame['function'] ?? null, $rawFrame['class'] ?? null, $this->isApplicationFrame($currentFile) ); $currentFile = $rawFrame['file'] ?? 'unknown'; $currentLine = $rawFrame['line'] ?? 0; } $frames[] = new Frame( $currentFile, $currentLine, [], '[top]' ); $frames = $this->removeBacktracePackageFrames($frames); if ($closure = $this->startingFromFrameClosure) { $frames = $this->startAtFrameFromClosure($frames, $closure); } $frames = array_slice($frames, $this->offset, $this->limit === 0 ? PHP_INT_MAX : $this->limit); return array_values($frames); } protected function isApplicationFrame(string $frameFilename): bool { $relativeFile = str_replace('\\', DIRECTORY_SEPARATOR, $frameFilename); if (! empty($this->applicationPath)) { $relativeFile = array_reverse(explode($this->applicationPath ?? '', $frameFilename, 2))[0]; } if (strpos($relativeFile, DIRECTORY_SEPARATOR . 'vendor') === 0) { return false; } return true; } protected function removeBacktracePackageFrames(array $frames): array { return $this->startAtFrameFromClosure($frames, function (Frame $frame) { return $frame->class !== static::class; }); } /** * @param \Spatie\Backtrace\Frame[] $frames * @param \Closure $closure * * @return array */ protected function startAtFrameFromClosure(array $frames, Closure $closure): array { foreach ($frames as $i => $frame) { $foundStartingFrame = $closure($frame); if ($foundStartingFrame) { return $frames; } unset($frames[$i]); } return $frames; } } PK �0�Z� README.mdnu �[��� # A better PHP backtrace [](https://packagist.org/packages/spatie/backtrace)  [](https://packagist.org/packages/spatie/backtrace) To get the backtrace in PHP you can use the `debug_backtrace` function. By default, it can be hard to work with. The reported function name for a frame is skewed: it belongs to the previous frame. Also, options need to be passed using a bitmask. This package provides a better way than `debug_backtrace` to work with a back trace. Here's an example: ```php // returns an array with `Spatie\Backtrace\Frame` instances $frames = Spatie\Backtrace\Backtrace::create()->frames(); $firstFrame = $frames[0]; $firstFrame->file; // returns the file name $firstFrame->lineNumber; // returns the line number $firstFrame->class; // returns the class name ``` ## Support us [<img src="https://github-ads.s3.eu-central-1.amazonaws.com/backtrace.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/backtrace) We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). ## Installation You can install the package via composer: ```bash composer require spatie/backtrace ``` ## Usage This is how you can create a backtrace instance: ```php $backtrace = Spatie\Backtrace\Backtrace::create(); ``` ### Getting the frames To get all the frames you can call `frames`. ```php $frames = $backtrace->frames(); // contains an array with `Spatie\Backtrace\Frame` instances ``` A `Spatie\Backtrace\Frame` has these properties: - `file`: the name of the file - `lineNumber`: the line number - `arguments`: the arguments used for this frame. Will be `null` if `withArguments` was not used. - `class`: the class name for this frame. Will be `null` if the frame concerns a function. - `method`: the method used in this frame - `applicationFrame`: contains `true` is this frame belongs to your application, and `false` if it belongs to a file in the vendor directory ### Collecting arguments For performance reasons, the frames of the back trace will not contain the arguments of the called functions. If you want to add those use the `withArguments` method. ```php $backtrace = Spatie\Backtrace\Backtrace::create()->withArguments(); ``` ### Setting the application path You can use the `applicationPath` to pass the base path of your app. This value will be used to determine whether a frame is an application frame, or a vendor frame. Here's an example using a Laravel specific function. ```php $backtrace = Spatie\Backtrace\Backtrace::create()->applicationPath(base_path()); ``` ### Getting a certain part of a trace If you only want to have the frames starting from a particular frame in the backtrace you can use the `startingFromFrame` method: ```php use Spatie\Backtrace\Backtrace; use Spatie\Backtrace\Frame; $frames = Backtrace::create() ->startingFromFrame(function (Frame $frame) { return $frame->class === MyClass::class; }) ->frames(); ``` With this code, all frames before the frame that concerns `MyClass` will have been filtered out. Alternatively, you can use the `offset` method, which will skip the given number of frames. In this example the first 2 frames will not end up in `$frames`. ```php $frames = Spatie\Backtrace\Backtrace::create() ->offset(2) ->frames(); ``` ### Limiting the number of frames To only get a specific number of frames use the `limit` function. In this example, we'll only get the first two frames. ```php $frames = Spatie\Backtrace\Backtrace::create() ->limit(2) ->frames(); ``` ### Getting a backtrace for a throwable Here's how you can get a backtrace for a throwable. ```php $frames = Spatie\Backtrace\Backtrace::createForThrowable($throwable) ``` Because we will use the backtrace that is already available the throwable, the frames will always contain the arguments used. ## Testing ``` bash composer test ``` ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. ## Security Vulnerabilities Please review [our security policy](../../security/policy) on how to report security vulnerabilities. ## Credits - [Freek Van de Herten](https://github.com/freekmurze) - [All Contributors](../../contributors) ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. PK �0�Z`;�9B B LICENSE.mdnu �[��� PK �0�Z��Kʤ � | composer.jsonnu �[��� PK �0�Z�,7�� � ] src/CodeSnippet.phpnu �[��� PK �0�ZEsra a � src/Frame.phpnu �[��� PK �0�Z� 1� � = src/File.phpnu �[��� PK �0�Z�:�H� � V src/Backtrace.phpnu �[��� PK �0�Z� j0 README.mdnu �[��� PK �D
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings