repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Twig/Extension/Stopwatch.php
src/Twig/Extension/Stopwatch.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Twig\Extension; use DebugBar\Bridge\Twig\MeasureTwigExtension; use DebugBar\Bridge\Twig\MeasureTwigTokenParser; use Illuminate\Foundation\Application; /** * Access debugbar time measures in your Twig templates. * Based on Symfony\Bridge\Twig\Extension\StopwatchExtension */ class Stopwatch extends MeasureTwigExtension { /** * @var \Barryvdh\Debugbar\LaravelDebugbar */ protected $debugbar; /** * Create a new time measure extension. * */ public function __construct(Application $app) { if ($app->bound('debugbar')) { $this->debugbar = $app['debugbar']; } parent::__construct(null, 'stopwatch'); } public function getDebugbar() { return $this->debugbar; } public function getTokenParsers() { return [ /* * {% measure foo %} * Some stuff which will be recorded on the timeline * {% endmeasure %} */ new MeasureTwigTokenParser(!is_null($this->debugbar), $this->tagName, $this->getName()), ]; } public function startMeasure(...$arg) { if (!$this->debugbar || !$this->debugbar->hasCollector('time')) { return; } $this->debugbar->getCollector('time')->startMeasure(...$arg); } public function stopMeasure(...$arg) { if (!$this->debugbar || !$this->debugbar->hasCollector('time')) { return; } $this->debugbar->getCollector('time')->stopMeasure(...$arg); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Twig/Extension/Dump.php
src/Twig/Extension/Dump.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Twig\Extension; use DebugBar\Bridge\Twig\DumpTwigExtension; /** * Dump variables using the DataFormatter */ class Dump extends DumpTwigExtension {}
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Twig/Extension/Debug.php
src/Twig/Extension/Debug.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Twig\Extension; use DebugBar\Bridge\Twig\DebugTwigExtension; use Illuminate\Foundation\Application; use Twig\Environment; /** * Access debugbar debug in your Twig templates. */ class Debug extends DebugTwigExtension { protected $app; /** * Create a new debug extension. * */ public function __construct(Application $app) { $this->app = $app; parent::__construct(null); } public function debug(Environment $env, $context) { if ($this->app->bound('debugbar') && $this->app['debugbar']->hasCollector('messages')) { $this->messagesCollector = $this->app['debugbar']['messages']; } return parent::debug($env, $context); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Support/Explain.php
src/Support/Explain.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Support; use Exception; use Illuminate\Database\ConnectionInterface; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Http; class Explain { public function isVisualExplainSupported(string $connection): bool { $driver = DB::connection($connection)->getDriverName(); if ($driver === 'pgsql') { return true; } if ($driver === 'mysql') { // Laravel 11 added a new MariaDB database driver but older Laravel versions handle MySQL and MariaDB with // the same driver - and even with new versions you can use the MySQL driver while connection to a MariaDB // database. This query uses a feature implemented only in MariaDB to differentiate them. try { DB::connection($connection)->select('SELECT * FROM seq_1_to_1'); return false; } catch (QueryException) { // This exception is expected when using MySQL as sequence tables are only available with MariaDB. So // the exception gets silenced as the check for MySQL has succeeded. return true; } } return false; } public function confirmVisualExplain(string $connection): ?string { return match (DB::connection($connection)->getDriverName()) { 'mysql' => 'The query and EXPLAIN output is sent to mysqlexplain.com. Do you want to continue?', 'pgsql' => 'The query and EXPLAIN output is sent to explain.dalibo.com. Do you want to continue?', default => null, }; } public function hash(string $connection, string $sql, array $bindings): string { $bindings = json_encode($bindings); return match (DB::connection($connection)->getDriverName()) { 'mariadb', 'mysql', 'pgsql' => hash_hmac('sha256', "{$connection}::{$sql}::{$bindings}", config('app.key')), default => null, }; } private function verify(string $connection, string $sql, array $bindings, string $hash): void { if (!hash_equals($this->hash($connection, $sql, $bindings), $hash)) { throw new Exception('Query to execute could not be verified.'); } } public function generateRawExplain(string $connection, string $sql, array $bindings, string $hash): array { $this->verify($connection, $sql, $bindings, $hash); $connection = DB::connection($connection); return match ($driver = $connection->getDriverName()) { 'mariadb', 'mysql' => $connection->select("EXPLAIN {$sql}", $bindings), 'pgsql' => array_column($connection->select("EXPLAIN {$sql}", $bindings), 'QUERY PLAN'), default => throw new Exception("Visual explain not available for driver '{$driver}'."), }; } public function generateVisualExplain(string $connection, string $sql, array $bindings, string $hash): string { $this->verify($connection, $sql, $bindings, $hash); if (!$this->isVisualExplainSupported($connection)) { throw new Exception('Visual explain not available for this connection.'); } $connection = DB::connection($connection); return match ($connection->getDriverName()) { 'mysql' => $this->generateVisualExplainMysql($connection, $sql, $bindings), 'pgsql' => $this->generateVisualExplainPgsql($connection, $sql, $bindings), default => throw new Exception("Visual explain not available for driver '{$connection->getDriverName()}'."), }; } private function generateVisualExplainMysql(ConnectionInterface $connection, string $query, array $bindings): string { return Http::withHeaders([ 'User-Agent' => 'barryvdh/laravel-debugbar', ])->post('https://api.mysqlexplain.com/v2/explains', [ 'query' => $query, 'bindings' => $bindings, 'version' => $connection->selectOne("SELECT VERSION()")->{'VERSION()'}, 'explain_json' => $connection->selectOne("EXPLAIN FORMAT=JSON {$query}", $bindings)->EXPLAIN, 'explain_tree' => rescue(fn() => $connection->selectOne("EXPLAIN FORMAT=TREE {$query}", $bindings)->EXPLAIN, report: false), ])->throw()->json('url'); } private function generateVisualExplainPgsql(ConnectionInterface $connection, string $query, array $bindings): string { return (string) Http::asForm()->post('https://explain.dalibo.com/new', [ 'query' => $query, 'plan' => $connection->selectOne("EXPLAIN (FORMAT JSON) {$query}", $bindings)->{'QUERY PLAN'}, 'title' => '', ])->effectiveUri(); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Support/RequestIdGenerator.php
src/Support/RequestIdGenerator.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Support; use DebugBar\RequestIdGeneratorInterface; use Illuminate\Support\Str; class RequestIdGenerator implements RequestIdGeneratorInterface { public function generate(): string { return (string) Str::ulid(); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Support/Clockwork/Converter.php
src/Support/Clockwork/Converter.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Support\Clockwork; class Converter { /** * Convert the phpdebugbar data to Clockwork format. * * @param array $data * * @return array */ public function convert($data) { $meta = $data['__meta']; // Default output $output = [ 'id' => $meta['id'], 'method' => $meta['method'], 'uri' => $meta['uri'], 'time' => $meta['utime'], 'headers' => [], 'cookies' => [], 'emailsData' => [], 'getData' => [], 'log' => [], 'postData' => [], 'sessionData' => [], 'timelineData' => [], 'viewsData' => [], 'controller' => null, 'responseTime' => null, 'responseStatus' => null, 'responseDuration' => 0, ]; if (isset($data['clockwork'])) { $output = array_merge($output, $data['clockwork']); } if (isset($data['memory']['peak_usage'])) { $output['memoryUsage'] = $data['memory']['peak_usage']; } if (isset($data['time']['measures'])) { $time = $data['time']; $output['time'] = $time['start']; $output['responseTime'] = $time['end']; $output['responseDuration'] = $time['duration'] * 1000; foreach ($time['measures'] as $measure) { $output['timelineData'][] = [ 'data' => [], 'description' => $measure['label'], 'duration' => $measure['duration'] * 1000, 'end' => $measure['end'], 'start' => $measure['start'], 'relative_start' => $measure['start'] - $time['start'], ]; } } if (isset($data['route'])) { $route = $data['route']; $controller = null; if (isset($route['controller'])) { $controller = $route['controller']; } elseif (isset($route['uses'])) { $controller = $route['uses']; } $output['controller'] = preg_replace('/<a\b[^>]*>(.*?)<\/a>/i', '', (string) $controller) ?: null; [$method, $uri] = explode(' ', $route['uri'], 2); $output['routes'][] = [ 'action' => $output['controller'], 'after' => $route['after'] ?? null, 'before' => $route['before'] ?? null, 'method' => $method, 'name' => $route['as'] ?? null, 'uri' => $uri, ]; } if (isset($data['messages']['messages'])) { foreach ($data['messages']['messages'] as $message) { $output['log'][] = [ 'message' => $message['message'], 'time' => $message['time'], 'level' => $message['label'], ]; } } if (isset($data['queries']['statements'])) { $queries = $data['queries']; foreach ($queries['statements'] as $statement) { if ($statement['type'] === 'explain' || $statement['type'] === 'info') { continue; } $output['databaseQueries'][] = [ 'query' => $statement['sql'], 'bindings' => $statement['params'], 'duration' => $statement['duration'] * 1000, 'time' => $statement['start'] ?? null, 'connection' => $statement['connection'], ]; } $output['databaseDuration'] = $queries['accumulated_duration'] * 1000; } if (isset($data['models']['data'])) { $output['modelsActions'] = []; $output['modelsCreated'] = []; $output['modelsUpdated'] = []; $output['modelsDeleted'] = []; $output['modelsRetrieved'] = []; foreach ($data['models']['data'] as $model => $value) { foreach ($value as $event => $count) { $eventKey = 'models' . ucfirst($event); if (isset($output[$eventKey])) { $output[$eventKey][$model] = $count; } } } } if (isset($data['views']['templates'])) { foreach ($data['views']['templates'] as $view) { $output['viewsData'][] = [ 'description' => 'Rendering a view', 'duration' => 0, 'end' => 0, 'start' => $view['start'] ?? 0, 'data' => [ 'name' => $view['name'], 'data' => $view['params'], ], ]; } } if (isset($data['event']['measures'])) { foreach ($data['event']['measures'] as $event) { $event['data'] = []; $event['listeners'] = []; foreach ($event['params'] ?? [] as $key => $param) { $event[is_numeric($key) ? 'data' : 'listeners'] = $param; } $output['events'][] = [ 'event' => ['event' => $event['label']], 'data' => $event['data'], 'time' => $event['start'], 'duration' => $event['duration'] * 1000, 'listeners' => $event['listeners'], ]; } } if (isset($data['symfonymailer_mails']['mails'])) { foreach ($data['symfonymailer_mails']['mails'] as $mail) { $output['emailsData'][] = [ 'data' => [ 'to' => implode(', ', $mail['to']), 'subject' => $mail['subject'], 'headers' => isset($mail['headers']) ? explode("\n", $mail['headers']) : null, ], ]; } } return $output; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Support/Clockwork/ClockworkCollector.php
src/Support/Clockwork/ClockworkCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Support\Clockwork; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use DebugBar\DataCollector\Renderable; use Illuminate\Session\SessionManager; use Illuminate\Support\Arr; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * * Based on \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector by Fabien Potencier <fabien@symfony.com> * */ class ClockworkCollector extends DataCollector implements DataCollectorInterface, Renderable { protected Request $request; protected Response $response; protected ?SessionManager $session; protected ?string $currentRequestId = null; protected array $hiddens = []; public function __construct( Request $request, Response $response, ?SessionManager $session = null, array $hiddens = [] ) { $this->request = $request; $this->response = $response; $this->session = $session; $this->hiddens = array_merge($hiddens, [ 'request_request.password', 'request_request.PHP_AUTH_PW', 'request_request.php-auth-pw', 'request_headers.php-auth-pw.0', ]); } /** * {@inheritDoc} */ public function getName(): string { return 'clockwork'; } /** * {@inheritDoc} */ public function getWidgets(): array { return []; } /** * {@inheritdoc} */ public function collect(): array { $request = $this->request; $response = $this->response; $data = [ 'getData' => $request->query->all(), 'postData' => $request->request->all(), 'headers' => $request->headers->all(), 'cookies' => $request->cookies->all(), 'uri' => $request->getRequestUri(), 'method' => $request->getMethod(), 'responseStatus' => $response->getStatusCode(), ]; if ($this->session) { $data['sessionData'] = $this->session->all(); } if (isset($data['headers']['authorization'][0])) { $data['headers']['authorization'][0] = substr($data['headers']['authorization'][0], 0, 12) . '******'; } $keyAlias = [ 'request_query' => 'getData', 'request_request' => 'postData', 'request_headers' => 'headers', 'request_cookies' => 'cookies', 'session_attributes' => 'sessionData', ]; foreach ($this->hiddens as $key) { $key = explode('.', $key); $key[0] = $keyAlias[$key[0]] ?? $key[0]; $key = implode('.', $key); if (Arr::has($data, $key)) { Arr::set($data, $key, '******'); } } return $data; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Storage/FilesystemStorage.php
src/Storage/FilesystemStorage.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Storage; use DebugBar\Storage\StorageInterface; use Illuminate\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; /** * Stores collected data into files */ class FilesystemStorage implements StorageInterface { protected string $dirname; protected Filesystem $files; protected int $gc_lifetime = 24; // Hours to keep collected data; protected int $gc_probability = 5; // Probability of GC being run on a save request. (5/100) /** * @param \Illuminate\Filesystem\Filesystem $files The filesystem * @param string $dirname Directories where to store files */ public function __construct(Filesystem $files, string $dirname) { $this->files = $files; $this->dirname = rtrim($dirname, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } /** * {@inheritDoc} */ public function save(string $id, array $data): void { if (!$this->files->isDirectory($this->dirname)) { if ($this->files->makeDirectory($this->dirname, 0o777, true)) { $this->files->put($this->dirname . '.gitignore', "*\n!.gitignore\n"); } else { throw new \Exception("Cannot create directory '$this->dirname'.."); } } try { $this->files->put($this->makeFilename($id), json_encode($data)); } catch (\Exception $e) { //TODO; error handling } // Randomly check if we should collect old files if (rand(1, 100) <= $this->gc_probability) { $this->garbageCollect(); } } /** * Create the filename for the data, based on the id. * */ public function makeFilename(string $id): string { return $this->dirname . basename($id) . ".json"; } /** * Delete files older than a certain age (gc_lifetime) */ protected function garbageCollect(): void { foreach ( Finder::create()->files()->name('*.json')->date('< ' . $this->gc_lifetime . ' hour ago')->in( $this->dirname, ) as $file ) { $this->files->delete($file->getRealPath()); } } /** * {@inheritDoc} */ public function get(string $id): array { $fileName = $this->makeFilename($id); if (!$this->files->exists($fileName)) { return []; } return json_decode($this->files->get($fileName), true); } /** * {@inheritDoc} */ public function find(array $filters = [], int $max = 20, int $offset = 0): array { // Sort by modified time, newest first $sort = function (\SplFileInfo $a, \SplFileInfo $b) { return $b->getMTime() <=> $a->getMTime(); }; // Loop through .json files, filter the metadata and stop when max is found. $i = 0; $results = []; foreach (Finder::create()->files()->name('*.json')->in($this->dirname)->sort($sort) as $file) { if ($i++ < $offset && empty($filters)) { $results[] = null; continue; } $data = json_decode($file->getContents(), true); $meta = $data['__meta']; unset($data); if ($this->filter($meta, $filters)) { $results[] = $meta; } if (count($results) >= ($max + $offset)) { break; } } return array_slice($results, $offset, $max); } /** * Filter the metadata for matches. * */ protected function filter(array $meta, array $filters): bool { foreach ($filters as $key => $value) { if (!isset($meta[$key]) || fnmatch($value, $meta[$key]) === false) { return false; } } return true; } /** * {@inheritDoc} */ public function clear(): void { foreach (Finder::create()->files()->name('*.json')->in($this->dirname) as $file) { $this->files->delete($file->getRealPath()); } } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/LogsCollector.php
src/DataCollector/LogsCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\MessagesCollector; use Illuminate\Support\Arr; use Psr\Log\LogLevel; use ReflectionClass; class LogsCollector extends MessagesCollector { protected $lines = 124; public function __construct(string|array|null $path = null, string $name = 'logs') { parent::__construct($name); $paths = Arr::wrap($path ?: [ storage_path('logs/laravel.log'), storage_path('logs/laravel-' . date('Y-m-d') . '.log'), // for daily driver ]); foreach ($paths as $path) { $this->getStorageLogs($path); } } /** * get logs apache in app/storage/logs * only 24 last of current day */ public function getStorageLogs(string $path): void { if (!file_exists($path)) { return; } //Load the latest lines, guessing about 15x the number of log entries (for stack traces etc) $file = implode("", $this->tailFile($path, $this->lines)); $basename = basename($path); foreach ($this->getLogs($file) as $log) { $this->messages[] = [ 'message' => trim($log['header'] . $log['stack']), 'label' => $log['level'], 'time' => substr($log['header'], 1, 19), 'collector' => $basename, 'is_string' => false, ]; } } /** * By Ain Tohvri (ain) * http://tekkie.flashbit.net/php/tail-functionality-in-php */ protected function tailFile(string $file, int $lines): array { $handle = fopen($file, "r"); $linecounter = $lines; $pos = -2; $beginning = false; $text = []; while ($linecounter > 0) { $t = " "; while ($t != "\n") { if (fseek($handle, $pos, SEEK_END) == -1) { $beginning = true; break; } $t = fgetc($handle); $pos--; } $linecounter--; if ($beginning) { rewind($handle); } $text[$lines - $linecounter - 1] = fgets($handle); if ($beginning) { break; } } fclose($handle); return array_reverse($text); } /** * Search a string for log entries * Based on https://github.com/mikemand/logviewer/blob/master/src/Kmd/Logviewer/Logviewer.php by mikemand */ public function getLogs(string $file): array { $pattern = "/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\](?:(?!\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\])[\s\S])*/"; $log_levels = $this->getLevels(); // There has GOT to be a better way of doing this... preg_match_all($pattern, $file, $headings); $log_data = preg_split($pattern, $file) ?: []; $log = []; foreach ($headings as $h) { for ($i = 0, $j = count($h); $i < $j; $i++) { foreach ($log_levels as $ll) { if (strpos(strtolower($h[$i]), strtolower('.' . $ll))) { $log[] = ['level' => $ll, 'header' => $h[$i], 'stack' => $log_data[$i] ?? '']; } } } } return $log; } public function getMessages(): array { return array_reverse(parent::getMessages()); } /** * Get the log levels from psr/log. * Based on https://github.com/mikemand/logviewer/blob/master/src/Kmd/Logviewer/Logviewer.php by mikemand */ public function getLevels(): array { $class = new ReflectionClass(new LogLevel()); return $class->getConstants(); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/LaravelCollector.php
src/DataCollector/LaravelCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; use Illuminate\Contracts\Foundation\Application as ApplicationContract; use Illuminate\Support\Str; class LaravelCollector extends DataCollector implements Renderable { public function __construct(protected ApplicationContract $laravel) {} /** * {@inheritDoc} */ public function collect(): array { return [ "version" => Str::of($this->laravel->version())->explode('.')->first() . '.x', 'tooltip' => [ 'Laravel Version' => $this->laravel->version(), 'PHP Version' => phpversion(), 'Environment' => $this->laravel->environment(), 'Debug Mode' => config('app.debug') ? 'Enabled' : 'Disabled', 'URL' => Str::of(config('app.url'))->replace(['http://', 'https://'], ''), 'Timezone' => config('app.timezone'), 'Locale' => config('app.locale'), ], ]; } /** * {@inheritDoc} */ public function getName(): string { return 'laravel'; } /** * {@inheritDoc} */ public function getWidgets(): array { return [ "version" => [ "icon" => "brand-laravel", "map" => "laravel.version", "default" => "", ], "version:tooltip" => [ "map" => "laravel.tooltip", "default" => "{}", ], ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/EventCollector.php
src/DataCollector/EventCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\TimeDataCollector; use DebugBar\DataFormatter\SimpleFormatter; use Illuminate\Events\Dispatcher; use Illuminate\Support\Str; class EventCollector extends TimeDataCollector { protected ?Dispatcher $events; protected array $excludedEvents; protected bool $collectValues; public function __construct(?float $requestStartTime = null, bool $collectValues = false, array $excludedEvents = []) { parent::__construct($requestStartTime); $this->collectValues = $collectValues; $this->excludedEvents = $excludedEvents; $this->setDataFormatter(new SimpleFormatter()); } public function onWildcardEvent(?string $name = null, array $data = []): void { $currentTime = microtime(true); $eventClass = explode(':', $name)[0]; foreach ($this->excludedEvents as $excludedEvent) { if (Str::is($excludedEvent, $eventClass)) { return; } } if (! $this->collectValues) { $this->addMeasure($name, $currentTime, $currentTime, [], null, $eventClass); return; } $params = $this->prepareParams($data); // Find all listeners for the current event foreach ($this->events->getListeners($name) as $i => $listener) { // Check if it's an object + method name if (is_array($listener) && count($listener) > 1 && is_object($listener[0])) { [$class, $method] = $listener; // Skip this class itself if ($class instanceof static) { continue; } // Format the listener to readable format $listener = get_class($class) . '@' . $method; // Handle closures } elseif ($listener instanceof \Closure) { $reflector = new \ReflectionFunction($listener); // Skip our own listeners if ($reflector->getNamespaceName() == 'Barryvdh\Debugbar') { continue; } // Format the closure to a readable format $filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/'); $lines = $reflector->getStartLine() . '-' . $reflector->getEndLine(); $listener = $reflector->getName() . ' (' . $filename . ':' . $lines . ')'; } else { // Not sure if this is possible, but to prevent edge cases $listener = $this->getDataFormatter()->formatVar($listener); } $params['listeners.' . $i] = $listener; } $this->addMeasure($name, $currentTime, $currentTime, $params, null, $eventClass); } public function subscribe(Dispatcher $events): void { $this->events = $events; $events->listen('*', [$this, 'onWildcardEvent']); } protected function prepareParams(array $params): array { $data = []; foreach ($params as $key => $value) { if (is_object($value) && Str::is('Illuminate\*\Events\*', get_class($value))) { $value = $this->prepareParams(get_object_vars($value)); } $data[$key] = htmlentities($this->getDataFormatter()->formatVar($value), ENT_QUOTES, 'UTF-8', false); } return $data; } public function collect(): array { $data = parent::collect(); $data['nb_measures'] = $data['count'] = count($data['measures']); return $data; } public function getName(): string { return 'event'; } public function getWidgets(): array { return [ "events" => [ "icon" => "subtask", "widget" => "PhpDebugBar.Widgets.TimelineWidget", "map" => "event", "default" => "{}", ], 'events:badge' => [ 'map' => 'event.nb_measures', 'default' => 0, ], ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/RequestCollector.php
src/DataCollector/RequestCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use DebugBar\DataCollector\Renderable; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Config; use Illuminate\Support\Str; use Laravel\Telescope\IncomingEntry; use Laravel\Telescope\Telescope; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * * Based on \Symfony\Component\HttpKernel\DataCollector\RequestDataCollector by Fabien Potencier <fabien@symfony.com> * */ class RequestCollector extends DataCollector implements DataCollectorInterface, Renderable { protected Request $request; protected Response $response; protected ?SessionInterface $session; protected ?string $currentRequestId = null; protected array $hiddens = []; public function __construct( Request $request, Response $response, ?SessionInterface $session = null, ?string $currentRequestId = null, array $hiddens = [] ) { $this->request = $request; $this->response = $response; $this->session = $session; $this->currentRequestId = $currentRequestId; $this->hiddens = array_merge($hiddens, [ 'request_request.password', 'request_headers.php-auth-pw.0', ]); } /** * {@inheritDoc} */ public function getName(): string { return 'request'; } /** * {@inheritDoc} */ public function getWidgets(): array { $widgets = [ "request" => [ "icon" => "tags", "widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget", "map" => "request.data", "order" => -100, "default" => "{}", ], 'request:badge' => [ "map" => "request.badge", "default" => "null", ], ]; if (Config::get('debugbar.options.request.label', true)) { $widgets['currentrequest'] = [ "icon" => "share-3", "map" => "request.data.uri", "link" => "request", "default" => "", ]; $widgets['currentrequest:tooltip'] = [ "map" => "request.tooltip", "default" => "{}", ]; } return $widgets; } /** * {@inheritdoc} */ public function collect(): array { $request = $this->request; $response = $this->response; $responseHeaders = $response->headers->all(); $cookies = []; foreach ($response->headers->getCookies() as $cookie) { $cookies[] = $this->getCookieHeader( $cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly(), ); } if (count($cookies) > 0) { $responseHeaders['Set-Cookie'] = $cookies; } $statusCode = $response->getStatusCode(); $startTime = defined('LARAVEL_START') ? LARAVEL_START : $request->server->get('REQUEST_TIME_FLOAT'); $query = $request->getQueryString(); $htmlData = []; $data = [ 'status' => $statusCode . ' ' . (Response::$statusTexts[$statusCode] ?? ''), 'duration' => $startTime ? $this->getDataFormatter()->formatDuration(microtime(true) - $startTime) : null, 'peak_memory' => $this->getDataFormatter()->formatBytes(memory_get_peak_usage(true), 1), ]; if ($request instanceof \Illuminate\Http\Request) { if ($route = $request->route()) { $htmlData += $this->getRouteInformation($route); } $fullUrl = $request->fullUrl(); $data += [ 'full_url' => strlen($fullUrl) > 100 ? [$fullUrl] : $fullUrl, ]; } if ($response instanceof RedirectResponse) { $data['response'] = 'Redirect to ' . $response->getTargetUrl(); } $data += [ 'response' => $response->headers->get('Content-Type') ? $response->headers->get( 'Content-Type', ) : 'text/html', 'request_format' => $request->getRequestFormat(), 'request_query' => $request->query->all(), 'request_request' => $request->request->all(), 'request_headers' => $request->headers->all(), 'request_cookies' => $request->cookies->all(), 'response_headers' => $responseHeaders, ]; if ($this->session) { $data['session_attributes'] = $this->session->all(); } if (isset($data['request_headers']['authorization'][0])) { $data['request_headers']['authorization'][0] = substr($data['request_headers']['authorization'][0], 0, 12) . '******'; } foreach ($this->hiddens as $key) { if (Arr::has($data, $key)) { Arr::set($data, $key, '******'); } } foreach ($data as $key => $var) { if (!is_string($data[$key])) { $data[$key] = DataCollector::getDefaultVarDumper()->renderVar($var); } else { $data[$key] = e($data[$key]); } } if (class_exists(Telescope::class)) { $entry = IncomingEntry::make([ 'requestId' => $this->currentRequestId, ])->type('debugbar'); Telescope::$entriesQueue[] = $entry; $url = route('debugbar.telescope', [$entry->uuid]); $htmlData['telescope'] = '<a href="' . $url . '" target="_blank">View in Telescope</a>'; } $tooltip = [ 'status' => $data['status'], ]; if ($this->request instanceof \Illuminate\Http\Request) { $tooltip += [ 'full_url' => Str::limit($this->request->fullUrl(), 100), 'action_name' => $this->request->route()?->getName(), 'controller_action' => $this->request->route()?->getActionName(), ]; } unset($htmlData['as'], $htmlData['uses']); return [ 'data' => $tooltip + $htmlData + $data, 'tooltip' => array_filter($tooltip), 'badge' => $statusCode >= 300 ? $data['status'] : null, ]; } protected function getRouteInformation(mixed $route): array { if (!is_a($route, 'Illuminate\Routing\Route')) { return []; } $uri = head($route->methods()) . ' ' . $route->uri(); $action = $route->getAction(); $result = [ 'uri' => $uri ?: '-', ]; $result = array_merge($result, $action); $uses = $action['uses'] ?? null; $controller = is_string($action['controller'] ?? null) ? $action['controller'] : ''; if (request()->hasHeader('X-Livewire')) { try { $component = request('components')[0]; $name = json_decode($component['snapshot'], true)['memo']['name']; $method = $component['calls'][0]['method']; $class = app(\Livewire\Mechanisms\ComponentRegistry::class)->getClass($name); if (class_exists($class) && method_exists($class, $method)) { $controller = $class . '@' . $method; $result['controller'] = ltrim($controller, '\\'); } } catch (\Throwable $e) { // } } if (str_contains($controller, '@')) { [$controller, $method] = explode('@', $controller); if (class_exists($controller) && method_exists($controller, $method)) { $reflector = new \ReflectionMethod($controller, $method); } unset($result['uses']); } elseif ($uses instanceof \Closure) { $reflector = new \ReflectionFunction($uses); $result['uses'] = $this->getDataFormatter()->formatVar($uses); } elseif (is_string($uses) && str_contains($uses, '@__invoke')) { if (class_exists($controller) && method_exists($controller, 'render')) { $reflector = new \ReflectionMethod($controller, 'render'); $result['controller'] = $controller . '@render'; } } if (isset($reflector)) { $filename = $this->normalizeFilePath($reflector->getFileName()); $result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine()); if ($link = $this->getXdebugLink($reflector->getFileName(), $reflector->getStartLine())) { $result['file'] = [ 'value' => $result['file'], 'xdebug_link' => $link, ]; if (isset($result['controller']) && is_string($result['controller'])) { $result['controller'] = [ 'value' => $result['controller'], 'xdebug_link' => $link, ]; } } } if (isset($result['middleware']) && is_array($result['middleware'])) { $middleware = implode(', ', $result['middleware']); unset($result['middleware']); $result['middleware'] = $middleware; } return array_filter($result); } protected function getCookieHeader(string $name, ?string $value, int $expires, string $path, ?string $domain, bool $secure, bool $httponly): string { $cookie = sprintf('%s=%s', $name, urlencode($value ?? '')); if (0 !== $expires) { if (is_numeric($expires)) { $expires = (int) $expires; } elseif ($expires instanceof \DateTime) { $expires = $expires->getTimestamp(); } else { $expires = strtotime((string) $expires); if (false === $expires || -1 == $expires) { throw new \InvalidArgumentException('The "expires" cookie parameter is not valid.'); } } $cookie .= '; expires=' . substr( \DateTime::createFromFormat('U', (string) $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5, ); } if ($domain) { $cookie .= '; domain=' . $domain; } $cookie .= '; path=' . $path; if ($secure) { $cookie .= '; secure'; } if ($httponly) { $cookie .= '; httponly'; } return $cookie; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/ViewCollector.php
src/DataCollector/ViewCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\TemplateCollector; use Illuminate\View\View; class ViewCollector extends TemplateCollector { public function getName(): string { return 'views'; } /** * Add a View instance to the Collector */ public function addView(View $view): void { $name = $view->getName(); $type = null; $data = $view->getData(); $path = $view->getPath(); if (class_exists('\Inertia\Inertia')) { [$name, $type, $data, $path] = $this->getInertiaView($name, $data, $path); } if (is_object($path)) { $type = get_class($view); $path = null; } if ($path) { if (!$type) { if (substr($path, -10) == '.blade.php') { $type = 'blade'; } else { $type = pathinfo($path, PATHINFO_EXTENSION); } } $shortPath = $this->normalizeFilePath($path); foreach ($this->exclude_paths as $excludePath) { if (str_starts_with($shortPath, $excludePath)) { return; } } } $this->addTemplate($name, $data, $type, $path); if ($this->timeCollector !== null) { $time = microtime(true); $this->timeCollector->addMeasure('View: ' . $name, $time, $time, [], 'views', 'View'); } } private function getInertiaView(string $name, array $data, ?string $path): array { if (isset($data['page']) && is_array($data['page'])) { $data = $data['page']; } if (isset($data['props'], $data['component'])) { $name = $data['component']; $data = $data['props']; if ($files = glob(resource_path(config('debugbar.options.views.inertia_pages') . '/' . $name . '.*'))) { $path = $files[0]; $type = pathinfo($path, PATHINFO_EXTENSION); if (in_array($type, ['js', 'jsx'])) { $type = 'react'; } } } return [$name, $type ?? '', $data, $path]; } public function addInertiaAjaxView(array $data): void { [$name, $type, $data, $path] = $this->getInertiaView('', $data, ''); if (! $name) { return; } $this->addTemplate($name, $data, $type, $path); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/ConfigCollector.php
src/DataCollector/ConfigCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use Illuminate\Config\Repository; class ConfigCollector extends \DebugBar\DataCollector\ConfigCollector { protected Repository $config; public function __construct(Repository $config, $name = 'config') { $this->config = $config; parent::__construct([], $name); } public function collect(): array { // Gather data on collect $this->setData($this->config->all()); return parent::collect(); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/QueryCollector.php
src/DataCollector/QueryCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use Barryvdh\Debugbar\Support\Explain; use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; use DebugBar\DataCollector\TimeDataCollector; use DebugBar\DataFormatter\QueryFormatter; use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Str; /** * Collects data about SQL statements executed with PDO */ class QueryCollector extends DataCollector implements Renderable, AssetProvider { protected array $queries = []; protected int $queryCount = 0; protected int $transactionEventsCount = 0; protected int $infoStatements = 0; protected ?int $softLimit = null; protected ?int $hardLimit = null; protected ?int $lastMemoryUsage = null; protected bool|int $findSource = false; protected array $middleware = []; protected bool $explainQuery = false; protected array $explainTypes = ['SELECT']; // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ protected array $reflection = []; protected array $excludePaths = []; protected array $backtraceExcludePaths = [ '/vendor/laravel/framework/src/Illuminate/Support', '/vendor/laravel/framework/src/Illuminate/Database', '/vendor/laravel/framework/src/Illuminate/Events', '/vendor/laravel/framework/src/Illuminate/Collections', '/vendor/october/rain', '/vendor/barryvdh/laravel-debugbar', ]; protected ?QueryFormatter $queryFormatter = null; protected ?TimeDataCollector $timeCollector; protected bool $renderSqlWithParams = false; protected bool $durationBackground = false; protected ?float $slowThreshold = null; public function __construct(?TimeDataCollector $timeCollector = null) { $this->timeCollector = $timeCollector; } public function getQueryFormatter(): QueryFormatter { if ($this->queryFormatter === null) { $this->queryFormatter = new QueryFormatter(); } return $this->queryFormatter; } /** * @param int|null $softLimit After the soft limit, no parameters/backtrace are captured * @param int|null $hardLimit After the hard limit, queries are ignored */ public function setLimits(?int $softLimit, ?int $hardLimit): void { $this->softLimit = $softLimit; $this->hardLimit = $hardLimit; } /** * Renders the SQL of traced statements with params embedded */ public function setRenderSqlWithParams(bool $enabled = true): void { $this->renderSqlWithParams = $enabled; } /** * Enable/disable finding the source */ public function setFindSource(bool|int $value, array $middleware): void { $this->findSource = $value; $this->middleware = $middleware; } public function mergeExcludePaths(array $excludePaths): void { $this->excludePaths = array_merge($this->excludePaths, $excludePaths); } /** * Set additional paths to exclude from the backtrace */ public function mergeBacktraceExcludePaths(array $excludePaths): void { $this->backtraceExcludePaths = array_merge($this->backtraceExcludePaths, $excludePaths); } /** * Enable/disable the shaded duration background on queries */ public function setDurationBackground(bool $enabled): void { $this->durationBackground = $enabled; } /** * Highlights queries that exceed the threshold * * @param int|float $threshold miliseconds value */ public function setSlowThreshold(int|float $threshold): void { $this->slowThreshold = $threshold / 1000; } public function isSqlRenderedWithParams(): bool { return $this->renderSqlWithParams; } /** * Enable/disable the EXPLAIN queries */ public function setExplainSource(bool $enabled): void { $this->explainQuery = $enabled; } public function startMemoryUsage(): void { $this->lastMemoryUsage = memory_get_usage(false); } public function addQuery(QueryExecuted $query): void { $this->queryCount++; if ($this->hardLimit && $this->queryCount > $this->hardLimit) { return; } $limited = $this->softLimit && $this->queryCount > $this->softLimit; $sql = (string) $query->sql; $time = $query->time / 1000; $endTime = microtime(true); $startTime = $endTime - $time; $source = []; if (!$limited && $this->findSource) { try { $source = $this->findSource(); } catch (\Exception $e) { } } $bindings = match (true) { $limited && filled($query->bindings) => [], default => $query->connection->prepareBindings($query->bindings), }; $this->queries[] = [ 'query' => $sql, 'type' => 'query', 'bindings' => $bindings, 'start' => $startTime, 'time' => $time, 'memory' => $this->lastMemoryUsage ? memory_get_usage(false) - $this->lastMemoryUsage : 0, 'source' => $source, 'connection' => $query->connection, 'driver' => $query->connection->getConfig('driver'), ]; if ($this->timeCollector !== null) { $this->timeCollector->addMeasure(Str::limit($sql, 100), $startTime, $endTime, [], 'db', 'Database Query'); } } /** * Use a backtrace to search for the origins of the query. */ protected function findSource(): array { $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, app('config')->get('debugbar.debug_backtrace_limit', 50)); $sources = []; foreach ($stack as $index => $trace) { $sources[] = $this->parseTrace($index, $trace); } return array_slice(array_filter($sources), 0, is_int($this->findSource) ? $this->findSource : 5); } /** * Parse a trace element from the backtrace stack. */ protected function parseTrace(int $index, array $trace): object|bool { $frame = (object) [ 'index' => $index, 'namespace' => null, 'name' => null, 'file' => null, 'line' => $trace['line'] ?? '1', ]; if (isset($trace['function']) && $trace['function'] == 'substituteBindings') { $frame->name = 'Route binding'; return $frame; } if ( isset($trace['class']) && isset($trace['file']) && !$this->fileIsInExcludedPath($trace['file']) ) { $frame->file = $trace['file']; if (isset($trace['object']) && is_a($trace['object'], '\Twig\Template')) { [$frame->file, $frame->line] = $this->getTwigInfo($trace); } elseif (str_contains($frame->file, storage_path())) { $hash = pathinfo($frame->file, PATHINFO_FILENAME); if ($frame->name = $this->findViewFromHash($hash)) { $frame->file = $frame->name[1]; $frame->name = $frame->name[0]; } else { $frame->name = $hash; } $frame->namespace = 'view'; return $frame; } elseif (str_contains($frame->file, 'Middleware')) { $frame->name = $this->findMiddlewareFromFile($frame->file); if ($frame->name) { $frame->namespace = 'middleware'; } else { $frame->name = $this->normalizeFilePath($frame->file); } return $frame; } $frame->name = $this->normalizeFilePath($frame->file); return $frame; } return false; } /** * Check if the given file is to be excluded from analysis */ protected function fileIsInExcludedPath(string $file): bool { $normalizedPath = str_replace('\\', '/', $file); foreach ($this->backtraceExcludePaths as $excludedPath) { if (str_contains($normalizedPath, $excludedPath)) { return true; } } return false; } /** * Find the middleware alias from the file. */ protected function findMiddlewareFromFile(string $file): ?string { $filename = pathinfo($file, PATHINFO_FILENAME); foreach ($this->middleware as $alias => $class) { if (is_string($class) && str_contains($class, $filename)) { return $alias; } } return null; } /** * Find the template name from the hash. */ protected function findViewFromHash(string $hash): ?array { $finder = app('view')->getFinder(); if (isset($this->reflection['viewfinderViews'])) { $property = $this->reflection['viewfinderViews']; } else { $reflection = new \ReflectionClass($finder); $property = $reflection->getProperty('views'); $this->reflection['viewfinderViews'] = $property; } $xxh128Exists = in_array('xxh128', hash_algos()); foreach ($property->getValue($finder) as $name => $path) { if (($xxh128Exists && hash('xxh128', 'v2' . $path) == $hash) || sha1('v2' . $path) == $hash) { return [$name, $path]; } } return null; } /** * Get the filename/line from a Twig template trace */ protected function getTwigInfo(array $trace): array { $file = $trace['object']->getTemplateName(); if (isset($trace['line'])) { foreach ($trace['object']->getDebugInfo() as $codeLine => $templateLine) { if ($codeLine <= $trace['line']) { return [$file, $templateLine]; } } } return [$file, -1]; } /** * Collect a database transaction event. */ public function collectTransactionEvent(string $event, mixed $connection): void { $this->transactionEventsCount++; $source = []; if ($this->findSource) { try { $source = $this->findSource(); } catch (\Exception $e) { } } $this->queries[] = [ 'query' => $event, 'type' => 'transaction', 'bindings' => [], 'start' => microtime(true), 'time' => 0, 'memory' => 0, 'source' => $source, 'connection' => $connection, 'driver' => $connection->getConfig('driver'), ]; } /** * Reset the queries. */ public function reset(): void { $this->queries = []; $this->queryCount = 0; $this->infoStatements = 0 ; } /** * {@inheritDoc} */ public function collect(): array { $totalTime = 0; $totalMemory = 0; $queries = $this->queries; $statements = []; foreach ($queries as $query) { $source = reset($query['source']); $normalizedPath = is_object($source) ? $this->normalizeFilePath($source->file ?: '') : ''; if ($query['type'] != 'transaction' && Str::startsWith($normalizedPath, $this->excludePaths)) { continue; } $totalTime += $query['time']; $totalMemory += $query['memory']; $connectionName = $query['connection']->getDatabaseName(); if (str_ends_with($connectionName, '.sqlite')) { $connectionName = $this->normalizeFilePath($connectionName); } $canExplainQuery = match (true) { in_array($query['driver'], ['mariadb', 'mysql', 'pgsql']) => $query['bindings'] !== null && preg_match('/^\s*(' . implode('|', $this->explainTypes) . ') /i', $query['query']), default => false, }; $statements[] = [ 'sql' => $this->getSqlQueryToDisplay($query), 'type' => $query['type'], 'params' => $query['bindings'] ?? [], 'backtrace' => array_values($query['source']), 'start' => $query['start'] ?? null, 'duration' => $query['time'], 'duration_str' => ($query['type'] == 'transaction') ? '' : $this->getDataFormatter()->formatDuration($query['time']), 'slow' => $this->slowThreshold && $this->slowThreshold <= $query['time'], 'memory' => $query['memory'], 'memory_str' => $query['memory'] ? $this->getDataFormatter()->formatBytes($query['memory']) : null, 'filename' => $source ? $this->getQueryFormatter()->formatSource($source, true) : null, 'source' => $source, 'xdebug_link' => is_object($source) ? $this->getXdebugLink($source->file ?: '', $source->line) : null, 'connection' => $connectionName, 'explain' => $this->explainQuery && $canExplainQuery ? [ 'url' => route('debugbar.queries.explain'), 'driver' => $query['driver'], 'connection' => $query['connection']->getName(), 'query' => $query['query'], 'hash' => (new Explain())->hash($query['connection']->getName(), $query['query'], $query['bindings']), ] : null, ]; } if ($this->durationBackground) { if ($totalTime > 0) { // For showing background measure on Queries tab $start_percent = 0; foreach ($statements as $i => $statement) { if (!isset($statement['duration'])) { continue; } $width_percent = $statement['duration'] / $totalTime * 100; $statements[$i] = array_merge($statement, [ 'start_percent' => round($start_percent, 3), 'width_percent' => round($width_percent, 3), ]); $start_percent += $width_percent; } } } if ($this->softLimit && $this->hardLimit && ($this->queryCount > $this->softLimit && $this->queryCount > $this->hardLimit)) { array_unshift($statements, [ 'sql' => '# Query soft and hard limit for Debugbar are reached. Only the first ' . $this->softLimit . ' queries show details. Queries after the first ' . $this->hardLimit . ' are ignored. Limits can be raised in the config (debugbar.options.db.soft/hard_limit).', 'type' => 'info', ]); $statements[] = [ 'sql' => '... ' . ($this->queryCount - $this->hardLimit) . ' additional queries are executed but now shown because of Debugbar query limits. Limits can be raised in the config (debugbar.options.db.soft/hard_limit)', 'type' => 'info', ]; $this->infoStatements += 2; } elseif ($this->hardLimit && $this->queryCount > $this->hardLimit) { array_unshift($statements, [ 'sql' => '# Query hard limit for Debugbar is reached after ' . $this->hardLimit . ' queries, additional ' . ($this->queryCount - $this->hardLimit) . ' queries are not shown.. Limits can be raised in the config (debugbar.options.db.hard_limit)', 'type' => 'info', ]); $statements[] = [ 'sql' => '... ' . ($this->queryCount - $this->hardLimit) . ' additional queries are executed but now shown because of Debugbar query limits. Limits can be raised in the config (debugbar.options.db.hard_limit)', 'type' => 'info', ]; $this->infoStatements += 2; } elseif ($this->softLimit && $this->queryCount > $this->softLimit) { array_unshift($statements, [ 'sql' => '# Query soft limit for Debugbar is reached after ' . $this->softLimit . ' queries, additional ' . ($this->queryCount - $this->softLimit) . ' queries only show the query. Limits can be raised in the config (debugbar.options.db.soft_limit)', 'type' => 'info', ]); $this->infoStatements++; } $visibleStatements = count($statements) - $this->infoStatements; $data = [ 'count' => $visibleStatements, 'nb_statements' => $this->queryCount, 'nb_visible_statements' => $visibleStatements, 'nb_excluded_statements' => $this->queryCount + $this->transactionEventsCount - $visibleStatements, 'nb_failed_statements' => 0, 'accumulated_duration' => $totalTime, 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($totalTime), 'memory_usage' => $totalMemory, 'memory_usage_str' => $totalMemory ? $this->getDataFormatter()->formatBytes($totalMemory) : null, 'statements' => $statements, ]; return $data; } /** * {@inheritDoc} */ public function getName(): string { return 'queries'; } /** * {@inheritDoc} */ public function getWidgets(): array { return [ "queries" => [ "icon" => "database", "widget" => "PhpDebugBar.Widgets.LaravelQueriesWidget", "map" => "queries", "default" => "[]", ], "queries:badge" => [ "map" => "queries.nb_statements", "default" => 0, ], ]; } protected function getSqlQueryToDisplay(array $query): string { $sql = $query['query']; if ($query['type'] === 'query' && $this->renderSqlWithParams && $query['connection']->getQueryGrammar() instanceof \Illuminate\Database\Query\Grammars\Grammar && method_exists($query['connection']->getQueryGrammar(), 'substituteBindingsIntoRawSql')) { try { $sql = $query['connection']->getQueryGrammar()->substituteBindingsIntoRawSql($sql, $query['bindings'] ?? []); return $this->getQueryFormatter()->formatSql($sql); } catch (\Throwable $e) { // Continue using the old substitute } } if ($query['type'] === 'query' && $this->renderSqlWithParams) { $pdo = null; try { $pdo = $query['connection']->getPdo(); } catch (\Throwable) { // ignore error for non-pdo laravel drivers } $sql = $this->getQueryFormatter()->formatSqlWithBindings($sql, $query['bindings'], $pdo); } return $this->getQueryFormatter()->formatSql($sql); } public function getAssets(): array { return [ 'js' => [ 'widgets/sqlqueries/widget.js', __DIR__ . '/../../resources/queries/widget.js', ], 'css' => 'widgets/sqlqueries/widget.css', ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/RouteCollector.php
src/DataCollector/RouteCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use Closure; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; use Illuminate\Routing\Router; /** * Based on Illuminate\Foundation\Console\RoutesCommand for Taylor Otwell * https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Console/RoutesCommand.php * */ class RouteCollector extends DataCollector implements Renderable { /** * The router instance. * * @var \Illuminate\Routing\Router */ protected $router; public function __construct(Router $router) { $this->router = $router; } /** * {@inheritDoc} */ public function collect(): array { $route = $this->router->current(); return $this->getRouteInformation($route); } /** * Get the route information for a given route. */ protected function getRouteInformation(mixed $route): array { if (!is_a($route, 'Illuminate\Routing\Route')) { return []; } $uri = head($route->methods()) . ' ' . $route->uri(); $action = $route->getAction(); $result = [ 'uri' => $uri, ]; $result = array_merge($result, $action); $uses = $action['uses'] ?? null; $controller = is_string($action['controller'] ?? null) ? $action['controller'] : ''; if (request()->hasHeader('X-Livewire')) { try { $component = request('components')[0]; $name = json_decode($component['snapshot'], true)['memo']['name']; $method = $component['calls'][0]['method']; $class = app(\Livewire\Mechanisms\ComponentRegistry::class)->getClass($name); if (class_exists($class) && method_exists($class, $method)) { $controller = $class . '@' . $method; $result['controller'] = ltrim($controller, '\\'); } } catch (\Throwable $e) { // } } if (str_contains($controller, '@')) { [$controller, $method] = explode('@', $controller); if (class_exists($controller) && method_exists($controller, $method)) { $reflector = new \ReflectionMethod($controller, $method); } unset($result['uses']); } elseif ($uses instanceof \Closure) { $reflector = new \ReflectionFunction($uses); $result['uses'] = $this->getDataFormatter()->formatVar($uses); } elseif (is_string($uses) && str_contains($uses, '@__invoke')) { if (class_exists($controller) && method_exists($controller, 'render')) { $reflector = new \ReflectionMethod($controller, 'render'); $result['controller'] = $controller . '@render'; } } if (isset($reflector)) { $filename = $this->normalizeFilePath($reflector->getFileName()); $result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine()); if ($link = $this->getXdebugLink($reflector->getFileName(), $reflector->getStartLine())) { $result['file'] = [ 'value' => $result['file'], 'xdebug_link' => $link, ]; if (isset($result['controller'])) { $result['controller'] = [ 'value' => $result['controller'], 'xdebug_link' => $link, ]; } } } if ($middleware = $this->getMiddleware($route)) { $result['middleware'] = $middleware; } return array_filter($result); } /** * Get middleware */ protected function getMiddleware(mixed $route): string { return implode(', ', array_map(function ($middleware) { return $middleware instanceof Closure ? 'Closure' : $middleware; }, $route->gatherMiddleware())); } /** * {@inheritDoc} */ public function getName(): string { return 'route'; } /** * {@inheritDoc} */ public function getWidgets(): array { $widgets = [ "route" => [ "icon" => "share-3", "widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget", "map" => "route", "default" => "{}", ], ]; return $widgets; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/LivewireCollector.php
src/DataCollector/LivewireCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use DebugBar\DataCollector\Renderable; use Illuminate\Contracts\View\View; use Illuminate\Http\Request; use Livewire\Livewire; use Livewire\Component; /** * Collector for Models. */ class LivewireCollector extends DataCollector implements DataCollectorInterface, Renderable { public $data = []; public function __construct(Request $request) { // Listen to Livewire views Livewire::listen('view:render', function (View $view) use ($request) { /** @var \Livewire\Component $component */ $component = $view->getData()['_instance']; // Create a unique name for each component $key = $component->getName() . ' #' . $component->id; $data = [ 'data' => $component->getPublicPropertiesDefinedBySubClass(), ]; if ($request->request->get('id') == $component->id) { $data['oldData'] = $request->request->get('data'); $data['actionQueue'] = $request->request->get('actionQueue'); } $data['name'] = $component->getName(); $data['view'] = $view->name(); $data['component'] = get_class($component); $data['id'] = $component->id; $this->data[$key] = $this->getDataFormatter()->formatVar($data); }); Livewire::listen('render', function (Component $component) use ($request) { // Create an unique name for each compoent $key = $component->getName() . ' #' . $component->getId(); $data = [ 'data' => $component->all(), ]; if ($request->request->get('id') == $component->getId()) { $data['oldData'] = $request->request->get('data'); $data['actionQueue'] = $request->request->get('actionQueue'); } $data['name'] = $component->getName(); $data['component'] = get_class($component); $data['id'] = $component->getId(); $this->data[$key] = $this->getDataFormatter()->formatVar($data); }); } public function collect(): array { return ['data' => $this->data, 'count' => count($this->data)]; } /** * {@inheritDoc} */ public function getName(): string { return 'livewire'; } /** * {@inheritDoc} */ public function getWidgets(): array { return [ "livewire" => [ "icon" => "brand-livewire", "widget" => "PhpDebugBar.Widgets.VariableListWidget", "map" => "livewire.data", "default" => "{}", ], 'livewire:badge' => [ 'map' => 'livewire.count', 'default' => 0, ], ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/PennantCollector.php
src/DataCollector/PennantCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use DebugBar\DataCollector\Renderable; use Illuminate\Support\Facades\Config; use Laravel\Pennant\FeatureManager; class PennantCollector extends DataCollector implements DataCollectorInterface, Renderable { protected FeatureManager $manager; /** * Create a new SessionCollector * */ public function __construct(FeatureManager $manager) { $this->manager = $manager; } /** * {@inheritdoc} */ public function collect(): array { $store = $this->manager->store(Config::get('pennant.default')); return $store->values($store->stored()); } /** * {@inheritDoc} */ public function getName(): string { return 'pennant'; } /** * {@inheritDoc} */ public function getWidgets(): array { return [ "pennant" => [ "icon" => "flag", "widget" => "PhpDebugBar.Widgets.VariableListWidget", "map" => "pennant", "default" => "{}", ], ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/MultiAuthCollector.php
src/DataCollector/MultiAuthCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\Guard; use Illuminate\Support\Str; use Illuminate\Contracts\Support\Arrayable; /** * Collector for Laravel's Auth provider */ class MultiAuthCollector extends DataCollector implements Renderable { /** @var array $guards */ protected $guards; /** @var \Illuminate\Auth\AuthManager */ protected $auth; /** @var bool */ protected $showName = false; /** @var bool */ protected $showGuardsData = true; /** * @param \Illuminate\Auth\AuthManager $auth * @param array $guards */ public function __construct($auth, $guards) { $this->auth = $auth; $this->guards = $guards; } /** * Set to show the users name/email */ public function setShowName(bool $showName): void { $this->showName = (bool) $showName; } /** * Set to hide the guards tab, and show only name */ public function setShowGuardsData(bool $showGuardsData): void { $this->showGuardsData = (bool) $showGuardsData; } /** * @{inheritDoc} */ public function collect(): array { $data = [ 'guards' => [], ]; $names = ''; foreach ($this->guards as $guardName => $config) { try { $guard = $this->auth->guard($guardName); if ($this->hasUser($guard)) { $user = $guard->user(); if (!is_null($user)) { $data['guards'][$guardName] = $this->getUserInformation($user); $names .= $guardName . ": " . $data['guards'][$guardName]['name'] . ', '; } } else { $data['guards'][$guardName] = null; } } catch (\Exception $e) { continue; } } foreach ($data['guards'] as $key => $var) { if (!is_string($data['guards'][$key])) { $data['guards'][$key] = $this->getDataFormatter()->formatVar($var); } } $data['names'] = rtrim($names, ', '); if (!$this->showGuardsData) { unset($data['guards']); } return $data; } private function hasUser(Guard $guard): bool { if (method_exists($guard, 'hasUser')) { return $guard->hasUser(); } return false; } /** * Get displayed user information */ protected function getUserInformation(mixed $user = null): array { // Defaults if (is_null($user)) { return [ 'name' => 'Guest', 'user' => ['guest' => true], ]; } // The default auth identifer is the ID number, which isn't all that // useful. Try username, email and name. $identifier = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->getKey(); if (is_numeric($identifier) || Str::isUuid($identifier) || Str::isUlid($identifier)) { try { if (isset($user->username)) { $identifier = $user->username; } elseif (isset($user->email)) { $identifier = $user->email; } elseif (isset($user->name)) { $identifier = Str::limit($user->name, 24); } } catch (\Throwable $e) { } } return [ 'name' => $identifier, 'user' => $user instanceof Arrayable ? $user->toArray() : $user, ]; } /** * @{inheritDoc} */ public function getName(): string { return 'auth'; } /** * @{inheritDoc} */ public function getWidgets(): array { $widgets = []; if ($this->showGuardsData) { $widgets["auth"] = [ "icon" => "lock", "widget" => "PhpDebugBar.Widgets.VariableListWidget", "map" => "auth.guards", "default" => "{}", ]; } if ($this->showName) { $widgets['auth.name'] = [ 'icon' => 'user', 'tooltip' => 'Auth status', 'map' => 'auth.names', 'default' => '', ]; } return $widgets; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/GateCollector.php
src/DataCollector/GateCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\MessagesCollector; use DebugBar\DataFormatter\SimpleFormatter; use Illuminate\Auth\Access\Response; use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Database\Eloquent\Model; use Illuminate\Routing\Router; use Illuminate\Support\Str; /** * Collector for Laravel's gate checks */ class GateCollector extends MessagesCollector { protected array $reflection = []; protected Router $router; public function __construct(Gate $gate, Router $router) { parent::__construct('gate'); $this->router = $router; $this->setDataFormatter(new SimpleFormatter()); $gate->after(function ($user, $ability, $result, $arguments = []) { $this->addCheck($user, $ability, $result, $arguments); }); } /** * {@inheritDoc} */ protected function customizeMessageHtml(?string $messageHtml, mixed $message): ?string { $pos = strpos((string) $messageHtml, 'array:5'); if ($pos !== false) { $name = $message['ability'] . ' ' . ($message['target'] ?? ''); $messageHtml = substr_replace($messageHtml, $name, $pos, 7); } return parent::customizeMessageHtml($messageHtml, $message); } public function addCheck(mixed $user, string $ability, mixed $result, array $arguments = []): void { $userKey = 'user'; $userId = null; if ($user) { $userKey = Str::snake(class_basename($user)); $userId = $user instanceof Authenticatable ? $user->getAuthIdentifier() : $user->getKey(); } $label = $result ? 'success' : 'error'; if ($result instanceof Response) { $label = $result->allowed() ? 'success' : 'error'; } $target = null; if (isset($arguments[0])) { if ($arguments[0] instanceof Model) { $model = $arguments[0]; if ($model->getKeyName() && isset($model[$model->getKeyName()])) { $target = get_class($model) . '(' . $model->getKeyName() . '=' . $model->getKey() . ')'; } else { $target = get_class($model); } } elseif (is_string($arguments[0])) { $target = $arguments[0]; } } $this->addMessage([ 'ability' => $ability, 'target' => $target, 'result' => $result, $userKey => $userId, 'arguments' => $this->getDataFormatter()->formatVar($arguments), ], $label, false); } protected function getStackTraceItem(array $stacktrace): array { foreach ($stacktrace as $i => $trace) { if (!isset($trace['file'])) { continue; } if (str_ends_with($trace['file'], 'Illuminate/Routing/ControllerDispatcher.php')) { $trace = $this->findControllerFromDispatcher($trace); } elseif (str_starts_with($trace['file'], storage_path())) { $hash = pathinfo($trace['file'], PATHINFO_FILENAME); if ($file = $this->findViewFromHash($hash)) { $trace['file'] = $file; } } if ($this->fileIsInExcludedPath($trace['file'])) { continue; } return $trace; } return $stacktrace[0]; } /** * Find the route action file */ protected function findControllerFromDispatcher(array $trace): array { /** @var \Closure|string|array $action */ $action = $this->router->current()->getAction('uses'); if (is_string($action)) { [$controller, $method] = explode('@', $action); $reflection = new \ReflectionMethod($controller, $method); $trace['file'] = $reflection->getFileName(); $trace['line'] = $reflection->getStartLine(); } elseif ($action instanceof \Closure) { $reflection = new \ReflectionFunction($action); $trace['file'] = $reflection->getFileName(); $trace['line'] = $reflection->getStartLine(); } return $trace; } /** * Find the template name from the hash. */ protected function findViewFromHash(string $hash): ?string { $finder = app('view')->getFinder(); if (isset($this->reflection['viewfinderViews'])) { $property = $this->reflection['viewfinderViews']; } else { $reflection = new \ReflectionClass($finder); $property = $reflection->getProperty('views'); $this->reflection['viewfinderViews'] = $property; } $xxh128Exists = in_array('xxh128', hash_algos()); foreach ($property->getValue($finder) as $name => $path) { if (($xxh128Exists && hash('xxh128', 'v2' . $path) == $hash) || sha1('v2' . $path) == $hash) { return $path; } } return null; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/SessionCollector.php
src/DataCollector/SessionCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use DebugBar\DataCollector\Renderable; use Illuminate\Support\Arr; use Symfony\Component\HttpFoundation\Session\SessionInterface; class SessionCollector extends DataCollector implements DataCollectorInterface, Renderable { protected SessionInterface $session; /** @var array */ protected $hiddens; public function __construct(SessionInterface $session, array $hiddens = []) { $this->session = $session; $this->hiddens = $hiddens; } /** * {@inheritdoc} */ public function collect(): array { $data = $this->session->all(); foreach ($this->hiddens as $key) { if (Arr::has($data, $key)) { Arr::set($data, $key, '******'); } } foreach ($data as $key => $value) { $data[$key] = is_string($value) ? $value : $this->getDataFormatter()->formatVar($value); } return $data; } /** * {@inheritDoc} */ public function getName(): string { return 'session'; } /** * {@inheritDoc} */ public function getWidgets(): array { return [ "session" => [ "icon" => "archive", "widget" => "PhpDebugBar.Widgets.VariableListWidget", "map" => "session", "default" => "{}", ], ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/DataCollector/CacheCollector.php
src/DataCollector/CacheCollector.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\DataCollector; use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\TimeDataCollector; use DebugBar\DataFormatter\HasDataFormatter; use Illuminate\Cache\Events\{ CacheFlushed, CacheFlushFailed, CacheFlushing, CacheHit, CacheMissed, ForgettingKey, KeyForgetFailed, KeyForgotten, KeyWriteFailed, KeyWritten, RetrievingKey, WritingKey, }; use Illuminate\Events\Dispatcher; class CacheCollector extends TimeDataCollector implements AssetProvider { use HasDataFormatter; /** @var bool */ protected $collectValues; /** @var array */ protected $eventStarts = []; /** @var array */ protected $classMap = [ CacheHit::class => ['hit', RetrievingKey::class], CacheMissed::class => ['missed', RetrievingKey::class], CacheFlushed::class => ['flushed', CacheFlushing::class], CacheFlushFailed::class => ['flush_failed', CacheFlushing::class], KeyWritten::class => ['written', WritingKey::class], KeyWriteFailed::class => ['write_failed', WritingKey::class], KeyForgotten::class => ['forgotten', ForgettingKey::class], KeyForgetFailed::class => ['forget_failed', ForgettingKey::class], ]; public function __construct(float $requestStartTime, bool $collectValues) { parent::__construct($requestStartTime); $this->collectValues = $collectValues; $this->memoryMeasure = true; } public function onCacheEvent(mixed $event): void { $class = get_class($event); $params = get_object_vars($event); $label = $this->classMap[$class][0]; if (isset($params['value'])) { $params['memoryUsage'] = strlen(serialize($params['value'])) * 8; if ($this->collectValues) { if ($this->isHtmlVarDumperUsed()) { $params['value'] = $this->getVarDumper()->renderVar($params['value']); } else { $params['value'] = htmlspecialchars($this->getDataFormatter()->formatVar($params['value'])); } } else { unset($params['value']); } } if (!empty($params['key'] ?? null) && in_array($label, ['hit', 'written'])) { $params['delete'] = route('debugbar.cache.delete', [ 'key' => urlencode($params['key']), 'tags' => !empty($params['tags']) ? json_encode($params['tags']) : '', ]); } $time = microtime(true); $startHashKey = $this->getEventHash($this->classMap[$class][1] ?? '', $params); $startTime = $this->eventStarts[$startHashKey] ?? $time; $this->addMeasure($label . "\t" . ($params['key'] ?? ''), $startTime, $time, $params); } public function onStartCacheEvent(mixed $event): void { $startHashKey = $this->getEventHash(get_class($event), get_object_vars($event)); $this->eventStarts[$startHashKey] = microtime(true); } protected function getEventHash(string $class, array $params): string { unset($params['value']); return $class . ':' . substr(hash('sha256', json_encode($params)), 0, 12); } public function subscribe(Dispatcher $dispatcher): void { foreach (array_keys($this->classMap) as $eventClass) { $dispatcher->listen($eventClass, [$this, 'onCacheEvent']); } $startEvents = array_unique(array_filter(array_map( fn($values) => $values[1] ?? null, array_values($this->classMap), ))); foreach ($startEvents as $eventClass) { $dispatcher->listen($eventClass, [$this, 'onStartCacheEvent']); } } public function collect(): array { $data = parent::collect(); $data['nb_measures'] = $data['count'] = count($data['measures']); return $data; } public function getName(): string { return 'cache'; } public function getWidgets(): array { return [ 'cache' => [ 'icon' => 'clipboard-text', 'widget' => 'PhpDebugBar.Widgets.LaravelCacheWidget', 'map' => 'cache', 'default' => '{}', ], 'cache:badge' => [ 'map' => 'cache.nb_measures', 'default' => 'null', ], ]; } public function getAssets(): array { return [ 'js' => __DIR__ . '/../../resources/cache/widget.js', ]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Facades/Debugbar.php
src/Facades/Debugbar.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Facades; use Barryvdh\Debugbar\LaravelDebugbar; use DebugBar\DataCollector\DataCollectorInterface; /** * @method static LaravelDebugbar addCollector(DataCollectorInterface $collector) * @method static void addMessage(mixed $message, string $label = 'info') * @method static void alert(mixed $message) * @method static void critical(mixed $message) * @method static void debug(mixed $message) * @method static void emergency(mixed $message) * @method static void error(mixed $message) * @method static LaravelDebugbar getCollector(string $name) * @method static bool hasCollector(string $name) * @method static void info(mixed $message) * @method static void log(mixed $message) * @method static void notice(mixed $message) * @method static void warning(mixed $message) * * @see \Barryvdh\Debugbar\LaravelDebugbar */ class Debugbar extends \Illuminate\Support\Facades\Facade { /** * {@inheritDoc} */ protected static function getFacadeAccessor() { return \Barryvdh\Debugbar\LaravelDebugbar::class; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Console/ClearCommand.php
src/Console/ClearCommand.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Console; use DebugBar\DebugBar; use Illuminate\Console\Command; class ClearCommand extends Command { protected $name = 'debugbar:clear'; protected $description = 'Clear the Debugbar Storage'; protected $debugbar; public function __construct(DebugBar $debugbar) { $this->debugbar = $debugbar; parent::__construct(); } public function handle() { $this->debugbar->boot(); if ($storage = $this->debugbar->getStorage()) { try { $storage->clear(); } catch (\InvalidArgumentException $e) { // hide InvalidArgumentException if storage location does not exist if (!str_contains($e->getMessage(), 'does not exist')) { throw $e; } } $this->info('Debugbar Storage cleared!'); } else { $this->error('No Debugbar Storage found..'); } } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Middleware/InjectDebugbar.php
src/Middleware/InjectDebugbar.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Middleware; use Closure; use Exception; use Illuminate\Http\Request; use Barryvdh\Debugbar\LaravelDebugbar; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Debug\ExceptionHandler; use Throwable; class InjectDebugbar { /** * The App container * * @var Container */ protected $container; /** * The DebugBar instance * * @var LaravelDebugbar */ protected $debugbar; /** * The URIs that should be excluded. * * @var array */ protected $except = []; /** * Create a new middleware instance. * */ public function __construct(Container $container, LaravelDebugbar $debugbar) { $this->container = $container; $this->debugbar = $debugbar; $this->except = config('debugbar.except') ?: []; } /** * Handle an incoming request. * * @param Request $request */ public function handle($request, Closure $next) { if (!$this->debugbar->isEnabled() || $this->inExceptArray($request)) { return $next($request); } $this->debugbar->boot(); try { /** @var \Illuminate\Http\Response $response */ $response = $next($request); } catch (Throwable $e) { $response = $this->handleException($request, $e); } // Modify the response to add the Debugbar $this->debugbar->modifyResponse($request, $response); return $response; } /** * Handle the given exception. * * (Copy from Illuminate\Routing\Pipeline by Taylor Otwell) * * @param Throwable $e * * @throws Exception */ protected function handleException($passable, $e) { if (! $this->container->bound(ExceptionHandler::class) || ! $passable instanceof Request) { throw $e; } $handler = $this->container->make(ExceptionHandler::class); $handler->report($e); return $handler->render($passable, $e); } /** * Determine if the request has a URI that should be ignored. * * @param \Illuminate\Http\Request $request * * @return bool */ protected function inExceptArray($request) { foreach ($this->except as $except) { if ($except !== '/') { $except = trim($except, '/'); } if ($request->is($except)) { return true; } } return false; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/src/Middleware/DebugbarEnabled.php
src/Middleware/DebugbarEnabled.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Middleware; use Closure; use Illuminate\Http\Request; use Barryvdh\Debugbar\LaravelDebugbar; class DebugbarEnabled { /** * The DebugBar instance * * @var LaravelDebugbar */ protected $debugbar; /** * Create a new middleware instance. * */ public function __construct(LaravelDebugbar $debugbar) { $this->debugbar = $debugbar; } /** * Handle an incoming request. * * @param Request $request */ public function handle($request, Closure $next) { if (!$this->debugbar->isEnabled()) { abort(404); } return $next($request); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DebugbarTest.php
tests/DebugbarTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests; use Barryvdh\Debugbar\LaravelDebugbar; use Illuminate\Support\Str; class DebugbarTest extends TestCase { /** * Define environment setup. * * @param \Illuminate\Foundation\Application $app * * @return void */ protected function getEnvironmentSetUp($app) { parent::getEnvironmentSetUp($app); // Force the Debugbar to Enable on test/cli applications $app->resolving(LaravelDebugbar::class, function ($debugbar) { $refObject = new \ReflectionObject($debugbar); $refProperty = $refObject->getProperty('enabled'); $refProperty->setValue($debugbar, true); }); } public function testItInjectsOnPlainText() { $crawler = $this->call('GET', 'web/plain'); $this->assertTrue(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItInjectsOnEmptyResponse() { $crawler = $this->call('GET', 'web/empty'); $this->assertTrue(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItInjectsOnNullyResponse() { $crawler = $this->call('GET', 'web/null'); $this->assertTrue(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItInjectsOnHtml() { $crawler = $this->call('GET', 'web/html'); $this->assertTrue(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItDoesntInjectOnJson() { $crawler = $this->call('GET', 'api/ping'); $this->assertFalse(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItDoesntInjectOnJsonLookingString() { $crawler = $this->call('GET', 'web/fakejson'); $this->assertFalse(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItDoesntInjectsOnHxRequestWithHxTarget() { $crawler = $this->get('web/html', [ 'Hx-Request' => 'true', 'Hx-Target' => 'main', ]); $this->assertFalse(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } public function testItInjectsOnHxRequestWithoutHxTarget() { $crawler = $this->get('web/html', [ 'Hx-Request' => 'true', ]); $this->assertTrue(Str::contains($crawler->content(), 'debugbar')); $this->assertEquals(200, $crawler->getStatusCode()); $this->assertNotEmpty($crawler->headers->get('phpdebugbar-id')); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/ErrorHandlerTest.php
tests/ErrorHandlerTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests; use Barryvdh\Debugbar\LaravelDebugbar; use ReflectionObject; class ErrorHandlerTest extends TestCase { /** * Define environment setup. * * @param \Illuminate\Foundation\Application $app * * @return void */ protected function getEnvironmentSetUp($app) { parent::getEnvironmentSetUp($app); // Force the Debugbar to Enable on test/cli applications $app->resolving(LaravelDebugbar::class, function ($debugbar) { $refObject = new ReflectionObject($debugbar); $refProperty = $refObject->getProperty('enabled'); $refProperty->setValue($debugbar, true); }); // Enable collectors needed for error handling $app['config']->set('debugbar.collectors.messages', true); $app['config']->set('debugbar.collectors.exceptions', true); } public function testErrorHandlerRespectsCustomErrorLevel() { $app = $this->app; $app['config']->set('debugbar.error_handler', true); // Exclude deprecation warnings $app['config']->set('debugbar.error_level', E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED); $debugbar = $app->make(LaravelDebugbar::class); $debugbar->boot(); // Get initial message count $initialCount = 0; if ($debugbar->hasCollector('messages')) { $initialCount = count($debugbar->getCollector('messages')->collect()['messages']); } // Trigger a deprecation warning - should NOT be captured @trigger_error('Test deprecation warning', E_USER_DEPRECATED); // Check that error was NOT captured if ($debugbar->hasCollector('messages')) { $messages = $debugbar->getCollector('messages')->collect(); $newCount = count($messages['messages']); $this->assertEquals($initialCount, $newCount, 'Deprecation warning should not be captured when excluded from error_level'); } // Trigger a warning (not a deprecation) - should be captured @trigger_error('Test warning', E_USER_WARNING); // Check that warning WAS captured if ($debugbar->hasCollector('messages')) { $messages = $debugbar->getCollector('messages')->collect(); $finalCount = count($messages['messages']); $this->assertGreaterThan($initialCount, $finalCount, 'Non-deprecation errors should still be captured'); } } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/TestCase.php
tests/TestCase.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests; use Barryvdh\Debugbar\Facades\Debugbar; use Barryvdh\Debugbar\ServiceProvider; use Illuminate\Routing\Router; use Orchestra\Testbench\TestCase as Orchestra; use Barryvdh\Debugbar\Tests\Mocks\MockController; use Barryvdh\Debugbar\Tests\Mocks\MockViewComponent; use Barryvdh\Debugbar\Tests\Mocks\MockMiddleware; class TestCase extends Orchestra { /** * Get package providers. * * @param \Illuminate\Foundation\Application $app * * @return array */ protected function getPackageProviders($app) { return [ServiceProvider::class]; } /** * Get package aliases. * * @param \Illuminate\Foundation\Application $app * * @return array */ protected function getPackageAliases($app) { return ['Debugbar' => Debugbar::class]; } /** * Define environment setup. * * @param \Illuminate\Foundation\Application $app * * @return void */ protected function getEnvironmentSetUp($app) { /** @var Router $router */ $router = $app['router']; $app['config']->set('debugbar.hide_empty_tabs', false); $this->addWebRoutes($router); $this->addApiRoutes($router); $this->addViewPaths(); } protected function addWebRoutes(Router $router) { $router->get('web/plain', function () { return 'PONG'; }); $router->get('web/empty', function () { return ''; }); $router->get('web/null', function () { return null; }); $router->get('web/html', function () { return '<html><head></head><body>Pong</body></html>'; }); $router->get('web/fakejson', function () { return '{"foo":"bar"}'; }); $router->get('web/show', [MockController::class, 'show']); $router->get('web/view', MockViewComponent::class); $router->post('web/mw')->middleware(MockMiddleware::class); } protected function addApiRoutes(Router $router) { $router->get('api/ping', [ 'uses' => function () { return response()->json(['status' => 'pong']); }, ]); } protected function addViewPaths() { config(['view.paths' => array_merge(config('view.paths'), [__DIR__ . '/resources/views'])]); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DebugbarBrowserTest.php
tests/DebugbarBrowserTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests; use Illuminate\Routing\Router; use Laravel\Dusk\Browser; use Illuminate\Database\Events\QueryExecuted; use Illuminate\Database\Connection; class DebugbarBrowserTest extends BrowserTestCase { /** * Define environment setup. * * @param \Illuminate\Foundation\Application $app * * @return void */ protected function getEnvironmentSetUp($app) { parent::getEnvironmentSetUp($app); $app['env'] = 'local'; //$app['config']->set('app.debug', true); $app['config']->set('debugbar.hide_empty_tabs', false); /** @var Router $router */ $router = $app['router']; $this->addWebRoutes($router); $this->addApiRoutes($router); $this->addViewPaths(); $kernel = app(\Illuminate\Contracts\Http\Kernel::class); $kernel->pushMiddleware(\Illuminate\Session\Middleware\StartSession::class); $kernel->pushMiddleware(\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class); // \Orchestra\Testbench\Dusk\Options::withoutUI(); } protected function addWebRoutes(Router $router) { $router->get('web/redirect', [ 'uses' => function () { return redirect($this->applicationBaseUrl() . '/web/plain'); }, ]); $router->get('web/plain', [ 'uses' => function () { return 'PONG'; }, ]); $router->get('web/html', [ 'uses' => function () { return '<html><head></head><body>HTMLPONG</body></html>'; }, ]); $router->get('web/ajax', [ 'uses' => function () { return view('ajax'); }, ]); $router->get('web/custom-prototype', [ 'uses' => function () { /** @var Connection $connection */ $connection = $this->app['db']->connectUsing( 'runtime-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', ], ); event(new QueryExecuted('SELECT * FROM users WHERE username = ?', ['debuguser'], 0, $connection)); return view('custom-prototype'); }, ]); $router->get('web/query/{num?}', [ 'uses' => function ($num = 1) { debugbar()->boot(); /** @var Connection $connection */ $connection = $this->app['db']->connectUsing( 'runtime-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', ], ); foreach (range(1, $num) as $i) { $executedQuery = new QueryExecuted('SELECT * FROM users WHERE username = ?', ['debuguser' . $i], 0, $connection); event($executedQuery); } return 'PONG'; }, ]); } protected function addApiRoutes(Router $router) { $router->get('api/ping', [ 'uses' => function () { return response()->json(['status' => 'pong']); }, ]); } protected function addViewPaths() { config(['view.paths' => array_merge(config('view.paths'), [__DIR__ . '/resources/views'])]); } public function testItStacksOnRedirect() { $this->browse(function (Browser $browser) { $browser->visit('web/redirect') ->assertSee('PONG') ->waitFor('.phpdebugbar') ->assertSee('GET web/plain') ->click('.phpdebugbar-tab-history') ->waitForTextIn('.phpdebugbar-widgets-dataset-history', 'web/redirect (stacked)') ->assertSee('web/redirect'); }); } public function testItInjectsOnPlainText() { $this->browse(function ($browser) { $browser->visit('web/plain') ->assertSee('PONG') ->waitFor('.phpdebugbar') ->assertSee('GET web/plain'); }); } public function testItInjectsOnHtml() { $this->browse(function ($browser) { $browser->visit('web/html') ->assertSee('HTMLPONG') ->waitFor('.phpdebugbar') ->assertSee('GET web/html'); }); } public function testItDoesntInjectOnJson() { $this->browse(function ($browser) { $browser->visit('api/ping') ->assertSee('pong') ->assertSourceMissing('debugbar') ->assertDontSee('GET api/ping'); }); } public function testItCapturesAjaxRequests() { $this->browse(function (Browser $browser) { $browser->visit('web/ajax') ->waitFor('.phpdebugbar') ->assertSee('GET web/ajax') ->click('#ajax-link') ->waitForTextIn('#result', 'pong') ->assertSee('GET api/ping'); }); } public function testDatabaseTabIsClickable() { $this->browse(function (Browser $browser) { $browser->visit('web/plain') ->waitFor('.phpdebugbar') ->assertDontSee('0 statements were executed') ->click('.phpdebugbar-tab[data-collector="queries"]') ->assertSee('0 statements were executed'); }); } public function testDatabaseCollectsQueries() { $this->browse(function (Browser $browser) { $browser->visit('web/query') ->waitFor('.phpdebugbar') ->click('.phpdebugbar-tab-history') ->waitForTextIn('.phpdebugbar-tab[data-collector="queries"] .phpdebugbar-badge', 1) ->click('.phpdebugbar-tab[data-collector="queries"]') ->screenshotElement('.phpdebugbar', 'queries-tab') ->waitForText('executed') ->waitForText('1 statements were executed') ->with('.phpdebugbar-widgets-sqlqueries', function ($queriesPane) { $queriesPane->assertSee('SELECT * FROM users') ->click('.phpdebugbar-widgets-list-item:nth-child(2)') ->assertSee('Params') ->assertSee('debuguser') ->assertSee('Backtrace') ->assertSee('DatabaseCollectorProvider.php:'); }) ->screenshotElement('.phpdebugbar', 'queries-expanded'); }); } public function testDatabaseCollectsQueriesWithCustomPrototype() { if (version_compare($this->app->version(), '10', '<')) { $this->markTestSkipped('This test is not compatible with Laravel 9.x and below'); } $this->browse(function (Browser $browser) { $browser->visit('web/custom-prototype') ->waitFor('.phpdebugbar') ->click('.phpdebugbar-tab-history') ->waitForTextIn('.phpdebugbar-tab[data-collector="queries"] .phpdebugbar-badge', 1) ->click('.phpdebugbar-tab[data-collector="queries"]') ->screenshotElement('.phpdebugbar', 'queries-tab') ->waitForText('executed') ->assertSee('1 statements were executed') ->with('.phpdebugbar-widgets-sqlqueries', function ($queriesPane) { $queriesPane->assertSee('SELECT * FROM users') ->click('.phpdebugbar-widgets-list-item:nth-child(2)') ->assertSee('Params') ->assertSee('debuguser') ->assertSee('Backtrace') ->assertSee('DatabaseCollectorProvider.php:'); }) ->screenshotElement('.phpdebugbar', 'queries-expanded'); }); } public function testDatabaseCollectsQueriesWithSoftLimit() { $this->browse(function (Browser $browser) { $browser->visit('web/query/200') ->waitFor('.phpdebugbar') ->click('.phpdebugbar-tab-history') ->waitForTextIn('.phpdebugbar-tab[data-collector="queries"] .phpdebugbar-badge', 200, 30) ->click('.phpdebugbar-tab[data-collector="queries"]') ->screenshotElement('.phpdebugbar', 'queries-tab') ->waitForText('executed') ->waitForText('200 statements were executed, 100 of which were duplicates, 100 unique.') ->waitForText('Query soft limit for Debugbar is reached after 100 queries, additional 100 queries only show the query.') ->screenshotElement('.phpdebugbar', 'queries-expanded'); }); } public function testDatabaseCollectsQueriesWithHardLimit() { $this->browse(function (Browser $browser) { $browser->visit('web/query/600') ->waitFor('.phpdebugbar') ->click('.phpdebugbar-tab-history') ->waitForTextIn('.phpdebugbar-tab[data-collector="queries"] .phpdebugbar-badge', 600) ->click('.phpdebugbar-tab[data-collector="queries"]') ->screenshotElement('.phpdebugbar', 'queries-tab') ->waitForText('executed') ->waitForText('600 statements were executed, 400 of which were duplicates, 200 unique.') ->waitForText('Query soft and hard limit for Debugbar are reached. Only the first 100 queries show details. Queries after the first 500 are ignored. ') ->screenshotElement('.phpdebugbar', 'queries-expanded'); }); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/BrowserTestCase.php
tests/BrowserTestCase.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests; use Barryvdh\Debugbar\Facades\Debugbar; use Barryvdh\Debugbar\ServiceProvider; class BrowserTestCase extends \Orchestra\Testbench\Dusk\TestCase { protected static $baseServeHost = '127.0.0.1'; protected static $baseServePort = 9292; /** * Get package providers. * * @param \Illuminate\Foundation\Application $app * * @return array */ protected function getPackageProviders($app) { return [ServiceProvider::class]; } /** * Get package aliases. * * @param \Illuminate\Foundation\Application $app * * @return array */ protected function getPackageAliases($app) { return ['Debugbar' => Debugbar::class]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Jobs/OrderShipped.php
tests/Jobs/OrderShipped.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Jobs; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class OrderShipped implements ShouldQueue { use Dispatchable; private $orderId; public function __construct($orderId) { $this->orderId = $orderId; } public function handle() { // Do Nothing } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Jobs/SendNotification.php
tests/Jobs/SendNotification.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Jobs; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class SendNotification implements ShouldQueue { use Dispatchable; public function handle() { // Do Nothing } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Mocks/MockViewComponent.php
tests/Mocks/MockViewComponent.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Mocks; use Illuminate\View\InvokableComponentVariable; class MockViewComponent extends InvokableComponentVariable { public function render() { return view('dashboard'); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Mocks/MockMiddleware.php
tests/Mocks/MockMiddleware.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Mocks; use Closure; class MockMiddleware { public function handle($request, Closure $next) { return $next($request); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Mocks/MockController.php
tests/Mocks/MockController.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Mocks; use Illuminate\Routing\Controller; class MockController extends Controller { public function show() { return view('dashboard'); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataFormatter/QueryFormatterTest.php
tests/DataFormatter/QueryFormatterTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataFormatter; use DebugBar\DataFormatter\QueryFormatter; use Barryvdh\Debugbar\Tests\TestCase; class QueryFormatterTest extends TestCase { public function testItFormatsArrayBindings() { $bindings = [ 'some string', [ 'string', "Another ' string", [ 'nested', 'array', ], ], ]; $queryFormatter = new QueryFormatter(); $output = $queryFormatter->checkBindings($bindings); $this->assertSame($output, ["some string", "[string,Another ' string,[nested,array]]"]); } public function testItFormatsObjectBindings() { $object = new \StdClass(); $object->attribute1 = 'test'; $bindings = [ 'some string', $object, ]; $queryFormatter = new QueryFormatter(); $output = $queryFormatter->checkBindings($bindings); $this->assertSame($output, ['some string', '{"attribute1":"test"}']); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/GateCollectorTest.php
tests/DataCollector/GateCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\Models\User; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Support\Facades\Gate; class GateCollectorTest extends TestCase { public function testItCollectsGateChecks() { debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\GateCollector $collector */ $collector = debugbar()->getCollector('gate'); $collector->useHtmlVarDumper(false); $user = new User([ 'id' => 1, 'name' => 'John Doe', 'email' => 'john@example.com', 'password' => 'password', ]); $user->can('test'); Gate::before(function ($user, $ability, $result, $arguments = []) { return true; }); $user->can('test'); $collect = $collector->collect(); $this->assertEquals(2, $collect['count']); $gateError = $collect['messages'][0]; $this->assertEquals('error', $gateError['label']); $this->assertEquals( '[ability => test, target => null, result => null, user => 1, arguments => []]', $gateError['message'], ); $gateSuccess = $collect['messages'][1]; $this->assertEquals('success', $gateSuccess['label']); $this->assertEquals( '[ability => test, target => null, result => true, user => 1, arguments => []]', $gateSuccess['message'], ); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/ModelsCollectorTest.php
tests/DataCollector/ModelsCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\Models\Person; use Barryvdh\Debugbar\Tests\Models\User; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Hash; class ModelsCollectorTest extends TestCase { use RefreshDatabase; public function testItCollectsRetrievedModels() { $this->loadLaravelMigrations(); debugbar()->boot(); /** @var \DebugBar\DataCollector\ObjectCountCollector $collector */ $collector = debugbar()->getCollector('models'); $collector->setXdebugLinkTemplate(''); $collector->collectCountSummary(false); $collector->setKeyMap([]); $data = []; $this->assertEquals( ['data' => $data, 'key_map' => [], 'count' => 0, 'is_counter' => true], $collector->collect(), ); User::create([ 'name' => 'John Doe', 'email' => 'john@example.com', 'password' => Hash::make('password'), ]); User::create([ 'name' => 'Jane Doe', 'email' => 'jane@example.com', 'password' => Hash::make('password'), ]); $data[User::class] = ['created' => 2]; $this->assertEquals( [ 'data' => $data, 'count' => 2, 'is_counter' => true, 'key_map' => [ ], ], $collector->collect(), ); $user = User::first(); $data[User::class]['retrieved'] = 1; $this->assertEquals( ['data' => $data, 'key_map' => [], 'count' => 3, 'is_counter' => true], $collector->collect(), ); $user->update(['name' => 'Jane Doe']); $data[User::class]['updated'] = 1; $this->assertEquals( [ 'data' => $data, 'count' => 4, 'is_counter' => true, 'key_map' => [], ], $collector->collect(), ); Person::all(); $data[Person::class] = ['retrieved' => 2]; $this->assertEquals( ['data' => $data, 'key_map' => [], 'count' => 6, 'is_counter' => true], $collector->collect(), ); $user->delete(); $data[User::class]['deleted'] = 1; $this->assertEquals( [ 'data' => $data, 'count' => 7, 'is_counter' => true, 'key_map' => [ ], ], $collector->collect(), ); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/SessionCollectorTest.php
tests/DataCollector/SessionCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\TestCase; use Barryvdh\Debugbar\DataCollector\SessionCollector; use Illuminate\Session\SymfonySessionDecorator; class SessionCollectorTest extends TestCase { protected function getEnvironmentSetUp($app) { $app['config']->set('debugbar.options.session.hiddens', ['secret']); parent::getEnvironmentSetUp($app); } public function testItCollectsSessionVariables() { $collector = new SessionCollector( $this->app->make(SymfonySessionDecorator::class), $this->app['config']->get('debugbar.options.session.hiddens', []), ); $this->assertEmpty($collector->collect()); $this->withSession(['testVariable' => 1, 'secret' => 'testSecret'])->get('/'); $collected = $collector->collect(); $this->assertNotEmpty($collected); $this->assertArrayHasKey('secret', $collected); $this->assertArrayHasKey('testVariable', $collected); $this->assertEquals($collected['secret'], '******'); $this->assertEquals($collected['testVariable'], 1); $this->flushSession(); $this->assertCount(0, $collector->collect()); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/QueryCollectorRuntimeDatabaseTest.php
tests/DataCollector/QueryCollectorRuntimeDatabaseTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Database\Connection; class QueryCollectorRuntimeDatabaseTest extends TestCase { protected function getEnvironmentSetUp($app) { $app['config']->set('database.default', null); $app['config']->set('database.connections', []); } public function testCollectsQueriesFromRuntimeConnections() { if (version_compare($this->app->version(), '10', '<')) { $this->markTestSkipped('This test is not compatible with Laravel 9.x and below'); } debugbar()->boot(); /** @var Connection $connection */ $connection = $this->app['db']->connectUsing( 'runtime-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', ], ); $connection->statement('SELECT 1'); /** @var \Debugbar\DataCollector\ExceptionsCollector $collector */ $exceptions = debugbar()->getCollector('exceptions'); self::assertEmpty($exceptions->getExceptions()); /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ $collector = debugbar()->getCollector('queries'); tap($collector->collect(), function (array $collection) { $this->assertEquals(1, $collection['nb_statements']); self::assertSame('SELECT 1', $collection['statements'][1]['sql']); }); } public function testCollectsQueriesFromRuntimeConnectionsWithoutConnectUsing() { debugbar()->boot(); $this->app['config']->set('database.connections.dynamic-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', ]); $this->app['config']->set('database.default', 'dynamic-connection'); /** @var Connection $connection */ $connection = $this->app['db']->connection('dynamic-connection'); $connection->statement('SELECT 1'); /** @var \Debugbar\DataCollector\ExceptionsCollector $collector */ $exceptions = debugbar()->getCollector('exceptions'); self::assertEmpty($exceptions->getExceptions()); /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ $collector = debugbar()->getCollector('queries'); tap($collector->collect(), function (array $collection) { $this->assertEquals(1, $collection['nb_statements']); self::assertSame('SELECT 1', $collection['statements'][1]['sql']); }); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/ViewCollectorTest.php
tests/DataCollector/ViewCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Arr; class ViewCollectorTest extends TestCase { use RefreshDatabase; public function testIdeLinksAreAbsolutePaths() { debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\ViewCollector $collector */ $collector = debugbar()->getCollector('views'); $collector->addView( view('dashboard'), ); tap(Arr::first($collector->collect()['templates']), function (array $template) { $this->assertEquals( 'phpstorm://open?file=' . urlencode(str_replace('\\', '/', realpath(__DIR__ . '/../resources/views/dashboard.blade.php'))) . '&line=1', $template['xdebug_link']['url'], ); }); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/JobsCollectorTest.php
tests/DataCollector/JobsCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\Jobs\OrderShipped; use Barryvdh\Debugbar\Tests\Jobs\SendNotification; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Schema; class JobsCollectorTest extends TestCase { use RefreshDatabase; protected function getEnvironmentSetUp($app) { $app['config']->set('debugbar.collectors.jobs', true); // The `sync` and `null` driver don't dispatch events // `database` or `redis` driver work great $app['config']->set('queue.default', 'database'); parent::getEnvironmentSetUp($app); } public function testItCollectsDispatchedJobs() { $this->loadLaravelMigrations(); $this->createJobsTable(); debugbar()->boot(); /** @var \DebugBar\DataCollector\ObjectCountCollector $collector */ $collector = debugbar()->getCollector('jobs'); $collector->setXdebugLinkTemplate(''); $collector->setKeyMap([]); $data = []; $this->assertEquals( [ 'data' => $data, 'count' => 0, 'is_counter' => true, 'key_map' => [], ], $collector->collect(), ); OrderShipped::dispatch(1); $data[OrderShipped::class] = ['value' => 1]; $this->assertEquals( [ 'data' => $data, 'count' => 1, 'is_counter' => true, 'key_map' => [], ], $collector->collect(), ); dispatch(new SendNotification()); dispatch(new SendNotification()); dispatch(new SendNotification()); $data[SendNotification::class] = ['value' => 3]; $this->assertEquals( [ 'data' => $data, 'count' => 4, 'is_counter' => true, 'key_map' => [], ], $collector->collect(), ); } protected function createJobsTable() { (new class extends Migration { public function up() { if (Schema::hasTable('jobs')) { return; } Schema::create('jobs', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('queue')->index(); $table->longText('payload'); $table->unsignedTinyInteger('attempts'); $table->unsignedInteger('reserved_at')->nullable(); $table->unsignedInteger('available_at'); $table->unsignedInteger('created_at'); }); } })->up(); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/RouteCollectorTest.php
tests/DataCollector/RouteCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\TestCase; use DebugBar\DataCollector\DataCollector; class RouteCollectorTest extends TestCase { /** @var \Barryvdh\Debugbar\DataCollector\RouteCollector $collector */ private DataCollector $routeCollector; protected function setUp(): void { parent::setUp(); debugbar()->boot(); $this->routeCollector = debugbar()->getCollector('route'); } protected function getEnvironmentSetUp($app) { $app['config']->set('debugbar.collectors.route', true); parent::getEnvironmentSetUp($app); } public function testItCollectsRouteUri() { $this->get('web/html'); $this->assertSame('GET web/html', $this->routeCollector->collect()['uri']); $this->call('POST', 'web/mw'); $this->assertSame('POST web/mw', $this->routeCollector->collect()['uri']); } /** * @dataProvider controllerData */ public function testItCollectsWithControllerHandler($controller, $file, $url) { $this->get('web/show'); $collected = $this->routeCollector->collect(); $this->assertNotEmpty($collected); $this->assertArrayHasKey('file', $collected); $this->assertArrayHasKey('controller', $collected); $this->assertStringContainsString($file, $collected['file']['value']); $this->assertStringContainsString($url, $collected['file']['xdebug_link']['url']); $this->assertStringContainsString($controller, $collected['controller']['value']); $this->assertStringContainsString($url, $collected['controller']['xdebug_link']['url']); } /** * @dataProvider viewComponentData */ public function testItCollectsWithViewComponentHandler($controller, $file, $url) { $this->get('web/view'); $collected = $this->routeCollector->collect(); $this->assertStringContainsString($file, $collected['file']['value']); $this->assertStringContainsString($url, $collected['file']['xdebug_link']['url']); $this->assertStringContainsString($controller, $collected['controller']['value']); $this->assertStringContainsString($url, $collected['controller']['xdebug_link']['url']); } /** * @dataProvider closureData */ public function testItCollectsWithClosureHandler($file) { $this->get('web/html'); $collected = $this->routeCollector->collect(); $this->assertNotEmpty($collected); $this->assertArrayHasKey('uses', $collected); $this->assertArrayHasKey('file', $collected); $this->assertStringContainsString($file, $collected['uses']); $this->assertStringContainsString($file, $collected['file']['value']); } public function testItCollectsMiddleware() { $this->call('POST', 'web/mw'); $collected = $this->routeCollector->collect(); $this->assertNotEmpty($collected); $this->assertArrayHasKey('middleware', $collected); $this->assertStringContainsString('MockMiddleware', $collected['middleware']); } public static function controllerData() { $filePath = urlencode(str_replace('\\', '/', realpath(__DIR__ . '/../Mocks/MockController.php'))); return [['MockController@show', 'MockController.php', sprintf('phpstorm://open?file=%s', $filePath), ]]; } public static function viewComponentData() { $filePath = urlencode(str_replace('\\', '/', realpath(__DIR__ . '/../Mocks/MockViewComponent.php'))); return [['MockViewComponent@render', 'MockViewComponent.php', sprintf('phpstorm://open?file=%s', $filePath), ]]; } public static function closureData() { return [['TestCase.php']]; } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/DataCollector/QueryCollectorTest.php
tests/DataCollector/QueryCollectorTest.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\DataCollector; use Barryvdh\Debugbar\Tests\TestCase; use Illuminate\Database\Events\QueryExecuted; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Arr; class QueryCollectorTest extends TestCase { use RefreshDatabase; public function testItReplacesQuestionMarksBindingsCorrectly() { $this->loadLaravelMigrations(); debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ $collector = debugbar()->getCollector('queries'); $collector->addQuery(new QueryExecuted( "SELECT ('[1, 2, 3]'::jsonb ?? ?) as a, ('[4, 5, 6]'::jsonb ??| ?) as b, 'hello world ? example ??' as c", [3, '{4}'], 0, $this->app['db']->connection(), )); tap($collector->collect(), function (array $collection) { $this->assertEquals(1, $collection['nb_statements']); tap(Arr::first($collection['statements']), function (array $statement) { $this->assertEquals([3, '{4}'], $statement['params']); $this->assertEquals(<<<SQL SELECT ('[1, 2, 3]'::jsonb ? 3) as a, ('[4, 5, 6]'::jsonb ?| '{4}') as b, 'hello world ? example ??' as c SQL, $statement['sql']); }); }); } public function testDollarBindingsArePresentedCorrectly() { debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ $collector = debugbar()->getCollector('queries'); $collector->addQuery(new QueryExecuted( "SELECT a FROM b WHERE c = ? AND d = ? AND e = ?", ['$10', '$2y$10_DUMMY_BCRYPT_HASH', '$_$$_$$$_$2_$3'], 0, $this->app['db']->connection(), )); tap(Arr::first($collector->collect()['statements']), function (array $statement) { $this->assertEquals( "SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'", $statement['sql'], ); }); } public function testFindingCorrectPathForView() { debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ $collector = debugbar()->getCollector('queries'); view('query') ->with('db', $this->app['db']->connection()) ->with('collector', $collector) ->render(); tap(Arr::first($collector->collect()['statements']), function (array $statement) { $this->assertEquals( "SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'", $statement['sql'], ); $this->assertTrue(@file_exists($statement['backtrace'][1]->file)); $this->assertEquals( realpath(__DIR__ . '/../resources/views/query.blade.php'), realpath($statement['backtrace'][1]->file), ); }); } }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Models/User.php
tests/Models/User.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Models; use Illuminate\Foundation\Auth\User as Model; class User extends Model { protected $table = 'users'; protected $guarded = []; }
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/Models/Person.php
tests/Models/Person.php
<?php declare(strict_types=1); namespace Barryvdh\Debugbar\Tests\Models; class Person extends User {}
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/resources/views/query.blade.php
tests/resources/views/query.blade.php
@php $collector->addQuery(new \Illuminate\Database\Events\QueryExecuted( "SELECT a FROM b WHERE c = ? AND d = ? AND e = ?", ['$10', '$2y$10_DUMMY_BCRYPT_HASH', '$_$$_$$$_$2_$3'], 0, $db )); @endphp
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/resources/views/ajax.blade.php
tests/resources/views/ajax.blade.php
<html> <body> <a href="#" id="ajax-link" onclick="loadAjax();return false;">Click me</a> <div id="result">Waiting..</div> <script> async function loadAjax() { try { const response = await fetch('/api/ping'); if (!response.ok) { throw new Error(`Response status: ${response.status}`); } const json = await response.json(); document.getElementById('result').innerText = json.status; } catch (error) { console.error(error.message); } } </script> </body>
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/resources/views/dashboard.blade.php
tests/resources/views/dashboard.blade.php
<div> <p>Basic view</p> </div>
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/tests/resources/views/custom-prototype.blade.php
tests/resources/views/custom-prototype.blade.php
<html> <body> <script> Array.prototype.customRemove = function(item) { const i = this.indexOf(item) if (i > -1) { this.splice(i, 1) } return this } </script> </body>
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/config/debugbar.php
config/debugbar.php
<?php declare(strict_types=1); return [ /* |-------------------------------------------------------------------------- | Debugbar Settings |-------------------------------------------------------------------------- | | Debugbar is enabled by default, when debug is set to true in app.php. | You can override the value by setting enable to true or false instead of null. | | You can provide an array of URI's that must be ignored (eg. 'api/*') | */ 'enabled' => env('DEBUGBAR_ENABLED'), 'except' => [ 'telescope*', 'horizon*', '_boost/browser-logs', ], /* |-------------------------------------------------------------------------- | DataCollectors |-------------------------------------------------------------------------- | | Enable/disable DataCollectors | */ 'collectors' => [ 'phpinfo' => env('DEBUGBAR_COLLECTORS_PHPINFO', false), // Php version 'messages' => env('DEBUGBAR_COLLECTORS_MESSAGES', true), // Messages 'time' => env('DEBUGBAR_COLLECTORS_TIME', true), // Time Datalogger 'memory' => env('DEBUGBAR_COLLECTORS_MEMORY', true), // Memory usage 'exceptions' => env('DEBUGBAR_COLLECTORS_EXCEPTIONS', true), // Exception displayer 'log' => env('DEBUGBAR_COLLECTORS_LOG', true), // Logs from Monolog (merged in messages if enabled) 'db' => env('DEBUGBAR_COLLECTORS_DB', true), // Show database (PDO) queries and bindings 'views' => env('DEBUGBAR_COLLECTORS_VIEWS', true), // Views with their data 'route' => env('DEBUGBAR_COLLECTORS_ROUTE', false), // Current route information 'auth' => env('DEBUGBAR_COLLECTORS_AUTH', false), // Display Laravel authentication status 'gate' => env('DEBUGBAR_COLLECTORS_GATE', true), // Display Laravel Gate checks 'session' => env('DEBUGBAR_COLLECTORS_SESSION', false), // Display session data 'symfony_request' => env('DEBUGBAR_COLLECTORS_SYMFONY_REQUEST', true), // Only one can be enabled.. 'mail' => env('DEBUGBAR_COLLECTORS_MAIL', true), // Catch mail messages 'laravel' => env('DEBUGBAR_COLLECTORS_LARAVEL', true), // Laravel version and environment 'events' => env('DEBUGBAR_COLLECTORS_EVENTS', false), // All events fired 'default_request' => env('DEBUGBAR_COLLECTORS_DEFAULT_REQUEST', false), // Regular or special Symfony request logger 'config' => env('DEBUGBAR_COLLECTORS_CONFIG', false), // Display config settings 'cache' => env('DEBUGBAR_COLLECTORS_CACHE', true), // Display cache events 'models' => env('DEBUGBAR_COLLECTORS_MODELS', true), // Display models 'livewire' => env('DEBUGBAR_COLLECTORS_LIVEWIRE', true), // Display Livewire (when available) 'jobs' => env('DEBUGBAR_COLLECTORS_JOBS', true), // Display dispatched jobs 'pennant' => env('DEBUGBAR_COLLECTORS_PENNANT', true), // Display Pennant feature flags ], /* |-------------------------------------------------------------------------- | Extra options |-------------------------------------------------------------------------- | | Configure some DataCollectors | */ 'options' => [ 'time' => [ 'memory_usage' => env('DEBUGBAR_OPTIONS_TIME_MEMORY_USAGE', false), // Calculated by subtracting memory start and end, it may be inaccurate ], 'messages' => [ 'trace' => env('DEBUGBAR_OPTIONS_MESSAGES_TRACE', true), // Trace the origin of the debug message 'capture_dumps' => env('DEBUGBAR_OPTIONS_MESSAGES_CAPTURE_DUMPS', false), // Capture laravel `dump();` as message ], 'memory' => [ 'reset_peak' => env('DEBUGBAR_OPTIONS_MEMORY_RESET_PEAK', false), // run memory_reset_peak_usage before collecting 'with_baseline' => env('DEBUGBAR_OPTIONS_MEMORY_WITH_BASELINE', false), // Set boot memory usage as memory peak baseline 'precision' => (int) env('DEBUGBAR_OPTIONS_MEMORY_PRECISION', 0), // Memory rounding precision ], 'auth' => [ 'show_name' => env('DEBUGBAR_OPTIONS_AUTH_SHOW_NAME', true), // Also show the users name/email in the debugbar 'show_guards' => env('DEBUGBAR_OPTIONS_AUTH_SHOW_GUARDS', true), // Show the guards that are used ], 'gate' => [ 'trace' => false, // Trace the origin of the Gate checks ], 'db' => [ 'with_params' => env('DEBUGBAR_OPTIONS_WITH_PARAMS', true), // Render SQL with the parameters substituted 'exclude_paths' => [ // Paths to exclude entirely from the collector //'vendor/laravel/framework/src/Illuminate/Session', // Exclude sessions queries ], 'backtrace' => env('DEBUGBAR_OPTIONS_DB_BACKTRACE', true), // Use a backtrace to find the origin of the query in your files. 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) 'timeline' => env('DEBUGBAR_OPTIONS_DB_TIMELINE', false), // Add the queries to the timeline 'duration_background' => env('DEBUGBAR_OPTIONS_DB_DURATION_BACKGROUND', true), // Show shaded background on each query relative to how long it took to execute. 'explain' => [ // Show EXPLAIN output on queries 'enabled' => env('DEBUGBAR_OPTIONS_DB_EXPLAIN_ENABLED', false), ], 'hints' => env('DEBUGBAR_OPTIONS_DB_HINTS', false), // Show hints for common mistakes 'only_slow_queries' => env('DEBUGBAR_OPTIONS_DB_ONLY_SLOW_QUERIES', true), // Only track queries that last longer than `slow_threshold` 'slow_threshold' => env('DEBUGBAR_OPTIONS_DB_SLOW_THRESHOLD', false), // Max query execution time (ms). Exceeding queries will be highlighted 'memory_usage' => env('DEBUGBAR_OPTIONS_DB_MEMORY_USAGE', false), // Show queries memory usage 'soft_limit' => (int) env('DEBUGBAR_OPTIONS_DB_SOFT_LIMIT', 100), // After the soft limit, no parameters/backtrace are captured 'hard_limit' => (int) env('DEBUGBAR_OPTIONS_DB_HARD_LIMIT', 500), // After the hard limit, queries are ignored ], 'mail' => [ 'timeline' => env('DEBUGBAR_OPTIONS_MAIL_TIMELINE', true), // Add mails to the timeline 'show_body' => env('DEBUGBAR_OPTIONS_MAIL_SHOW_BODY', true), ], 'views' => [ 'timeline' => env('DEBUGBAR_OPTIONS_VIEWS_TIMELINE', true), // Add the views to the timeline 'data' => env('DEBUGBAR_OPTIONS_VIEWS_DATA', false), // True for all data, 'keys' for only names, false for no parameters. 'group' => (int) env('DEBUGBAR_OPTIONS_VIEWS_GROUP', 50), // Group duplicate views. Pass value to auto-group, or true/false to force 'inertia_pages' => env('DEBUGBAR_OPTIONS_VIEWS_INERTIA_PAGES', 'js/Pages'), // Path for Inertia views 'exclude_paths' => [ // Add the paths which you don't want to appear in the views 'vendor/filament', // Exclude Filament components by default ], ], 'route' => [ 'label' => env('DEBUGBAR_OPTIONS_ROUTE_LABEL', true), // Show complete route on bar ], 'session' => [ 'hiddens' => [], // Hides sensitive values using array paths ], 'symfony_request' => [ 'label' => env('DEBUGBAR_OPTIONS_SYMFONY_REQUEST_LABEL', true), // Show route on bar 'hiddens' => [], // Hides sensitive values using array paths, example: request_request.password ], 'events' => [ 'data' => env('DEBUGBAR_OPTIONS_EVENTS_DATA', false), // Collect events data, listeners 'excluded' => [], // Example: ['eloquent.*', 'composing', Illuminate\Cache\Events\CacheHit::class] ], 'cache' => [ 'values' => env('DEBUGBAR_OPTIONS_CACHE_VALUES', true), // Collect cache values ], ], /** * Add any additional DataCollectors by adding the class name of a DataCollector or invokable class. */ 'custom_collectors' => [ // MyCollector::class => env('DEBUGBAR_COLLECTORS_MYCOLLECTOR', true), ], /* |-------------------------------------------------------------------------- | Editor |-------------------------------------------------------------------------- | | Choose your preferred editor to use when clicking file name. | | Supported: "sublime", "textmate", "emacs", "macvim", "codelite", | "phpstorm", "phpstorm-remote", "idea", "idea-remote", | "vscode", "vscode-insiders", "vscode-remote", "vscode-insiders-remote", | "vscodium", "nova", "xdebug", "atom", "espresso", | "netbeans", "cursor", "windsurf", "zed", "antigravity" | */ 'editor' => env('DEBUGBAR_EDITOR') ?: env('IGNITION_EDITOR', 'phpstorm'), /* |-------------------------------------------------------------------------- | Capture Ajax Requests |-------------------------------------------------------------------------- | | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), | you can use this option to disable sending the data through the headers. | | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. | | Note for your request to be identified as ajax requests they must either send the header | X-Requested-With with the value XMLHttpRequest (most JS libraries send this), or have application/json as a Accept header. | | By default `ajax_handler_auto_show` is set to true allowing ajax requests to be shown automatically in the Debugbar. | Changing `ajax_handler_auto_show` to false will prevent the Debugbar from reloading. | | You can defer loading the dataset, so it will be loaded with ajax after the request is done. (Experimental) */ 'capture_ajax' => env('DEBUGBAR_CAPTURE_AJAX', true), 'add_ajax_timing' => env('DEBUGBAR_ADD_AJAX_TIMING', false), 'ajax_handler_auto_show' => env('DEBUGBAR_AJAX_HANDLER_AUTO_SHOW', true), 'ajax_handler_enable_tab' => env('DEBUGBAR_AJAX_HANDLER_ENABLE_TAB', true), 'defer_datasets' => env('DEBUGBAR_DEFER_DATASETS', false), /* |-------------------------------------------------------------------------- | Remote Path Mapping |-------------------------------------------------------------------------- | | If you are using a remote dev server, like Laravel Homestead, Docker, or | even a remote VPS, it will be necessary to specify your path mapping. | | Leaving one, or both of these, empty or null will not trigger the remote | URL changes and Debugbar will treat your editor links as local files. | | "remote_sites_path" is an absolute base path for your sites or projects | in Homestead, Vagrant, Docker, or another remote development server. | | Example value: "/home/vagrant/Code" | | "local_sites_path" is an absolute base path for your sites or projects | on your local computer where your IDE or code editor is running on. | | Example values: "/Users/<name>/Code", "C:\Users\<name>\Documents\Code" | */ 'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH'), 'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', env('IGNITION_LOCAL_SITES_PATH')), /* |-------------------------------------------------------------------------- | Storage settings |-------------------------------------------------------------------------- | | Debugbar stores data for session/ajax requests. | You can disable this, so the debugbar stores data in headers/session, | but this can cause problems with large data collectors. | By default, file storage (in the storage folder) is used. Redis and PDO | can also be used. For PDO, run the package migrations first. | | Warning: Enabling storage.open will allow everyone to access previous | request, do not enable open storage in publicly available environments! | Specify a callback if you want to limit based on IP or authentication. | Leaving it to null will allow localhost only. */ 'storage' => [ 'enabled' => env('DEBUGBAR_STORAGE_ENABLED', true), 'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback. 'driver' => env('DEBUGBAR_STORAGE_DRIVER', 'file'), // redis, file, pdo, custom 'path' => env('DEBUGBAR_STORAGE_PATH', storage_path('debugbar')), // For file driver 'connection' => env('DEBUGBAR_STORAGE_CONNECTION'), // Leave null for default connection (Redis/PDO) 'provider' => env('DEBUGBAR_STORAGE_PROVIDER', ''), // Instance of StorageInterface for custom driver ], /* |-------------------------------------------------------------------------- | Assets |-------------------------------------------------------------------------- | | Vendor files are included by default, but can be set to false. | This can also be set to 'js' or 'css', to only include javascript or css vendor files. | Vendor files are for css: (none) | and for js: highlight.js | So if you want syntax highlighting, set it to true. | */ 'use_dist_files' => env('DEBUGBAR_USE_DIST_FILES', true), 'include_vendors' => env('DEBUGBAR_INCLUDE_VENDORS', true), /* |-------------------------------------------------------------------------- | Custom Error Handler for Deprecated warnings |-------------------------------------------------------------------------- | | When enabled, the Debugbar shows deprecated warnings for Symfony components | in the Messages tab. | | You can set a custom error reporting level to filter which errors are | handled. For example, to exclude deprecation warnings: | E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED | | To exclude notices, strict warnings, and deprecations: | E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED | | Defaults to E_ALL (all errors). | */ 'error_handler' => env('DEBUGBAR_ERROR_HANDLER', false), 'error_level' => env('DEBUGBAR_ERROR_LEVEL', E_ALL), /* |-------------------------------------------------------------------------- | Clockwork integration |-------------------------------------------------------------------------- | | The Debugbar can emulate the Clockwork headers, so you can use the Chrome | Extension, without the server-side code. It uses Debugbar collectors instead. | */ 'clockwork' => env('DEBUGBAR_CLOCKWORK', false), /* |-------------------------------------------------------------------------- | Inject Debugbar in Response |-------------------------------------------------------------------------- | | Usually, the debugbar is added just before </body>, by listening to the | Response after the App is done. If you disable this, you have to add them | in your template yourself. See http://phpdebugbar.com/docs/rendering.html | */ 'inject' => env('DEBUGBAR_INJECT', true), /* |-------------------------------------------------------------------------- | Debugbar route prefix |-------------------------------------------------------------------------- | | Sometimes you want to set route prefix to be used by Debugbar to load | its resources from. Usually the need comes from misconfigured web server or | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97 | */ 'route_prefix' => env('DEBUGBAR_ROUTE_PREFIX', '_debugbar'), /* |-------------------------------------------------------------------------- | Debugbar route middleware |-------------------------------------------------------------------------- | | Additional middleware to run on the Debugbar routes */ 'route_middleware' => [], /* |-------------------------------------------------------------------------- | Debugbar route domain |-------------------------------------------------------------------------- | | By default Debugbar route served from the same domain that request served. | To override default domain, specify it as a non-empty value. */ 'route_domain' => env('DEBUGBAR_ROUTE_DOMAIN'), /* |-------------------------------------------------------------------------- | Debugbar theme |-------------------------------------------------------------------------- | | Switches between light and dark theme. If set to auto it will respect system preferences | Possible values: auto, light, dark */ 'theme' => env('DEBUGBAR_THEME', 'auto'), /* |-------------------------------------------------------------------------- | Backtrace stack limit |-------------------------------------------------------------------------- | | By default, the Debugbar limits the number of frames returned by the 'debug_backtrace()' function. | If you need larger stacktraces, you can increase this number. Setting it to 0 will result in no limit. */ 'debug_backtrace_limit' => (int) env('DEBUGBAR_DEBUG_BACKTRACE_LIMIT', 50), ];
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
barryvdh/laravel-debugbar
https://github.com/barryvdh/laravel-debugbar/blob/7e9719db094762f08f998521dcc048321d936bcb/database/migrations/2014_12_01_120000_create_phpdebugbar_storage_table.php
database/migrations/2014_12_01_120000_create_phpdebugbar_storage_table.php
<?php declare(strict_types=1); use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('phpdebugbar', function (Blueprint $table) { $table->string('id'); $table->longText('data'); $table->string('meta_utime'); $table->dateTime('meta_datetime'); $table->string('meta_uri'); $table->string('meta_ip'); $table->string('meta_method'); $table->primary('id'); $table->index('meta_utime'); $table->index('meta_datetime'); $table->index('meta_uri'); $table->index('meta_ip'); $table->index('meta_method'); }); } /** * Reverse the migrations. */ public function down() { Schema::drop('phpdebugbar'); } };
php
MIT
7e9719db094762f08f998521dcc048321d936bcb
2026-01-04T15:02:34.390506Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/.php-cs-fixer.php-lowest.php
.php-cs-fixer.php-lowest.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use PhpCsFixer\Config; use PhpCsFixer\Future; if (\PHP_VERSION_ID < 7_04_00 || \PHP_VERSION_ID >= 7_05_00) { fwrite(\STDERR, "PHP CS Fixer's config for PHP-LOWEST can be executed only on lowest supported PHP version - ~7.4.0.\n"); fwrite(\STDERR, "Running it on higher PHP version would falsy expect more changes, eg `mixed` type on PHP 8.\n"); exit(1); } $config = require __DIR__.'/.php-cs-fixer.dist.php'; Closure::bind( static function (Config $config): void { $config->name = 'PHP-LOWEST'.(Future::isFutureModeEnabled() ? ' (future mode)' : ''); }, null, Config::class, )($config); $config->getFinder()->notPath([ // @TODO 4.0 change interface to be fully typehinted and remove the exceptions from this list 'src/DocBlock/Annotation.php', 'src/Doctrine/Annotation/Tokens.php', 'src/Tokenizer/Tokens.php', // @TODO add `mixed` return type to `ExecutorWithoutErrorHandler::execute` when PHP 8.0+ is required and remove the exception from this list 'src/ExecutorWithoutErrorHandler.php', ]); $typesMap = [ 'T' => 'mixed', 'TFixerInputConfig' => 'array', 'TFixerComputedConfig' => 'array', 'TFixer' => '\PhpCsFixer\AbstractFixer', '_PhpTokenKind' => 'int|string', '_PhpTokenArray' => 'array{0: int, 1: string}', '_PhpTokenArrayPartial' => 'array{0: int, 1?: string}', '_PhpTokenPrototype' => '_PhpTokenArray|string', '_PhpTokenPrototypePartial' => '_PhpTokenArrayPartial|string', ]; $config->setRules([ 'phpdoc_to_param_type' => ['types_map' => $typesMap], 'phpdoc_to_return_type' => ['types_map' => $typesMap], 'phpdoc_to_property_type' => ['types_map' => $typesMap], ]); return $config;
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/composer-dependency-analyser.php
composer-dependency-analyser.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use ShipMonk\ComposerDependencyAnalyser\Config\Configuration; use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType; return (new Configuration()) ->disableExtensionsAnalysis() ->ignoreErrorsOnPackage('composer/xdebug-handler', [ErrorType::UNUSED_DEPENDENCY]) ->ignoreErrorsOnPackage('symfony/polyfill-mbstring', [ErrorType::UNUSED_DEPENDENCY]) ->ignoreErrorsOnPackage('symfony/polyfill-php80', [ErrorType::UNUSED_DEPENDENCY]) ->ignoreErrorsOnPackage('symfony/polyfill-php81', [ErrorType::UNUSED_DEPENDENCY]) ->ignoreErrorsOnPackage('symfony/polyfill-php84', [ErrorType::UNUSED_DEPENDENCY]) ->ignoreErrorsOnPackage('symfony/event-dispatcher-contracts', [ErrorType::SHADOW_DEPENDENCY]) ->ignoreErrorsOnPath('dev-tools', [ErrorType::UNKNOWN_CLASS, ErrorType::SHADOW_DEPENDENCY]) ->ignoreErrorsOnPath('tests', [ErrorType::UNKNOWN_CLASS]) ->ignoreUnknownClasses(\PHP_VERSION_ID < 8_05_00 ? [ 'T_PIPE', 'T_VOID_CAST', ] : []) ;
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/.php-cs-fixer.php-highest.php
.php-cs-fixer.php-highest.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use PhpCsFixer\Config; use PhpCsFixer\Future; // @phpstan-ignore greaterOrEqual.alwaysFalse, booleanOr.alwaysFalse (PHPStan thinks that 80499 is max PHP version ID) if (\PHP_VERSION_ID < 8_05_00 || \PHP_VERSION_ID >= 8_06_00) { fwrite(\STDERR, "PHP CS Fixer's config for PHP-HIGHEST can be executed only on highest supported PHP version - 8.5.*.\n"); fwrite(\STDERR, "Running it on lower PHP version would prevent calling migration rules.\n"); exit(1); } $config = require __DIR__.'/.php-cs-fixer.dist.php'; Closure::bind( static function (Config $config): void { $config->name = 'PHP-HIGHEST'.(Future::isFutureModeEnabled() ? ' (future mode)' : ''); }, null, Config::class, )($config); $config->getFinder()->notPath([ 'src/Tokenizer/Tokens.php', // due to some quirks on SplFixedArray typing ]); $typesMap = [ 'T' => 'mixed', 'TFixerInputConfig' => 'array', 'TFixerComputedConfig' => 'array', 'TFixer' => '\PhpCsFixer\AbstractFixer', '_PhpTokenKind' => 'int|string', '_PhpTokenArray' => 'array{0: int, 1: string}', '_PhpTokenArrayPartial' => 'array{0: int, 1?: string}', '_PhpTokenPrototype' => '_PhpTokenArray|string', '_PhpTokenPrototypePartial' => '_PhpTokenArrayPartial|string', ]; $config->setRules(array_merge($config->getRules(), [ '@PHP8x5Migration' => true, '@PHP8x5Migration:risky' => true, 'phpdoc_to_param_type' => ['types_map' => $typesMap], 'phpdoc_to_return_type' => ['types_map' => $typesMap], 'phpdoc_to_property_type' => ['types_map' => $typesMap], 'fully_qualified_strict_types' => ['import_symbols' => true], 'php_unit_attributes' => false, // as is not yet supported by PhpCsFixerInternal/configurable_fixer_template ])); return $config;
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/.php-cs-fixer.dist.php
.php-cs-fixer.dist.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use PhpCsFixer\Config; use PhpCsFixer\Finder; use PhpCsFixer\Fixer\Internal\ConfigurableFixerTemplateFixer; use PhpCsFixer\RuleSet\Sets\Internal\InternalRiskySet; use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; if ( filter_var(getenv('PHP_CS_FIXER_TESTS_SYSTEM_UNDER_TEST'), \FILTER_VALIDATE_BOOL) && !filter_var(getenv('PHP_CS_FIXER_TESTS_ALLOW_ONE_TIME_SELF_CONFIG_USAGE'), \FILTER_VALIDATE_BOOL) ) { throw new Error(sprintf('This configuration file ("%s") is not meant to be used in tests.', __FILE__)); } $fileHeaderParts = [ <<<'EOF' This file is part of PHP CS Fixer. (c) Fabien Potencier <fabien@symfony.com> Dariusz Rumiński <dariusz.ruminski@gmail.com> EOF, <<<'EOF' This source file is subject to the MIT license that is bundled with this source code in the file LICENSE. EOF, ]; return (new Config()) ->setParallelConfig(ParallelConfigFactory::detect()) // @TODO 4.0 no need to call this manually ->setUnsupportedPhpVersionAllowed(true) ->setRiskyAllowed(true) ->registerCustomRuleSets([ new InternalRiskySet(), // available only on repo level, not exposed to external installations or phar build ]) ->registerCustomFixers([ new ConfigurableFixerTemplateFixer(), // @TODO shall be registered while registering the Set with it ]) ->setRules([ '@auto' => true, '@auto:risky' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, '@self/internal' => true, // internal rule set, shall not be used outside of main repo 'final_internal_class' => [ 'include' => [], 'exclude' => ['final', 'api-extendable'], 'consider_absent_docblock_as_internal_class' => true, ], 'header_comment' => [ 'header' => implode('', $fileHeaderParts), 'validator' => implode('', [ '/', preg_quote($fileHeaderParts[0], '/'), '(?P<EXTRA>.*)??', preg_quote($fileHeaderParts[1], '/'), '/s', ]), ], 'modernize_strpos' => true, // needs PHP 8+ or polyfill 'native_constant_invocation' => ['strict' => false], // strict:false to not remove `\` on low-end PHP versions for not-yet-known consts 'numeric_literal_separator' => true, 'phpdoc_order' => [ 'order' => [ 'type', 'template', 'template-covariant', 'template-extends', 'extends', 'implements', 'property', 'method', 'param', 'return', 'var', 'assert', 'assert-if-false', 'assert-if-true', 'throws', 'author', 'see', ], ], 'phpdoc_tag_no_named_arguments' => [ 'description' => 'Parameter names are not covered by the backward compatibility promise.', ], 'trailing_comma_in_multiline' => [ 'after_heredoc' => true, 'elements' => [ 'arguments', 'array_destructuring', 'arrays', // 'match', // @TODO PHP 8.0: enable me // 'parameters', // @TODO PHP 8.0: enable me ], ], ]) ->setFinder( (new Finder()) ->in(__DIR__) ->append([__DIR__.'/php-cs-fixer']) ->exclude(['dev-tools/phpstan', 'tests/Fixtures']) ->ignoreDotFiles(false), // @TODO v4 line no longer needed ) ;
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/.php-cs-fixer.well-defined-arrays.php
dev-tools/.php-cs-fixer.well-defined-arrays.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ $config = require __DIR__.'/../.php-cs-fixer.dist.php'; $config->setRules([ 'phpdoc_array_type' => true, 'phpdoc_list_type' => true, ]); return $config;
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/info-extractor.php
dev-tools/info-extractor.php
#!/usr/bin/env php <?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use PhpCsFixer\Console\Application; require_once __DIR__.'/../vendor/autoload.php'; $version = [ 'number' => Application::VERSION, 'vnumber' => 'v'.Application::VERSION, 'codename' => Application::VERSION_CODENAME, ]; echo json_encode([ 'version' => $version, ], \JSON_PRETTY_PRINT | \JSON_THROW_ON_ERROR);
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/console-application.php
dev-tools/phpstan/console-application.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ use PhpCsFixer\Console\Application; require_once __DIR__.'/../../vendor/autoload.php'; return new Application();
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/src/Extension/PregMatchParameterOutExtension.php
dev-tools/phpstan/src/Extension/PregMatchParameterOutExtension.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\PHPStan\Extension; use PhpCsFixer\Preg; use PhpParser\Node\Expr\StaticCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParameterReflection; use PHPStan\TrinaryLogic; use PHPStan\Type\Php\RegexArrayShapeMatcher; use PHPStan\Type\StaticMethodParameterOutTypeExtension; use PHPStan\Type\Type; final class PregMatchParameterOutExtension implements StaticMethodParameterOutTypeExtension { private RegexArrayShapeMatcher $regexShapeMatcher; public function __construct( RegexArrayShapeMatcher $regexShapeMatcher ) { $this->regexShapeMatcher = $regexShapeMatcher; } public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool { return Preg::class === $methodReflection->getDeclaringClass()->getName() && \in_array($methodReflection->getName(), ['match', 'matchAll'], true) && 'matches' === $parameter->getName(); } public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type { $args = $methodCall->getArgs(); $patternArg = $args[0] ?? null; $matchesArg = $args[2] ?? null; $flagsArg = $args[3] ?? null; if ( null === $patternArg || null === $matchesArg ) { return null; } $flagsType = null; if (null !== $flagsArg) { $flagsType = $scope->getType($flagsArg->value); } $matcherMethod = ('match' === $methodReflection->getName()) ? 'matchExpr' : 'matchAllExpr'; // @phpstan-ignore method.dynamicName return $this->regexShapeMatcher->{$matcherMethod}($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/src/Extension/PregMatchTypeSpecifyingExtension.php
dev-tools/phpstan/src/Extension/PregMatchTypeSpecifyingExtension.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\PHPStan\Extension; use PhpCsFixer\Preg; use PhpParser\Node\Expr\StaticCall; use PHPStan\Analyser\Scope; use PHPStan\Analyser\SpecifiedTypes; use PHPStan\Analyser\TypeSpecifier; use PHPStan\Analyser\TypeSpecifierAwareExtension; use PHPStan\Analyser\TypeSpecifierContext; use PHPStan\Reflection\MethodReflection; use PHPStan\TrinaryLogic; use PHPStan\Type\Php\RegexArrayShapeMatcher; use PHPStan\Type\StaticMethodTypeSpecifyingExtension; final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { private RegexArrayShapeMatcher $regexShapeMatcher; private TypeSpecifier $typeSpecifier; public function __construct( RegexArrayShapeMatcher $regexShapeMatcher ) { $this->regexShapeMatcher = $regexShapeMatcher; } public function getClass(): string { return Preg::class; } public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void { $this->typeSpecifier = $typeSpecifier; } public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context): bool { return \in_array($methodReflection->getName(), ['match', 'matchAll'], true) && !$context->null(); } public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes { $args = $node->getArgs(); $patternArg = $args[0] ?? null; $matchesArg = $args[2] ?? null; $flagsArg = $args[3] ?? null; if ( null === $patternArg || null === $matchesArg ) { return new SpecifiedTypes(); } $flagsType = null; if (null !== $flagsArg) { $flagsType = $scope->getType($flagsArg->value); } $matcherMethod = ('match' === $methodReflection->getName()) ? 'matchExpr' : 'matchAllExpr'; /** @phpstan-ignore method.dynamicName */ $matchedType = $this->regexShapeMatcher->{$matcherMethod}( $patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope ); if (null === $matchedType) { return new SpecifiedTypes(); } $overwrite = false; if ($context->false()) { $overwrite = true; $context = $context->negate(); } $types = $this->typeSpecifier->create( $matchesArg->value, $matchedType, $context, $scope, )->setRootExpr($node); if ($overwrite) { $types = $types->setAlwaysOverwriteTypes(); } return $types; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/src/Rules/NoInternalTypesInPublicApiRule.php
dev-tools/phpstan/src/Rules/NoInternalTypesInPublicApiRule.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\PHPStan\Rules; use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\Type; /** * Validates that public and protected methods and properties in non-internal classes do not expose internal types. * * @implements Rule<InClassNode> * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class NoInternalTypesInPublicApiRule implements Rule { public function __construct( private ReflectionProvider $reflectionProvider, ) {} /** * For quick debug. * * @phpstan-ignore-next-line shipmonk.deadMethodsss */ public static function debug(string $msg): void { file_put_contents('phpstan.log', $msg."\n", \FILE_APPEND); } public function getNodeType(): string { return InClassNode::class; } public function processNode(Node $node, Scope $scope): array { $classReflection = $node->getClassReflection(); // Skip if class is internal (check PHPDoc @internal annotation) if ($this->isInternal($classReflection)) { return []; } $errors = []; $classIsFinal = $classReflection->isFinal(); // Check methods foreach ($classReflection->getNativeReflection()->getMethods() as $method) { $methodReflection = $classReflection->getNativeMethod($method->getName()); // Skip if method is private if ($methodReflection->isPrivate()) { continue; } // Skip if method is protected inside final class if ($classIsFinal && !$methodReflection->isPublic()) { continue; } // Skip if method is internal (check PHPDoc @internal annotation) if ($this->isInternalMethod($classReflection, $methodReflection)) { continue; } // Check return type using PHPStan's type system foreach ($methodReflection->getVariants() as $variant) { $errors = array_merge( $errors, $this->checkTypeForInternal( $variant->getReturnType(), $classReflection->getName(), 'method '.$methodReflection->getName().'()', 'return' ) ); // Check parameter types using PHPStan's type system foreach ($variant->getParameters() as $parameter) { $errors = array_merge( $errors, $this->checkTypeForInternal( $parameter->getType(), $classReflection->getName(), 'method '.$methodReflection->getName().'()', 'parameter $'.$parameter->getName() ) ); } } } // Check properties foreach ($classReflection->getNativeReflection()->getProperties() as $property) { // Skip private properties if ($property->isPrivate()) { continue; } // Skip if property is protected inside final class if ($classIsFinal && !$property->isPublic()) { continue; } $propertyReflection = $classReflection->getNativeProperty($property->getName()); // Skip if property is internal (check PHPDoc @internal annotation) $docComment = $propertyReflection->getDocComment(); if (null !== $docComment && str_contains($docComment, '@internal')) { continue; } // Check property type using PHPStan's type system $propertyType = $propertyReflection->getReadableType(); $errors = array_merge( $errors, $this->checkTypeForInternal( $propertyType, $classReflection->getName(), 'property $'.$propertyReflection->getName(), 'type' ) ); } return $errors; } /** * Check if a class is marked as @internal in PHPDoc. */ private function isInternal(ClassReflection $classReflection): bool { static $cache = []; $name = $classReflection->getName(); if (!isset($cache[$name])) { $docComment = $classReflection->getNativeReflection()->getDocComment(); $cache[$name] = false !== $docComment && str_contains($docComment, '@internal'); } return $cache[$name]; } /** * Check if a method is marked as @internal in PHPDoc. */ private function isInternalMethod(ClassReflection $classReflection, MethodReflection $methodReflection): bool { static $cache = []; $name = \sprintf('%s::%s', $classReflection->getName(), $methodReflection->getName()); if (!isset($cache[$name])) { $docComment = $methodReflection->getDocComment(); $cache[$name] = null !== $docComment && str_contains($docComment, '@internal'); } return $cache[$name]; } /** * Check if a PHPStan Type contains references to internal classes. * Uses PHPStan's built-in type system to recursively check all contained types. * * @return list<IdentifierRuleError> */ private function checkTypeForInternal( Type $type, string $className, string $memberName, string $context ): array { $errors = []; // Recursively check all class references in the type // This handles union types, intersection types, and generic types automatically foreach ($type->getReferencedClasses() as $referencedClass) { // Check if the type class is internal (check PHPDoc) $typeClassReflection = $this->reflectionProvider->getClass($referencedClass); if ($this->isInternal($typeClassReflection)) { $errors[] = RuleErrorBuilder::message(\sprintf( '%s %s exposes internal type %s in %s type.', $className, $memberName, $typeClassReflection->getName(), $context )) ->identifier('phpCsFixer.internalTypeInPublicApi') ->build() ; } } return $errors; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/variable.undefined.php
dev-tools/phpstan/baseline/variable.undefined.php
<?php declare(strict_types = 1); $ignoreErrors = []; $ignoreErrors[] = [ 'rawMessage' => 'Variable $innerValues might not be defined.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/offsetAccess.notFound.php
dev-tools/phpstan/baseline/offsetAccess.notFound.php
<?php declare(strict_types = 1); $ignoreErrors = []; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on list<int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/AbstractFopenFlagFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int, int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/AbstractFopenFlagFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<int<0, max>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/AbstractFunctionReferenceFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Cache/Cache.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Console/Command/DescribeCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/DescribeCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset non-falsy-string might not exist on array<string, PhpCsFixer\\RuleSet\\RuleSetDefinitionInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/DescribeCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, PhpCsFixer\\Fixer\\FixerInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/DescribeCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, PhpCsFixer\\RuleSet\\RuleSetDefinitionInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/DescribeCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'argv\' might not exist on array<mixed>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/SelfUpdateCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'major\' might not exist on array{0?: string, major?: numeric-string, 1?: numeric-string}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/SelfUpdateCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'files\' might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/WorkerCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/SelfUpdate/NewVersionChecker.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on array.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Differ/DiffConsoleFormatter.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<PhpCsFixer\\DocBlock\\Line>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/DocBlock.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on list<PhpCsFixer\\DocBlock\\Line>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/DocBlock.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'_array_shape_inner\' might not exist on array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'_callable_argument\' might not exist on array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'_callable_template_inner\' might not exist on array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_inner_value\' might not exist on array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_inners\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_name\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_unsealed_type_a\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_unsealed_type_comma\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_unsealed_type_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'array_shape_unsealed_variadic\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_argument_type\' might not exist on array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_arguments\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_name\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_inner_b\' might not exist on array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_inner_b_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_inner_d\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_inner_d_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_inners\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'callable_template_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'class_constant\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'class_constant_name\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_cond_left\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_cond_middle\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_cond_right_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_false_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_false_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_true_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'conditional_true_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'generic_name\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'generic_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'generic_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'nullable\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'parenthesized_start\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'parenthesized_types\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'type\' might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'types\' might not exist on array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on array<string>.', 'count' => 4, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on non-empty-array<array{string, int<-1, max>}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-list<array{start_index: int<0, max>, value: string, next_glue: string|null, next_glue_raw: string|null}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/DocBlock/TypeExpression.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on list<PhpCsFixer\\Doctrine\\Annotation\\Token>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Doctrine/Annotation/DocLexer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Documentation/DocumentationLocator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Documentation/DocumentationLocator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset (int|string) might not exist on array<string, PhpCsFixer\\Fixer\\FixerInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Documentation/RuleSetDocumentationGenerator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on non-empty-list<int<0, max>>.', 'count' => 4, 'path' => __DIR__ . '/../../../src/Fixer/Alias/EregToPregFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on non-empty-array<int, int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Alias/SetTypeToCastFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<string>.', 'count' => 5, 'path' => __DIR__ . '/../../../src/Fixer/Basic/NumericLiteralSeparatorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on non-empty-array<-844|346|347|348|349|350|351|352|353|354|10008, \'__CLASS__\'|\'__DIR__\'|\'__FILE__\'|\'__FUNCTION__\'|\'__LINE__\'|\'__METHOD__\'|\'__NAMESPACE__\'|\'__PROPERTY__\'|\'__TRAIT__\'|\'class\'>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Casing/MagicConstantCasingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on array<int<1, max>, int>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoNullPropertyInitializationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<int<0, max>>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on non-empty-list<int<0, max>>.', 'count' => 4, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-list<int<0, max>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on non-empty-list<int<0, max>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'class_is_final\' might not exist on array{classIndex: int, token: PhpCsFixer\\Tokenizer\\Token, type: string, class_is_final?: bool, method_final_index: int|null, method_is_constructor?: bool, method_is_private: bool, method_of_enum: false}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoUnneededFinalMethodFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'method_is_constructor\' might not exist on array{classIndex: int, token: PhpCsFixer\\Tokenizer\\Token, type: string, class_is_final: false, method_final_index: int|null, method_is_constructor?: bool, method_is_private: true, method_of_enum: false}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoUnneededFinalMethodFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'end\' might not exist on array{start: int, visibility: non-empty-string, abstract: bool, static: bool, readonly: bool, type?: string, name?: string, end?: int}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array{setupbeforeclass: 1, dosetupbeforeclass: 2, teardownafterclass: 3, doteardownafterclass: 4, setup: 5, dosetup: 6, assertpreconditions: 7, assertpostconditions: 8, ...}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int, PhpCsFixer\\Tokenizer\\Tokens>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedTraitsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array{\'|\': array{10024, \'|\'}, \'&\': array{10035, \'&\'}}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedTypesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array{1: \'|^#\\\\s*$|\', 3: \'|^/\\\\*[\\\\s\\\\*]*\\\\*+/$|\', 2: \'|^//\\\\s*$|\'}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Comment/NoEmptyCommentFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on list{0?: string, 1?: string, 2?: non-falsy-string}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ControlStructure/NoBreakCommentFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on list{0?: string, 1?: string, 2?: non-falsy-string}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ControlStructure/NoBreakCommentFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int|string, bool|null>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ControlStructure/YodaStyleFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<int|string, bool|null>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ControlStructure/YodaStyleFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/FunctionNotation/ImplodeCallFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on non-empty-array<int, int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/FunctionNotation/ImplodeCallFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, PhpCsFixer\\Tokenizer\\Analyzer\\Analysis\\ArgumentAnalysis>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/FullyQualifiedStrictTypesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<PhpCsFixer\\Tokenizer\\Analyzer\\Analysis\\NamespaceAnalysis>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/GlobalNamespaceImportFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<PhpCsFixer\\Tokenizer\\Analyzer\\Analysis\\NamespaceUseAnalysis>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/GroupImportFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int, int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on list<PhpCsFixer\\Tokenizer\\Token>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on list<int|null>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-array<int<0, max>, non-empty-list<int>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-list<int>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on list<PhpCsFixer\\Tokenizer\\Token>.', 'count' => 6, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on non-empty-list<int>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<non-falsy-string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/SingleImportPerStatementFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Internal/ConfigurableFixerTemplateFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'get_called_class\'|\'get_class\'|\'get_class_this\'|\'php_sapi_name\'|\'phpversion\'|\'pi\' might not exist on array<string, non-empty-list<PhpCsFixer\\Tokenizer\\Token>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/LanguageConstruct/FunctionToConstantFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, non-empty-list<PhpCsFixer\\Tokenizer\\Token>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/LanguageConstruct/FunctionToConstantFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<int<0, max>>.', 'count' => 6, 'path' => __DIR__ . '/../../../src/Fixer/LanguageConstruct/IsNullFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on array.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/Naming/NoHomoglyphNamesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-array<int<0, max>, string>.', 'count' => 5, 'path' => __DIR__ . '/../../../src/Fixer/Operator/BinaryOperatorSpacesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on non-empty-array<int<0, max>, int|null>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitConstructFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<int<0, max>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitConstructFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset non-empty-string might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitConstructFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<PhpCsFixer\\Tokenizer\\Token>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 0 might not exist on list<int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on list<int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int, int>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'expectExceptionMessageRegExp\' might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitExpectationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on non-empty-list<int<0, max>>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitExpectationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on list<int>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitExpectationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitExpectationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 3 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'expectedException\' might not exist on array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on list<non-empty-string>.', 'count' => 4, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<8, max> might not exist on list<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on non-empty-list<array{int, string}>.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset string might not exist on non-empty-array<string, non-empty-list<array{int, string}>>.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset mixed might not exist on non-empty-array<string, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on list{0?: string, 1?: string}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<-1, max> might not exist on list<PhpCsFixer\\DocBlock\\Line>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'desc\' might not exist on array{indent: string|null, tag: null, hint: string, var: string|null, static: string, desc?: string|null}.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'desc\' might not exist on array{indent: string|null, tag: string, hint: string, var: \'\', static: string, desc?: string|null}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'desc\' might not exist on array{indent: string|null, tag: string, hint: string, var: non-empty-string|null, static: string, desc?: string|null}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'hint2\' might not exist on non-empty-array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'hint3\' might not exist on non-empty-array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'signature\' might not exist on non-empty-array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'static\' might not exist on non-empty-array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<0, max> might not exist on non-empty-list<array{indent: string|null, tag: string|null, hint: string, var: string|null, static: string, desc?: string|null}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 3 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocArrayTypeFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocArrayTypeFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1 might not exist on array.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocInlineTagNormalizerFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocInlineTagNormalizerFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'general_phpdoc_tag_rename\' might not exist on non-empty-array<string, PhpCsFixer\\Fixer\\FixerInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocNoAliasTagFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 2 might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocNoUselessInheritdocFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int<1, max> might not exist on array.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocSingleLineVarSpacingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset \'general_phpdoc_tag_rename\' might not exist on non-empty-array<string, PhpCsFixer\\Fixer\\FixerInterface>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocTagCasingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset 1|int<3, max> might not exist on array<int<0, max>, string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocTagTypeFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Offset int might not exist on array<int, string>.', 'count' => 2,
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
true
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/argument.type.php
dev-tools/phpstan/baseline/argument.type.php
<?php declare(strict_types = 1); $ignoreErrors = []; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be int by placeholder #1 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Command/WorkerCommand.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #5 of function sprintf is expected to be string by placeholder #4 ("%%s"), bool|string given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/ConfigurationResolver.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $diffs of static method PhpCsFixer\\Console\\Report\\FixReport\\GitlabReporter::getLines() expects list<SebastianBergmann\\Diff\\Diff>, array<SebastianBergmann\\Diff\\Diff> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Console/Report/FixReport/GitlabReporter.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $offset of function substr expects int, int|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Documentation/FixerDocumentGenerator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $subject of function str_replace expects array<string>|string, string|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Documentation/FixerDocumentGenerator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $offset of function substr expects int, int|false given.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Documentation/RuleSetDocumentationGenerator.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $index of method PhpCsFixer\\Tokenizer\\Tokens::getNextTokenOfKind() expects int, int|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Alias/PowToExponentiationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $slices of method PhpCsFixer\\Tokenizer\\Tokens::insertSlices() expects array<int, list<PhpCsFixer\\Tokenizer\\Token>|PhpCsFixer\\Tokenizer\\Token|PhpCsFixer\\Tokenizer\\Tokens>, array<\'\'|int, array{PhpCsFixer\\Tokenizer\\Token, PhpCsFixer\\Tokenizer\\Token}|PhpCsFixer\\Tokenizer\\Token> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $string of function strlen expects string, string|false given.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Fixer/Basic/PsrAutoloadingFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $a of method PhpCsFixer\\Fixer\\ClassNotation\\OrderedClassElementsFixer::sortGroupElements() expects array{start: int, visibility: string, abstract: bool, static: bool, readonly: bool, type: string, name: string, end: int}, array&T given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $b of method PhpCsFixer\\Fixer\\ClassNotation\\OrderedClassElementsFixer::sortGroupElements() expects array{start: int, visibility: string, abstract: bool, static: bool, readonly: bool, type: string, name: string, end: int}, array&T given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $possibleKind of method PhpCsFixer\\Tokenizer\\Token::isGivenKind() expects int|list<int>, list<int|string> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ControlStructure/YodaStyleFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $length of function substr expects int|null, int|false given.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Fixer/Import/FullyQualifiedStrictTypesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $offset of function substr expects int, int|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/NoUnusedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $indices of method PhpCsFixer\\Fixer\\Import\\OrderedImportsFixer::sortByAlgorithm() expects array<int, array{namespace: non-empty-string, startIndex: int, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}>, array<\'\'|int, array{namespace: string, startIndex: int|null, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $indices of method PhpCsFixer\\Fixer\\Import\\OrderedImportsFixer::sortByAlgorithm() expects array<int, array{namespace: non-empty-string, startIndex: int, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}>, non-empty-array<\'\'|int, array{namespace: string, startIndex: int|null, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $offset of function substr expects int, int<0, max>|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Operator/BinaryOperatorSpacesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $length of function substr expects int|null, int<0, max>|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Operator/BinaryOperatorSpacesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $name of static method PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitAttributesFixer::toClassConstant() expects non-empty-string, string given.', 'count' => 5, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitAttributesFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $length of function substr expects int|null, int<0, max>|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $lines of method PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitTestAnnotationFixer::splitUpDocBlock() expects non-empty-list<PhpCsFixer\\DocBlock\\Line>, list<PhpCsFixer\\DocBlock\\Line> given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $offset of function substr expects int, int|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/NoBlankLinesAfterPhpdocFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $str of function preg_quote expects string, int|string given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Whitespace/ArrayIndentationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $parentScopeEndIndex of method PhpCsFixer\\Fixer\\Whitespace\\ArrayIndentationFixer::findExpressionEndIndex() expects int, int|string given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Whitespace/ArrayIndentationFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $code of static method PhpCsFixer\\Hasher::calculate() expects string, string|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Linter/CachingLinter.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, array<string, mixed>|bool given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/RuleSet/RuleSet.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $analysis of static method PhpCsFixer\\Tokenizer\\Analyzer\\ControlCaseStructuresAnalyzer::buildControlCaseStructureAnalysis() expects array{kind: int, index: int, open: int, end: int, cases: list<array{index: int, open: int}>, default: array{index: int, open: int}|null}, non-empty-array<literal-string&non-falsy-string, mixed> given.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Tokenizer/Analyzer/ControlCaseStructuresAnalyzer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $name of static method PhpCsFixer\\Tokenizer\\Processor\\ImportProcessor::tokenizeName() expects non-empty-string, string given.', 'count' => 2, 'path' => __DIR__ . '/../../../src/Tokenizer/Transformer/NameQualifiedTransformer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $json of function json_decode expects string, string|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../src/ToolInfo.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be int by placeholder #1 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/CiConfigurationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 of function sprintf is expected to be int by placeholder #2 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/CiConfigurationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $testClassName of method PhpCsFixer\\Tests\\AutoReview\\ProjectCodeTest::testDataFromDataProviders() expects class-string<PhpCsFixer\\Tests\\TestCase>, class-string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/ProjectCodeTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $testClassName of method PhpCsFixer\\Tests\\AutoReview\\ProjectCodeTest::testDataProvidersAreNonPhpVersionConditional() expects class-string<PhpCsFixer\\Tests\\TestCase>, class-string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/ProjectCodeTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $testClassName of method PhpCsFixer\\Tests\\AutoReview\\ProjectCodeTest::testThatTestDataProvidersAreUsed() expects class-string<PhpCsFixer\\Tests\\TestCase>, class-string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/ProjectCodeTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $dataProviderName of method PhpCsFixer\\Tests\\AutoReview\\ProjectCodeTest::testDataProvidersAreNonPhpVersionConditional() expects non-empty-string, string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/AutoReview/ProjectCodeTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be string by placeholder #1 ("%%s"), string|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Cache/FileHandlerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $expected of method PhpCsFixer\\Tests\\Console\\ConfigurationResolverTest::testResolveIntersectionOfPaths() expects Exception|list<string>, array<string> given.', 'count' => 10, 'path' => __DIR__ . '/../../../tests/Console/ConfigurationResolverTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expectedClass of method PhpCsFixer\\Tests\\Console\\ConfigurationResolverTest::testResolveConfigFileChooseFile() expects class-string<PhpCsFixer\\ConfigInterface>, string given.', 'count' => 5, 'path' => __DIR__ . '/../../../tests/Console/ConfigurationResolverTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be string by placeholder #1 ("%%s"), class-string<Throwable>|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Console/Output/ErrorOutputTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $expectedOutputClass of method PhpCsFixer\\Tests\\Console\\Output\\Progress\\ProgressOutputFactoryTest::testValidProcessOutputIsCreated() expects class-string<Throwable>, string given.', 'count' => 4, 'path' => __DIR__ . '/../../../tests/Console/Output/Progress/ProgressOutputFactoryTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Bar\', \'Test\\\\AB\\\\Baz\', \'A\\\\B\\\\Quux\', \'A\\\\B\\\\Baz\', \'A\\\\B\\\\Foo\', \'\\\\AB\\\\Baz\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Bar\', \'Test\\\\A\\\\B\\\\Quux\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Foo\', \'Test\\\\A\\\\B\\\\Quux\', \'A\\\\B\\\\Baz\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Foo\', \'Test\\\\Corge\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Foo\', \'\\\\A\\\\B\\\\Qux\', \'A\\\\B\\\\Baz\', \'Test\\\\A\\\\B\\\\Quux\', \'A\\\\B\\\\Bar\', \'Test\\\\Corge\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'A\\\\B\\\\Foo\', \'\\\\A\\\\B\\\\Qux\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'Test\\\\A\\\\B\\\\Quux\', \'A\\\\B\\\\Bar\', \'Test\\\\Corge\', \'A\\\\B\\\\Baz\', \'A\\\\B\\\\Foo\', \'\\\\A\\\\B\\\\Qux\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'Test\\\\Corge\', \'\\\\A\\\\B\\\\Qux\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 $configuration of method PhpCsFixer\\Tests\\Fixer\\AttributeNotation\\GeneralAttributeRemoveFixerTest::testFix() expects array{attributes?: list<class-string>}, array{attributes: array{\'\\\\A\\\\B\\\\Qux\', \'\\\\Corge\', \'A\\\\B\\\\Bar\'}} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/AttributeNotation/GeneralAttributeRemoveFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 12, count: 1, multiLine: true} given.', 'count' => 2, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 16, count: 2, multiLine: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 36, count: 2, multiLine: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 5, count: 1, multiLine: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 5, count: 2, multiLine: true} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfo() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 5, count: 3, multiLine: false} given.', 'count' => 3, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $expected of method PhpCsFixer\\Tests\\Fixer\\ClassNotation\\ClassDefinitionFixerTest::testClassyInheritanceInfoPre80() expects array{start: int, classy: int, open: int, extends: array{start: int, count: int, multiLine: bool}|false, implements: array{start: int, count: int, multiLine: bool}|false, anonymousClass: bool, final: int|false, abstract: int|false, ...}, array{start: 36, count: 2, multiLine: true} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{header: \'\', comment_type: \'foo\'} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{header: \'\', comment_type: stdClass} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{header: \'\', location: stdClass} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{header: \'\', separate: stdClass} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{header: 1} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $configuration of method PhpCsFixer\\Tests\\Fixer\\Comment\\HeaderCommentFixerTest::testInvalidConfiguration() expects array{comment_type?: \'comment\'|\'PHPDoc\', header: string, location?: \'after_declare_strict\'|\'after_open\', separate?: \'both\'|\'bottom\'|\'none\'|\'top\', validator?: string|null}|null, array{} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Fixer/Comment/HeaderCommentFixerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $minimum of method PhpCsFixer\\Tests\\FixerDefinition\\VersionSpecificationTest::testConstructorRejectsInvalidValues() expects int<1, max>|null, -1 given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/FixerDefinition/VersionSpecificationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $minimum of method PhpCsFixer\\Tests\\FixerDefinition\\VersionSpecificationTest::testConstructorRejectsInvalidValues() expects int<1, max>|null, 0 given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/FixerDefinition/VersionSpecificationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $maximum of method PhpCsFixer\\Tests\\FixerDefinition\\VersionSpecificationTest::testConstructorRejectsInvalidValues() expects int<1, max>|null, -1 given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/FixerDefinition/VersionSpecificationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $maximum of method PhpCsFixer\\Tests\\FixerDefinition\\VersionSpecificationTest::testConstructorRejectsInvalidValues() expects int<1, max>|null, 0 given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/FixerDefinition/VersionSpecificationTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be int by placeholder #1 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/RuleSet/Sets/AbstractSetTestCase.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #3 of function sprintf is expected to be int by placeholder #2 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/RuleSet/Sets/AbstractSetTestCase.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $input of method PhpCsFixer\\Tests\\Runner\\Parallel\\ProcessFactoryTest::testCreate() expects array<string, string>, array<string, string|true> given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Runner/Parallel/ProcessFactoryTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $input of method PhpCsFixer\\Tests\\Runner\\Parallel\\ProcessFactoryTest::testGetCommandArgs() expects array<string, string>, array<string, string|true> given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Runner/Parallel/ProcessFactoryTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $input of method PhpCsFixer\\Tests\\Runner\\Parallel\\ProcessFactoryTest::testGetCommandArgs() expects array<string, string>, array<string, true> given.', 'count' => 2, 'path' => __DIR__ . '/../../../tests/Runner/Parallel/ProcessFactoryTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #4 of function sprintf is expected to be int by placeholder #3 ("%%d"), int<0, max>|false given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Test/AbstractFixerTestCase.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be string by placeholder #1 ("%%s"), false given.', 'count' => 5, 'path' => __DIR__ . '/../../../tests/Test/AbstractIntegrationCaseFactory.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 of function sprintf is expected to be int by placeholder #1 ("%%d"), string given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Test/AbstractTransformerTestCase.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $caseSensitive of method PhpCsFixer\\Tests\\Tokenizer\\TokenTest::testIsKeyCaseSensitive() expects bool|list<bool>, array{1: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokenTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #1 $expected of method PhpCsFixer\\Tests\\Tokenizer\\TokensAnalyzerTest::testIsBinaryOperator() expects list<int>, array{0: 3, 5: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokensAnalyzerTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #2 $sequence of method PhpCsFixer\\Tests\\Tokenizer\\TokensTest::testFindSequenceException() expects non-empty-list<array{0: int, 1?: string}|PhpCsFixer\\Tokenizer\\Token|string>, array{} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokensTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #6 $caseSensitive of method PhpCsFixer\\Tests\\Tokenizer\\TokensTest::testFindSequence() expects bool|list<bool>, array{1: false} given.', 'count' => 2, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokensTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #6 $caseSensitive of method PhpCsFixer\\Tests\\Tokenizer\\TokensTest::testFindSequence() expects bool|list<bool>, array{1: true} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokensTest.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Parameter #6 $caseSensitive of method PhpCsFixer\\Tests\\Tokenizer\\TokensTest::testFindSequence() expects bool|list<bool>, array{2: false} given.', 'count' => 1, 'path' => __DIR__ . '/../../../tests/Tokenizer/TokensTest.php', ]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/return.type.php
dev-tools/phpstan/baseline/return.type.php
<?php declare(strict_types = 1); $ignoreErrors = []; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Fixer\\ClassNotation\\NoPhp4ConstructorFixer::findFunction() should return array{nameIndex: int, startIndex: int, endIndex: int, bodyIndex: int, modifiers: list<int>}|null but returns array{nameIndex: int<0, max>, startIndex: int, endIndex: int|null, bodyIndex: int|null, modifiers: array<int, int>}.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Fixer\\ClassNotation\\OrderedClassElementsFixer::getElements() should return list<array{start: int, visibility: string, abstract: bool, static: bool, readonly: bool, type: string, name: string, end: int}> but returns list<array{start: int, visibility: \'public\', abstract: false, static: false, readonly: bool, type: string, name?: string, end: int}|array{start: int, visibility: non-empty-string, abstract: bool, static: bool, readonly: bool}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/ClassNotation/OrderedClassElementsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Fixer\\FunctionNotation\\ImplodeCallFixer::getArgumentIndices() should return array<int, int> but returns array<int|string, int|null>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/FunctionNotation/ImplodeCallFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Fixer\\Import\\OrderedImportsFixer::getNewOrder() should return array<int, array{namespace: non-empty-string, startIndex: int, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}> but returns array<\'\'|int, array{namespace: non-empty-string, startIndex: int, endIndex: int, importType: \'class\'|\'const\'|\'function\', group: bool}>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Import/OrderedImportsFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Fixer\\Phpdoc\\PhpdocAlignFixer::getMatches() should return array{indent: string|null, tag: string|null, hint: string, var: string|null, static: string, desc?: string|null}|null but returns non-empty-array<string>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Fixer/Phpdoc/PhpdocAlignFixer.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Tokenizer\\Tokens::findGivenKind() should return array<int, array<int<0, max>, PhpCsFixer\\Tokenizer\\Token>|PhpCsFixer\\Tokenizer\\Token> but returns array<int, array<int, PhpCsFixer\\Tokenizer\\Token>|PhpCsFixer\\Tokenizer\\Token>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Tokenizer/Tokens.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Tokenizer\\Tokens::findOppositeBlockEdge() should return int<0, max> but returns int.', 'count' => 3, 'path' => __DIR__ . '/../../../src/Tokenizer/Tokens.php', ]; $ignoreErrors[] = [ 'rawMessage' => 'Method PhpCsFixer\\Tokenizer\\Tokens::findSequence() should return non-empty-array<int<0, max>, PhpCsFixer\\Tokenizer\\Token>|null but returns non-empty-array<int, PhpCsFixer\\Tokenizer\\Token>.', 'count' => 1, 'path' => __DIR__ . '/../../../src/Tokenizer/Tokens.php', ]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/assign.propertyType.php
dev-tools/phpstan/baseline/assign.propertyType.php
<?php declare(strict_types = 1); $ignoreErrors = []; $ignoreErrors[] = [ 'rawMessage' => 'Property PhpCsFixer\\FixerConfiguration\\FixerOption::$allowedValues (non-empty-list<bool|(callable(mixed): bool)|float|int|string|null>|null) does not accept non-empty-array<int<0, max>, bool|(callable(mixed): bool)|Closure|float|int|string|null>|null.', 'count' => 1, 'path' => __DIR__ . '/../../../src/FixerConfiguration/FixerOption.php', ]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/dev-tools/phpstan/baseline/_loader.php
dev-tools/phpstan/baseline/_loader.php
<?php declare(strict_types = 1); return ['includes' => [ __DIR__ . '/argument.type.php', __DIR__ . '/assign.propertyType.php', __DIR__ . '/offsetAccess.notFound.php', __DIR__ . '/return.type.php', __DIR__ . '/variable.undefined.php', ]];
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ExecutorWithoutErrorHandler.php
src/ExecutorWithoutErrorHandler.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class ExecutorWithoutErrorHandler { private function __construct() {} /** * @template T * * @param callable(): T $callback * * @return T * * @throws ExecutorWithoutErrorHandlerException */ public static function execute(callable $callback) { /** @var ?string */ $error = null; set_error_handler(static function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) use (&$error): bool { $error = $errorString; return true; }); try { $result = $callback(); } finally { restore_error_handler(); } if (null !== $error) { throw new ExecutorWithoutErrorHandlerException($error); } return $result; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/PharChecker.php
src/PharChecker.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class PharChecker implements PharCheckerInterface { public function checkFileValidity(string $filename): ?string { try { $phar = new \Phar($filename); // free the variable to unlock the file unset($phar); } catch (\Exception $e) { if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { throw $e; } return 'Failed to create Phar instance. '.$e->getMessage(); } return null; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/FixerNameValidator.php
src/FixerNameValidator.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class FixerNameValidator { public function isValid(string $name, bool $isCustom): bool { if (!$isCustom) { return Preg::match('/^[a-z][a-z0-9_]*$/', $name); } return Preg::match('/^[A-Z][a-zA-Z0-9]*\/[a-z][a-z0-9_]*$/', $name); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/WordMatcher.php
src/WordMatcher.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @readonly * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class WordMatcher { /** * @var list<string> */ private array $candidates; /** * @param list<string> $candidates */ public function __construct(array $candidates) { $this->candidates = $candidates; } public function match(string $needle): ?string { $word = null; $distance = ceil(\strlen($needle) * 0.35); foreach ($this->candidates as $candidate) { $candidateDistance = levenshtein($needle, $candidate); if ($candidateDistance < $distance) { $word = $candidate; $distance = $candidateDistance; } } return $word; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ParallelAwareConfigInterface.php
src/ParallelAwareConfigInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Runner\Parallel\ParallelConfig; /** * @author Greg Korba <greg@codito.dev> * * @TODO 4.0 Include parallel runner config in main ConfigInterface * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface ParallelAwareConfigInterface extends ConfigInterface { public function getParallelConfig(): ParallelConfig; public function setParallelConfig(ParallelConfig $config): ConfigInterface; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ComposerJsonReader.php
src/ComposerJsonReader.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use Composer\Semver\Semver; use Symfony\Component\Filesystem\Exception\IOException; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class ComposerJsonReader { private const COMPOSER_FILENAME = 'composer.json'; private bool $isProcessed = false; private ?string $php = null; private ?string $phpUnit = null; private static ?self $singleton = null; public static function createSingleton(): self { if (null === self::$singleton) { self::$singleton = new self(); } return self::$singleton; } public function getPhp(): ?string { $this->processFile(); return $this->php; } public function getPhpUnit(): ?string { $this->processFile(); return $this->phpUnit; } private function processFile(): void { if (true === $this->isProcessed) { return; } if (!file_exists(self::COMPOSER_FILENAME)) { throw new IOException(\sprintf('Failed to read file "%s".', self::COMPOSER_FILENAME)); } $readResult = file_get_contents(self::COMPOSER_FILENAME); if (false === $readResult) { throw new IOException(\sprintf('Failed to read file "%s".', self::COMPOSER_FILENAME)); } $this->processJson($readResult); } private function processJson(string $json): void { if (true === $this->isProcessed) { return; } $composerJson = json_decode($json, true, 512, \JSON_THROW_ON_ERROR); $this->php = self::getMinSemVer(self::detectPhp($composerJson)); $this->phpUnit = self::getMinSemVer(self::detectPackage($composerJson, 'phpunit/phpunit')); $this->isProcessed = true; } private static function getMinSemVer(?string $version): ?string { if ('' === $version || null === $version) { return null; } /** @var non-empty-list<string> $arr */ $arr = Preg::split('/\s*\|\|?\s*/', trim($version)); $arr = array_map(static function ($v) { $v = ltrim($v, 'v^~>= '); $v = substr($v, 0, strcspn($v, ' ,-')); if (str_ends_with($v, '.*')) { $v = substr($v, 0, -\strlen('.*')); } return $v; }, $arr); $textVersion = array_find($arr, static fn ($v) => true === Preg::match('/^\D/', $v)); if (null !== $textVersion) { return null; } /** @var non-empty-list<string> $sortedArr */ $sortedArr = Semver::sort($arr); $min = $sortedArr[0]; $parts = explode('.', $min); return \sprintf('%s.%s', (int) $parts[0], (int) ($parts[1] ?? 0)); } /** * @param array<string, mixed> $composerJson */ private static function detectPhp(array $composerJson): ?string { $version = []; if (isset($composerJson['config']['platform']['php'])) { $version[] = $composerJson['config']['platform']['php']; } if (isset($composerJson['require-dev']['php'])) { $version[] = $composerJson['require-dev']['php']; } if (isset($composerJson['require']['php'])) { $version[] = $composerJson['require']['php']; } if (\count($version) > 0) { return implode(' || ', $version); } return null; } /** * @param array<string, mixed> $composerJson * @param non-empty-string $package */ private static function detectPackage(array $composerJson, string $package): ?string { $version = []; if (isset($composerJson['require-dev'][$package])) { $version[] = $composerJson['require-dev'][$package]; } if (isset($composerJson['require'][$package])) { $version[] = $composerJson['require'][$package]; } if (\count($version) > 0) { return implode(' || ', $version); } return null; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/WhitespacesFixerConfig.php
src/WhitespacesFixerConfig.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @readonly * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class WhitespacesFixerConfig { /** @var non-empty-string */ private string $indent; /** @var non-empty-string */ private string $lineEnding; /** * @param non-empty-string $indent * @param non-empty-string $lineEnding */ public function __construct(string $indent = ' ', string $lineEnding = "\n") { if (!\in_array($indent, [' ', ' ', "\t"], true)) { throw new \InvalidArgumentException('Invalid "indent" param, expected tab or two or four spaces.'); } if (!\in_array($lineEnding, ["\n", "\r\n"], true)) { throw new \InvalidArgumentException('Invalid "lineEnding" param, expected "\n" or "\r\n".'); } $this->indent = $indent; $this->lineEnding = $lineEnding; } /** * @return non-empty-string */ public function getIndent(): string { return $this->indent; } /** * @return non-empty-string */ public function getLineEnding(): string { return $this->lineEnding; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/CustomRulesetsAwareConfigInterface.php
src/CustomRulesetsAwareConfigInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\RuleSet\RuleSetDefinitionInterface; /** * @author Greg Korba <greg@codito.dev> * * @TODO 4.0 Include support for custom rulesets in main ConfigInterface * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface CustomRulesetsAwareConfigInterface extends ConfigInterface { /** * Registers custom rule sets to be used the same way as built-in rule sets. * * @param list<RuleSetDefinitionInterface> $ruleSets * * @todo v4 Introduce it in main ConfigInterface */ public function registerCustomRuleSets(array $ruleSets): ConfigInterface; /** * @return list<RuleSetDefinitionInterface> */ public function getCustomRuleSets(): array; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ToolInfoInterface.php
src/ToolInfoInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface ToolInfoInterface { /** * @return array{name: string, version: string, dist: array{reference?: string}} */ public function getComposerInstallationDetails(): array; public function getComposerVersion(): string; public function getVersion(): string; public function isInstalledAsPhar(): bool; public function isInstalledByComposer(): bool; public function isRunInsideDocker(): bool; public function getPharDownloadUri(string $version): string; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/RuleSetNameValidator.php
src/RuleSetNameValidator.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class RuleSetNameValidator { public static function isValid(string $name, bool $isCustom): bool { if (!$isCustom) { return Preg::match('/^@[a-z][a-z0-9\/_\-\.]*(:risky)?$/i', $name); } // See: https://regex101.com/r/VcOnNr/7 return Preg::match('/^@(?!PhpCsFixer)[a-z][a-z0-9_]*\/[a-z][a-z0-9_\-\.]*(:risky)?$/i', $name); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractDoctrineAnnotationFixer.php
src/AbstractDoctrineAnnotationFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Doctrine\Annotation\Tokens as DoctrineAnnotationTokens; use PhpCsFixer\Fixer\ConfigurableFixerInterface; use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; use PhpCsFixer\FixerConfiguration\FixerOptionBuilder; use PhpCsFixer\Tokenizer\CT; use PhpCsFixer\Tokenizer\FCT; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixer\Tokenizer\TokensAnalyzer; /** * @internal * * @phpstan-type _AutogeneratedInputConfiguration array{ * ignored_tags?: list<string>, * } * @phpstan-type _AutogeneratedComputedConfiguration array{ * ignored_tags: list<string>, * } * * @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration> * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractDoctrineAnnotationFixer extends AbstractFixer implements ConfigurableFixerInterface { private const CLASS_MODIFIERS = [\T_ABSTRACT, \T_FINAL, FCT::T_READONLY]; private const MODIFIER_KINDS = [\T_PUBLIC, \T_PROTECTED, \T_PRIVATE, \T_FINAL, \T_ABSTRACT, \T_NS_SEPARATOR, \T_STRING, CT::T_NULLABLE_TYPE, FCT::T_READONLY, FCT::T_PRIVATE_SET, FCT::T_PROTECTED_SET, FCT::T_PUBLIC_SET]; /** * @var array<int, array{classIndex: int, token: Token, type: string}> */ private array $classyElements; public function isCandidate(Tokens $tokens): bool { return $tokens->isTokenKindFound(\T_DOC_COMMENT); } protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { // fetch indices one time, this is safe as we never add or remove a token during fixing $analyzer = new TokensAnalyzer($tokens); $this->classyElements = $analyzer->getClassyElements(); foreach ($tokens->findGivenKind(\T_DOC_COMMENT) as $index => $docCommentToken) { if (!$this->nextElementAcceptsDoctrineAnnotations($tokens, $index)) { continue; } $doctrineAnnotationTokens = DoctrineAnnotationTokens::createFromDocComment( $docCommentToken, $this->configuration['ignored_tags'], // @phpstan-ignore-line ); $this->fixAnnotations($doctrineAnnotationTokens); $tokens[$index] = new Token([\T_DOC_COMMENT, $doctrineAnnotationTokens->getCode()]); } } /** * Fixes Doctrine annotations from the given PHPDoc style comment. */ abstract protected function fixAnnotations(DoctrineAnnotationTokens $doctrineAnnotationTokens): void; protected function createConfigurationDefinition(): FixerConfigurationResolverInterface { return new FixerConfigurationResolver([ (new FixerOptionBuilder('ignored_tags', 'List of tags that must not be treated as Doctrine Annotations.')) ->setAllowedTypes(['string[]']) ->setDefault([ // PHPDocumentor 1 'abstract', 'access', 'code', 'deprec', 'encode', 'exception', 'final', 'ingroup', 'inheritdoc', 'inheritDoc', 'magic', 'name', 'toc', 'tutorial', 'private', 'static', 'staticvar', 'staticVar', 'throw', // PHPDocumentor 2 'api', 'author', 'category', 'copyright', 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal', 'license', 'link', 'method', 'package', 'param', 'property', 'property-read', 'property-write', 'return', 'see', 'since', 'source', 'subpackage', 'throws', 'todo', 'TODO', 'usedBy', 'uses', 'var', 'version', // PHPUnit 'after', 'afterClass', 'backupGlobals', 'backupStaticAttributes', 'before', 'beforeClass', 'codeCoverageIgnore', 'codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd', 'covers', 'coversDefaultClass', 'coversNothing', 'dataProvider', 'depends', 'expectedException', 'expectedExceptionCode', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp', 'group', 'large', 'medium', 'preserveGlobalState', 'requires', 'runTestsInSeparateProcesses', 'runInSeparateProcess', 'small', 'test', 'testdox', 'ticket', 'uses', // PHPCheckStyle 'SuppressWarnings', // PHPStorm 'noinspection', // PEAR 'package_version', // PlantUML 'enduml', 'startuml', // Psalm 'psalm', // PHPStan 'phpstan', 'template', // other 'fix', 'FIXME', 'fixme', 'override', ]) ->getOption(), ]); } private function nextElementAcceptsDoctrineAnnotations(Tokens $tokens, int $index): bool { do { $index = $tokens->getNextMeaningfulToken($index); if (null === $index) { return false; } } while ($tokens[$index]->isGivenKind(self::CLASS_MODIFIERS)); if ($tokens[$index]->isGivenKind(\T_CLASS)) { return true; } while ($tokens[$index]->isGivenKind(self::MODIFIER_KINDS)) { $index = $tokens->getNextMeaningfulToken($index); } if (!isset($this->classyElements[$index])) { return false; } return $tokens[$this->classyElements[$index]['classIndex']]->isGivenKind(\T_CLASS); // interface, enums and traits cannot have doctrine annotations } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/StdinFileInfo.php
src/StdinFileInfo.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Davi Koscianski Vidal <davividal@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class StdinFileInfo extends \SplFileInfo { public function __construct() { parent::__construct(__FILE__); } public function __toString(): string { return $this->getRealPath(); } public function getRealPath(): string { // So file_get_contents & friends will work. // Warning - this stream is not seekable, so `file_get_contents` will work only once! Consider using `FileReader`. return 'php://stdin'; } public function getATime(): int { return 0; } public function getBasename($suffix = null): string { return $this->getFilename(); } public function getCTime(): int { return 0; } public function getExtension(): string { return '.php'; } /** * @param null|class-string<\SplFileInfo> $class */ public function getFileInfo($class = null): \SplFileInfo { throw new \BadMethodCallException(\sprintf('Method "%s" is not implemented.', __METHOD__)); } public function getFilename(): string { /* * Useful so fixers depending on PHP-only files still work. * * The idea to use STDIN is to parse PHP-only files, so we can * assume that there will be always a PHP file out there. */ return 'stdin.php'; } public function getGroup(): int { return 0; } public function getInode(): int { return 0; } public function getLinkTarget(): string { return ''; } public function getMTime(): int { return 0; } public function getOwner(): int { return 0; } public function getPath(): string { return ''; } /** * @param null|class-string<\SplFileInfo> $class */ public function getPathInfo($class = null): \SplFileInfo { throw new \BadMethodCallException(\sprintf('Method "%s" is not implemented.', __METHOD__)); } public function getPathname(): string { return $this->getFilename(); } public function getPerms(): int { return 0; } public function getSize(): int { return 0; } public function getType(): string { return 'file'; } public function isDir(): bool { return false; } public function isExecutable(): bool { return false; } public function isFile(): bool { return true; } public function isLink(): bool { return false; } public function isReadable(): bool { return true; } public function isWritable(): bool { return false; } public function openFile($openMode = 'r', $useIncludePath = false, $context = null): \SplFileObject { throw new \BadMethodCallException(\sprintf('Method "%s" is not implemented.', __METHOD__)); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/FixerFactory.php
src/FixerFactory.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException; use PhpCsFixer\Fixer\ConfigurableFixerInterface; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; use PhpCsFixer\RuleSet\RuleSetInterface; use Symfony\Component\Finder\Finder as SymfonyFinder; use Symfony\Component\Finder\SplFileInfo; /** * Class provides a way to create a group of fixers. * * Fixers may be registered (made the factory aware of them) by * registering a custom fixer and default, built in fixers. * Then, one can attach Config instance to fixer instances. * * Finally factory creates a ready to use group of fixers. * * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class FixerFactory { private FixerNameValidator $nameValidator; /** * @var list<FixerInterface> */ private array $fixers = []; /** * @var array<string, FixerInterface> */ private array $fixersByName = []; public function __construct() { $this->nameValidator = new FixerNameValidator(); } public function setWhitespacesConfig(WhitespacesFixerConfig $config): self { foreach ($this->fixers as $fixer) { if ($fixer instanceof WhitespacesAwareFixerInterface) { $fixer->setWhitespacesConfig($config); } } return $this; } /** * @return list<FixerInterface> */ public function getFixers(): array { $this->fixers = Utils::sortFixers($this->fixers); return $this->fixers; } /** * @return $this */ public function registerBuiltInFixers(): self { static $builtInFixers = null; if (null === $builtInFixers) { /** @var list<class-string<FixerInterface>> */ $builtInFixers = []; $finder = SymfonyFinder::create()->files() ->in(__DIR__.'/Fixer') ->exclude(['Internal']) ->name('*Fixer.php') ->depth(1) ; /** @var SplFileInfo $file */ foreach ($finder as $file) { $relativeNamespace = $file->getRelativePath(); $fixerClass = 'PhpCsFixer\Fixer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php'); $builtInFixers[] = $fixerClass; } } foreach ($builtInFixers as $class) { /** @var FixerInterface */ $fixer = new $class(); $this->registerFixer($fixer, false); } return $this; } /** * @param iterable<FixerInterface> $fixers * * @return $this */ public function registerCustomFixers(iterable $fixers): self { foreach ($fixers as $fixer) { $this->registerFixer($fixer, true); } return $this; } /** * @return $this */ public function registerFixer(FixerInterface $fixer, bool $isCustom): self { $name = $fixer->getName(); if (isset($this->fixersByName[$name])) { throw new \UnexpectedValueException(\sprintf('Fixer named "%s" is already registered.', $name)); } if (!$this->nameValidator->isValid($name, $isCustom)) { throw new \UnexpectedValueException(\sprintf('Fixer named "%s" has invalid name.', $name)); } $this->fixers[] = $fixer; $this->fixersByName[$name] = $fixer; return $this; } /** * Apply RuleSet on fixers to filter out all unwanted fixers. * * @return $this */ public function useRuleSet(RuleSetInterface $ruleSet): self { $fixers = []; $fixersByName = []; $fixerConflicts = []; $fixerNames = array_keys($ruleSet->getRules()); foreach ($fixerNames as $name) { if (!\array_key_exists($name, $this->fixersByName)) { throw new \UnexpectedValueException(\sprintf('Rule "%s" does not exist.', $name)); } $fixer = $this->fixersByName[$name]; $config = $ruleSet->getRuleConfiguration($name); if (null !== $config) { if ($fixer instanceof ConfigurableFixerInterface) { if (\count($config) < 1) { throw new InvalidFixerConfigurationException($fixer->getName(), 'Configuration must be an array and may not be empty.'); } $fixer->configure($config); } else { throw new InvalidFixerConfigurationException($fixer->getName(), 'Is not configurable.'); } } $fixers[] = $fixer; $fixersByName[$name] = $fixer; $conflicts = array_values(array_intersect($this->getFixersConflicts($fixer), $fixerNames)); if (\count($conflicts) > 0) { $fixerConflicts[$name] = $conflicts; } } if (\count($fixerConflicts) > 0) { throw new \UnexpectedValueException($this->generateConflictMessage($fixerConflicts)); } $this->fixers = $fixers; $this->fixersByName = $fixersByName; return $this; } /** * Check if fixer exists. */ public function hasRule(string $name): bool { return isset($this->fixersByName[$name]); } /** * @return list<string> */ private function getFixersConflicts(FixerInterface $fixer): array { return [ 'blank_lines_before_namespace' => [ 'no_blank_lines_before_namespace', 'single_blank_line_before_namespace', ], 'no_blank_lines_before_namespace' => ['single_blank_line_before_namespace'], 'single_import_per_statement' => ['group_import'], ][$fixer->getName()] ?? []; } /** * @param array<string, list<string>> $fixerConflicts */ private function generateConflictMessage(array $fixerConflicts): string { $message = 'Rule contains conflicting fixers:'; $report = []; foreach ($fixerConflicts as $fixer => $fixers) { // filter mutual conflicts $report[$fixer] = array_values(array_filter( $fixers, static fn (string $candidate): bool => !\array_key_exists($candidate, $report) || !\in_array($fixer, $report[$candidate], true), )); if (\count($report[$fixer]) > 0) { $message .= \sprintf("\n- \"%s\" with %s", $fixer, Utils::naturalLanguageJoin($report[$fixer])); } } return $message; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractPhpdocTypesFixer.php
src/AbstractPhpdocTypesFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\DocBlock\Annotation; use PhpCsFixer\DocBlock\DocBlock; use PhpCsFixer\DocBlock\TypeExpression; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; /** * This abstract fixer provides a base for fixers to fix types in PHPDoc. * * @author Graham Campbell <hello@gjcampbell.co.uk> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractPhpdocTypesFixer extends AbstractFixer { public function isCandidate(Tokens $tokens): bool { return $tokens->isTokenKindFound(\T_DOC_COMMENT); } protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { foreach ($tokens as $index => $token) { if (!$token->isGivenKind(\T_DOC_COMMENT)) { continue; } $doc = new DocBlock($token->getContent()); $annotations = $doc->getAnnotationsOfType(Annotation::TAGS_WITH_TYPES); if (0 === \count($annotations)) { continue; } foreach ($annotations as $annotation) { $this->fixType($annotation); } $tokens[$index] = new Token([\T_DOC_COMMENT, $doc->getContent()]); } } /** * Actually normalize the given type. */ abstract protected function normalize(string $type): string; /** * Fix the type at the given line. * * We must be super careful not to modify parts of words. * * This will be nicely handled behind the scenes for us by the annotation class. */ private function fixType(Annotation $annotation): void { $typeExpression = $annotation->getTypeExpression(); if (null === $typeExpression) { return; } $newTypeExpression = $typeExpression->mapTypes(function (TypeExpression $type) { if (!$type->isCompositeType()) { $value = $this->normalize($type->toString()); return new TypeExpression($value, null, []); } return $type; }); $annotation->setTypes([$newTypeExpression->toString()]); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractProxyFixer.php
src/AbstractProxyFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; use PhpCsFixer\Tokenizer\Tokens; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractProxyFixer extends AbstractFixer { /** * @var non-empty-array<string, FixerInterface> */ protected array $proxyFixers; public function __construct() { $proxyFixers = []; foreach (Utils::sortFixers($this->createProxyFixers()) as $proxyFixer) { $proxyFixers[$proxyFixer->getName()] = $proxyFixer; } $this->proxyFixers = $proxyFixers; parent::__construct(); } public function isCandidate(Tokens $tokens): bool { foreach ($this->proxyFixers as $fixer) { if ($fixer->isCandidate($tokens)) { return true; } } return false; } public function isRisky(): bool { foreach ($this->proxyFixers as $fixer) { if ($fixer->isRisky()) { return true; } } return false; } public function getPriority(): int { if (\count($this->proxyFixers) > 1) { throw new \LogicException('You need to override this method to provide the priority of combined fixers.'); } return reset($this->proxyFixers)->getPriority(); } public function supports(\SplFileInfo $file): bool { foreach ($this->proxyFixers as $fixer) { if ($fixer->supports($file)) { return true; } } return false; } public function setWhitespacesConfig(WhitespacesFixerConfig $config): void { parent::setWhitespacesConfig($config); foreach ($this->proxyFixers as $fixer) { if ($fixer instanceof WhitespacesAwareFixerInterface) { $fixer->setWhitespacesConfig($config); } } } protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { foreach ($this->proxyFixers as $fixer) { $fixer->fix($file, $tokens); } } /** * @return non-empty-list<FixerInterface> */ abstract protected function createProxyFixers(): array; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Preg.php
src/Preg.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * This class replaces preg_* functions to better handling UTF8 strings, * ensuring no matter "u" modifier is present or absent subject will be handled correctly. * * @author Kuba Werłos <werlos@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class Preg { /** * @param array<array-key, mixed> $matches * @param int-mask<PREG_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL> $flags * * @param-out ($flags is PREG_OFFSET_CAPTURE * ? array<array-key, array{string, 0|positive-int}|array{'', -1}> * : ($flags is PREG_UNMATCHED_AS_NULL * ? array<array-key, string|null> * : ($flags is int-mask<PREG_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL>&768 * ? array<array-key, array{string, 0|positive-int}|array{null, -1}> * : array<array-key, string> * ) * ) * ) $matches * * @throws PregException */ public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool { $result = @preg_match(self::addUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return 1 === $result; } $result = @preg_match(self::removeUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return 1 === $result; } throw self::newPregException(preg_last_error(), preg_last_error_msg(), __METHOD__, $pattern); } /** * @param array<array-key, mixed> $matches * @param int-mask<PREG_PATTERN_ORDER, PREG_SET_ORDER, PREG_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL> $flags * * @param-out ($flags is PREG_PATTERN_ORDER * ? array<list<string>> * : ($flags is PREG_SET_ORDER * ? list<array<string>> * : ($flags is int-mask<PREG_PATTERN_ORDER, PREG_OFFSET_CAPTURE>&(256|257) * ? array<list<array{string, int}>> * : ($flags is int-mask<PREG_SET_ORDER, PREG_OFFSET_CAPTURE>&258 * ? list<array<array{string, int}>> * : ($flags is int-mask<PREG_PATTERN_ORDER, PREG_UNMATCHED_AS_NULL>&(512|513) * ? array<list<?string>> * : ($flags is int-mask<PREG_SET_ORDER, PREG_UNMATCHED_AS_NULL>&514 * ? list<array<?string>> * : ($flags is int-mask<PREG_SET_ORDER, PREG_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL>&770 * ? list<array<array{?string, int}>> * : ($flags is 0 ? array<list<string>> : array<mixed>) * ) * ) * ) * ) * ) * ) * ) $matches * * @throws PregException */ public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = \PREG_PATTERN_ORDER, int $offset = 0): int { $result = @preg_match_all(self::addUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } $result = @preg_match_all(self::removeUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } throw self::newPregException(preg_last_error(), preg_last_error_msg(), __METHOD__, $pattern); } /** * @param-out int $count * * @return ($subject is non-empty-string ? ($replacement is non-empty-string ? non-empty-string : string) : string) * * @throws PregException */ public static function replace(string $pattern, string $replacement, string $subject, int $limit = -1, ?int &$count = null): string { $result = @preg_replace(self::addUtf8Modifier($pattern), $replacement, $subject, $limit, $count); if (null !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } $result = @preg_replace(self::removeUtf8Modifier($pattern), $replacement, $subject, $limit, $count); if (null !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } throw self::newPregException(preg_last_error(), preg_last_error_msg(), __METHOD__, $pattern); } /** * @param-out int $count * * @throws PregException */ public static function replaceCallback(string $pattern, callable $callback, string $subject, int $limit = -1, ?int &$count = null): string { $result = @preg_replace_callback(self::addUtf8Modifier($pattern), $callback, $subject, $limit, $count); if (null !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } $result = @preg_replace_callback(self::removeUtf8Modifier($pattern), $callback, $subject, $limit, $count); if (null !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } throw self::newPregException(preg_last_error(), preg_last_error_msg(), __METHOD__, $pattern); } /** * @return ($flags is PREG_SPLIT_OFFSET_CAPTURE ? list<array{string, int<0, max>}> : list<string>) * * @throws PregException */ public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array { $result = @preg_split(self::addUtf8Modifier($pattern), $subject, $limit, $flags); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } $result = @preg_split(self::removeUtf8Modifier($pattern), $subject, $limit, $flags); if (false !== $result && \PREG_NO_ERROR === preg_last_error()) { return $result; } throw self::newPregException(preg_last_error(), preg_last_error_msg(), __METHOD__, $pattern); } private static function addUtf8Modifier(string $pattern): string { return $pattern.'u'; } private static function removeUtf8Modifier(string $pattern): string { if ('' === $pattern) { return ''; } $delimiter = $pattern[0]; $endDelimiterPosition = strrpos($pattern, $delimiter); \assert(\is_int($endDelimiterPosition)); return substr($pattern, 0, $endDelimiterPosition).str_replace('u', '', substr($pattern, $endDelimiterPosition)); } /** * Create the generic PregException message and tell more about such kind of error in the message. */ private static function newPregException(int $error, string $errorMsg, string $method, string $pattern): PregException { $result = null; $errorMessage = null; try { $result = ExecutorWithoutErrorHandler::execute(static fn () => preg_match($pattern, '')); } catch (ExecutorWithoutErrorHandlerException $e) { $result = false; $errorMessage = $e->getMessage(); } if (false !== $result) { return new PregException(\sprintf('Unknown error occurred when calling %s: %s.', $method, $errorMsg), $error); } $code = preg_last_error(); $message = \sprintf( '(code: %d) %s', $code, preg_replace('~preg_[a-z_]+[()]{2}: ~', '', $errorMessage), ); return new PregException( \sprintf('%s(): Invalid PCRE pattern "%s": %s (version: %s)', $method, $pattern, $message, \PCRE_VERSION), $code, ); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractFixer.php
src/AbstractFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\ConfigurationException\RequiredFixerConfigurationException; use PhpCsFixer\Fixer\ConfigurableFixerInterface; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface; use PhpCsFixer\Tokenizer\Tokens; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractFixer implements FixerInterface { protected WhitespacesFixerConfig $whitespacesConfig; /** * @readonly */ private string $name; public function __construct() { $nameParts = explode('\\', static::class); $name = substr(end($nameParts), 0, -\strlen('Fixer')); $this->name = Utils::camelCaseToUnderscore($name); if ($this instanceof ConfigurableFixerInterface) { try { $this->configure([]); } catch (RequiredFixerConfigurationException $e) { // ignore } } if ($this instanceof WhitespacesAwareFixerInterface) { $this->whitespacesConfig = $this->getDefaultWhitespacesFixerConfig(); } } final public function fix(\SplFileInfo $file, Tokens $tokens): void { if ($this instanceof ConfigurableFixerInterface && property_exists($this, 'configuration') && null === $this->configuration) { throw new RequiredFixerConfigurationException($this->getName(), 'Configuration is required.'); } if (0 < $tokens->count() && $this->isCandidate($tokens) && $this->supports($file)) { $this->applyFix($file, $tokens); } } public function isRisky(): bool { return false; } public function getName(): string { return $this->name; } public function getPriority(): int { return 0; } public function supports(\SplFileInfo $file): bool { return true; } public function setWhitespacesConfig(WhitespacesFixerConfig $config): void { if (!$this instanceof WhitespacesAwareFixerInterface) { throw new \LogicException('Cannot run method for class not implementing "PhpCsFixer\Fixer\WhitespacesAwareFixerInterface".'); } $this->whitespacesConfig = $config; } abstract protected function applyFix(\SplFileInfo $file, Tokens $tokens): void; private function getDefaultWhitespacesFixerConfig(): WhitespacesFixerConfig { static $defaultWhitespacesFixerConfig = null; if (null === $defaultWhitespacesFixerConfig) { $defaultWhitespacesFixerConfig = new WhitespacesFixerConfig(' ', "\n"); } return $defaultWhitespacesFixerConfig; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ConfigInterface.php
src/ConfigInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Fixer\FixerInterface; /** * @author Fabien Potencier <fabien@symfony.com> * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface ConfigInterface { /** @internal */ public const PHP_VERSION_SYNTAX_SUPPORTED = '8.5'; /** * Returns the path to the cache file. * * @return null|non-empty-string Returns null if not using cache */ public function getCacheFile(): ?string; /** * Returns the custom fixers to use. * * @return list<FixerInterface> */ public function getCustomFixers(): array; /** * Returns files to scan. * * @return iterable<\SplFileInfo> */ public function getFinder(): iterable; public function getFormat(): string; /** * Returns true if progress should be hidden. */ public function getHideProgress(): bool; /** * @return non-empty-string */ public function getIndent(): string; /** * @return non-empty-string */ public function getLineEnding(): string; /** * Returns the name of the configuration. * * The name must be all lowercase and without any spaces. * * @return string The name of the configuration */ public function getName(): string; /** * Get configured PHP executable, if any. * * @deprecated * * @TODO 4.0 remove me */ public function getPhpExecutable(): ?string; /** * Check if it is allowed to run risky fixers. */ public function getRiskyAllowed(): bool; /** * Get rules. * * Keys of array are names of fixers/sets, values are true/false. * * @return array<string, array<string, mixed>|bool> */ public function getRules(): array; /** * Returns true if caching should be enabled. */ public function getUsingCache(): bool; /** * Adds a suite of custom fixers. * * Name of custom fixer should follow `VendorName/rule_name` convention. * * @param iterable<FixerInterface> $fixers */ public function registerCustomFixers(iterable $fixers): self; /** * Sets the path to the cache file. * * @param non-empty-string $cacheFile */ public function setCacheFile(string $cacheFile): self; /** * @param iterable<\SplFileInfo> $finder */ public function setFinder(iterable $finder): self; public function setFormat(string $format): self; public function setHideProgress(bool $hideProgress): self; /** * @param non-empty-string $indent */ public function setIndent(string $indent): self; /** * @param non-empty-string $lineEnding */ public function setLineEnding(string $lineEnding): self; /** * Set PHP executable. * * @deprecated * * @TODO 4.0 remove me */ public function setPhpExecutable(?string $phpExecutable): self; /** * Set if it is allowed to run risky fixers. */ public function setRiskyAllowed(bool $isRiskyAllowed): self; /** * Set rules. * * Keys of array are names of fixers or sets. * Value for set must be bool (turn it on or off). * Value for fixer may be bool (turn it on or off) or array of configuration * (turn it on and contains configuration for FixerInterface::configure method). * * @param array<string, array<string, mixed>|bool> $rules */ public function setRules(array $rules): self; public function setUsingCache(bool $usingCache): self; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ToolInfo.php
src/ToolInfo.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Console\Application; /** * Obtain information about using version of tool. * * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class ToolInfo implements ToolInfoInterface { public const COMPOSER_PACKAGE_NAME = 'friendsofphp/php-cs-fixer'; public const COMPOSER_LEGACY_PACKAGE_NAME = 'fabpot/php-cs-fixer'; /** * @var null|array{name: string, version: string, dist: array{reference?: string}} */ private ?array $composerInstallationDetails = null; private ?bool $isInstalledByComposer = null; public function getComposerInstallationDetails(): array { if (!$this->isInstalledByComposer()) { throw new \LogicException('Cannot get composer version for tool not installed by composer.'); } if (null === $this->composerInstallationDetails) { $composerInstalled = json_decode(file_get_contents($this->getComposerInstalledFile()), true, 512, \JSON_THROW_ON_ERROR); /** @var list<array{name: string, version: string, dist: array{reference?: string}}> $packages */ $packages = $composerInstalled['packages'] ?? $composerInstalled; foreach ($packages as $package) { if (\in_array($package['name'], [self::COMPOSER_PACKAGE_NAME, self::COMPOSER_LEGACY_PACKAGE_NAME], true)) { $this->composerInstallationDetails = $package; break; } } } return $this->composerInstallationDetails; } public function getComposerVersion(): string { $package = $this->getComposerInstallationDetails(); $versionSuffix = ''; if (isset($package['dist']['reference'])) { $versionSuffix = '#'.$package['dist']['reference']; } return $package['version'].$versionSuffix; } public function getVersion(): string { if ($this->isInstalledByComposer()) { return Application::VERSION.':'.$this->getComposerVersion(); } return Application::VERSION; } public function isInstalledAsPhar(): bool { return str_starts_with(__DIR__, 'phar://'); } public function isInstalledByComposer(): bool { if (null === $this->isInstalledByComposer) { $this->isInstalledByComposer = !$this->isInstalledAsPhar() && file_exists($this->getComposerInstalledFile()); } return $this->isInstalledByComposer; } /** * Determines if the tool is run inside our pre-built Docker image. * The `/fixer/` path comes from our Dockerfile, tool is installed there and added to global PATH via symlinked binary. */ public function isRunInsideDocker(): bool { return str_starts_with(__FILE__, '/fixer/') && is_file('/.dockerenv'); } public function getPharDownloadUri(string $version): string { return \sprintf( 'https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/%s/php-cs-fixer.phar', $version, ); } private function getComposerInstalledFile(): string { return __DIR__.'/../../../composer/installed.json'; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/FileRemoval.php
src/FileRemoval.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * Handles files removal with possibility to remove them on shutdown. * * @author Adam Klvač <adam@klva.cz> * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class FileRemoval { /** * List of observed files to be removed. * * @var array<string, true> */ private array $files = []; public function __construct() { register_shutdown_function([$this, 'clean']); } public function __destruct() { $this->clean(); } /** * This class is not intended to be serialized, * and cannot be deserialized (see __wakeup method). */ public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.self::class); } /** * Disable the deserialization of the class to prevent attacker executing * code by leveraging the __destruct method. * * @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection */ public function __wakeup(): void { throw new \BadMethodCallException('Cannot unserialize '.self::class); } /** * Adds a file to be removed. */ public function observe(string $path): void { $this->files[$path] = true; } /** * Removes a file from shutdown removal. */ public function delete(string $path): void { if (isset($this->files[$path])) { unset($this->files[$path]); } $this->unlink($path); } /** * Removes attached files. */ public function clean(): void { foreach ($this->files as $file => $value) { $this->unlink($file); } $this->files = []; } private function unlink(string $path): void { @unlink($path); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Utils.php
src/Utils.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\Tokenizer\Token; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * @author Graham Campbell <hello@gjcampbell.co.uk> * @author Odín del Río <odin.drp@gmail.com> * * @internal * * @deprecated This is a God Class anti-pattern. Don't expand it. It is fine to use logic that is already here (that's why we don't trigger deprecation warnings), but over time logic should be moved to dedicated, single-responsibility classes. * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class Utils { private function __construct() { // cannot create instance } /** * Converts a camel cased string to a snake cased string. */ public static function camelCaseToUnderscore(string $string): string { return mb_strtolower( Preg::replace( '/(?<!^)(?<!_)((?=[\p{Lu}][^\p{Lu}])|(?<![\p{Lu}])(?=[\p{Lu}]))/', '_', $string, ), ); } /** * Calculate the trailing whitespace. * * What we're doing here is grabbing everything after the final newline. */ public static function calculateTrailingWhitespaceIndent(Token $token): string { if (!$token->isWhitespace()) { throw new \InvalidArgumentException(\sprintf('The given token must be whitespace, got "%s".', $token->getName())); } $str = strrchr( str_replace(["\r\n", "\r"], "\n", $token->getContent()), "\n", ); if (false === $str) { return ''; } return ltrim($str, "\n"); } /** * Perform stable sorting using provided comparison function. * * Stability is ensured by using Schwartzian transform. * * @template T * @template L of list<T> * @template R * * @param L $elements * @param callable(T): R $getComparedValue a callable that takes a single element and returns the value to compare * @param callable(R, R): int $compareValues a callable that compares two values * * @return L */ public static function stableSort(array $elements, callable $getComparedValue, callable $compareValues): array { $sortItems = []; foreach ($elements as $index => $element) { $sortItems[] = [$element, $index, $getComparedValue($element)]; } usort($sortItems, static function ($a, $b) use ($compareValues): int { $comparison = $compareValues($a[2], $b[2]); if (0 !== $comparison) { return $comparison; } return $a[1] <=> $b[1]; }); return array_map(static fn (array $item) => $item[0], $sortItems); // @phpstan-ignore return.type (PHPStan cannot understand that the result will still be L template) } /** * Sort fixers by their priorities. * * @template T of list<FixerInterface> * * @param T $fixers * * @return T */ public static function sortFixers(array $fixers): array { // Schwartzian transform is used to improve the efficiency and avoid // `usort(): Array was modified by the user comparison function` warning for mocked objects. return self::stableSort( $fixers, static fn (FixerInterface $fixer): int => $fixer->getPriority(), static fn (int $a, int $b): int => $b <=> $a, ); } /** * Join names in natural language using specified wrapper (double quote by default). * * @param list<string> $names * * @throws \InvalidArgumentException */ public static function naturalLanguageJoin(array $names, string $wrapper = '"', string $lastJoin = 'and'): string { if (0 === \count($names)) { throw new \InvalidArgumentException('Array of names cannot be empty.'); } if (\strlen($wrapper) > 1) { throw new \InvalidArgumentException('Wrapper should be a single-char string or empty.'); } $names = array_map(static fn (string $name): string => \sprintf('%2$s%1$s%2$s', $name, $wrapper), $names); $last = array_pop($names); if (\count($names) > 0) { return implode(', ', $names).' '.$lastJoin.' '.$last; } return $last; } /** * Join names in natural language wrapped in backticks, e.g. `a`, `b` and `c`. * * @param list<string> $names * * @throws \InvalidArgumentException */ public static function naturalLanguageJoinWithBackticks(array $names, string $lastJoin = 'and'): string { return self::naturalLanguageJoin($names, '`', $lastJoin); } public static function convertArrayTypeToList(string $type): string { $parts = explode('[]', $type); $count = \count($parts) - 1; return str_repeat('list<', $count).$parts[0].str_repeat('>', $count); } /** * @param mixed $value */ public static function toString($value): string { return \is_array($value) ? self::arrayToString($value) : self::scalarToString($value); } /** * @param mixed $value */ private static function scalarToString($value): string { $str = var_export($value, true); return Preg::replace('/\bNULL\b/', 'null', $str); } /** * @param array<array-key, mixed> $value */ private static function arrayToString(array $value): string { if (0 === \count($value)) { return '[]'; } $isHash = !array_is_list($value); $str = '['; foreach ($value as $k => $v) { if ($isHash) { $str .= self::scalarToString($k).' => '; } $str .= \is_array($v) ? self::arrayToString($v).', ' : self::scalarToString($v).', '; } return substr($str, 0, -2).']'; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/ExecutorWithoutErrorHandlerException.php
src/ExecutorWithoutErrorHandlerException.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class ExecutorWithoutErrorHandlerException extends \RuntimeException {}
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Config.php
src/Config.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Config\RuleCustomisationPolicyAwareConfigInterface; use PhpCsFixer\Config\RuleCustomisationPolicyInterface; use PhpCsFixer\Fixer\FixerInterface; use PhpCsFixer\RuleSet\RuleSetDefinitionInterface; use PhpCsFixer\Runner\Parallel\ParallelConfig; use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; /** * @author Fabien Potencier <fabien@symfony.com> * @author Katsuhiro Ogawa <ko.fivestar@gmail.com> * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. * * @api-extendable */ class Config implements ConfigInterface, ParallelAwareConfigInterface, UnsupportedPhpVersionAllowedConfigInterface, CustomRulesetsAwareConfigInterface, RuleCustomisationPolicyAwareConfigInterface { /** * @var non-empty-string */ private string $cacheFile = '.php-cs-fixer.cache'; /** * @var list<FixerInterface> */ private array $customFixers = []; /** * @var array<string, RuleSetDefinitionInterface> */ private array $customRuleSets = []; /** * @var null|iterable<\SplFileInfo> */ private ?iterable $finder = null; private string $format; private bool $hideProgress = false; /** * @var non-empty-string */ private string $indent = ' '; private bool $isRiskyAllowed = false; /** * @var non-empty-string */ private string $lineEnding = "\n"; private string $name; private ParallelConfig $parallelConfig; private ?string $phpExecutable = null; /** * @TODO: 4.0 - update to @PER * * @var array<string, array<string, mixed>|bool> */ private array $rules; private bool $usingCache = true; private bool $isUnsupportedPhpVersionAllowed = false; private ?RuleCustomisationPolicyInterface $ruleCustomisationPolicy = null; public function __construct(string $name = 'default') { $this->name = $name.(Future::isFutureModeEnabled() ? ' (future mode)' : ''); $this->rules = Future::getV4OrV3(['@PER-CS' => true], ['@PSR12' => true]); // @TODO 4.0 | 3.x switch to '@auto' for v4 $this->format = Future::getV4OrV3('@auto', 'txt'); // @TODO 4.0 cleanup if (Future::isFutureModeEnabled() || filter_var(getenv('PHP_CS_FIXER_PARALLEL'), \FILTER_VALIDATE_BOOL)) { $this->parallelConfig = ParallelConfigFactory::detect(); } else { $this->parallelConfig = ParallelConfigFactory::sequential(); } // @TODO 4.0 cleanup if (false !== getenv('PHP_CS_FIXER_IGNORE_ENV')) { $this->isUnsupportedPhpVersionAllowed = filter_var(getenv('PHP_CS_FIXER_IGNORE_ENV'), \FILTER_VALIDATE_BOOL); } } /** * @return non-empty-string */ public function getCacheFile(): string { return $this->cacheFile; } public function getCustomFixers(): array { return $this->customFixers; } public function getCustomRuleSets(): array { return array_values($this->customRuleSets); } /** * @return iterable<\SplFileInfo> */ public function getFinder(): iterable { $this->finder ??= new Finder(); return $this->finder; } public function getFormat(): string { return $this->format; } public function getHideProgress(): bool { return $this->hideProgress; } public function getIndent(): string { return $this->indent; } public function getLineEnding(): string { return $this->lineEnding; } public function getName(): string { return $this->name; } public function getParallelConfig(): ParallelConfig { return $this->parallelConfig; } public function getPhpExecutable(): ?string { return $this->phpExecutable; } public function getRiskyAllowed(): bool { return $this->isRiskyAllowed; } public function getRules(): array { return $this->rules; } public function getUsingCache(): bool { return $this->usingCache; } public function getUnsupportedPhpVersionAllowed(): bool { return $this->isUnsupportedPhpVersionAllowed; } public function getRuleCustomisationPolicy(): ?RuleCustomisationPolicyInterface { return $this->ruleCustomisationPolicy; } public function registerCustomFixers(iterable $fixers): ConfigInterface { foreach ($fixers as $fixer) { $this->addCustomFixer($fixer); } return $this; } /** * @param list<RuleSetDefinitionInterface> $ruleSets */ public function registerCustomRuleSets(array $ruleSets): ConfigInterface { foreach ($ruleSets as $ruleset) { $this->customRuleSets[$ruleset->getName()] = $ruleset; } return $this; } /** * @param non-empty-string $cacheFile */ public function setCacheFile(string $cacheFile): ConfigInterface { $this->cacheFile = $cacheFile; return $this; } public function setFinder(iterable $finder): ConfigInterface { $this->finder = $finder; return $this; } public function setFormat(string $format): ConfigInterface { $this->format = $format; return $this; } public function setHideProgress(bool $hideProgress): ConfigInterface { $this->hideProgress = $hideProgress; return $this; } /** * @param non-empty-string $indent */ public function setIndent(string $indent): ConfigInterface { $this->indent = $indent; return $this; } /** * @param non-empty-string $lineEnding */ public function setLineEnding(string $lineEnding): ConfigInterface { $this->lineEnding = $lineEnding; return $this; } public function setParallelConfig(ParallelConfig $config): ConfigInterface { $this->parallelConfig = $config; return $this; } public function setPhpExecutable(?string $phpExecutable): ConfigInterface { $this->phpExecutable = $phpExecutable; return $this; } public function setRiskyAllowed(bool $isRiskyAllowed): ConfigInterface { $this->isRiskyAllowed = $isRiskyAllowed; return $this; } public function setRules(array $rules): ConfigInterface { $this->rules = $rules; return $this; } public function setUsingCache(bool $usingCache): ConfigInterface { $this->usingCache = $usingCache; return $this; } public function setUnsupportedPhpVersionAllowed(bool $isUnsupportedPhpVersionAllowed): ConfigInterface { $this->isUnsupportedPhpVersionAllowed = $isUnsupportedPhpVersionAllowed; return $this; } public function setRuleCustomisationPolicy(?RuleCustomisationPolicyInterface $ruleCustomisationPolicy): ConfigInterface { // explicitly prevent policy with no proper version defined if (null !== $ruleCustomisationPolicy && '' === $ruleCustomisationPolicy->getPolicyVersionForCache()) { throw new \InvalidArgumentException('The Rule Customisation Policy version cannot be an empty string.'); } $this->ruleCustomisationPolicy = $ruleCustomisationPolicy; return $this; } private function addCustomFixer(FixerInterface $fixer): void { $this->customFixers[] = $fixer; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/UnsupportedPhpVersionAllowedConfigInterface.php
src/UnsupportedPhpVersionAllowedConfigInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @TODO 4.0 Include in main ConfigInterface * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface UnsupportedPhpVersionAllowedConfigInterface extends ConfigInterface { /** * Returns true if execution should be allowed on unsupported PHP version whose syntax is not yet supported by the fixer. */ public function getUnsupportedPhpVersionAllowed(): bool; public function setUnsupportedPhpVersionAllowed(bool $isUnsupportedPhpVersionAllowed): ConfigInterface; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/PharCheckerInterface.php
src/PharCheckerInterface.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ interface PharCheckerInterface { /** * @return null|string the invalidity reason if any, null otherwise */ public function checkFileValidity(string $filename): ?string; }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/FileReader.php
src/FileReader.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * File reader that unify access to regular file and stdin-alike file. * * Regular file could be read multiple times with `file_get_contents`, but file provided on stdin cannot. * Consecutive try will provide empty content for stdin-alike file. * This reader unifies access to them. * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class FileReader { private ?string $stdinContent = null; public static function createSingleton(): self { static $instance = null; if (!$instance) { $instance = new self(); } return $instance; } public function read(string $filePath): string { if ('php://stdin' === $filePath) { if (null === $this->stdinContent) { $this->stdinContent = $this->readRaw($filePath); } return $this->stdinContent; } return $this->readRaw($filePath); } private function readRaw(string $realPath): string { $content = @file_get_contents($realPath); if (false === $content) { $error = error_get_last(); throw new \RuntimeException(\sprintf( 'Failed to read content from "%s".%s', $realPath, null !== $error ? ' '.$error['message'] : '', )); } return $content; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Future.php
src/Future.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class Future { /** * @var array<string, true> */ private static array $deprecations = []; private function __construct() { // cannot create instance } public static function isFutureModeEnabled(): bool { return filter_var( getenv('PHP_CS_FIXER_FUTURE_MODE'), \FILTER_VALIDATE_BOOL, ); } public static function triggerDeprecation(\Exception $futureException): void { if (self::isFutureModeEnabled()) { throw new \RuntimeException( 'Your are using something deprecated, see previous exception. Aborting execution because `PHP_CS_FIXER_FUTURE_MODE` environment variable is set.', 0, $futureException, ); } $message = $futureException->getMessage(); self::$deprecations[$message] = true; @trigger_error($message, \E_USER_DEPRECATED); } /** * @return list<string> */ public static function getTriggeredDeprecations(): array { $triggeredDeprecations = array_keys(self::$deprecations); sort($triggeredDeprecations); return $triggeredDeprecations; } /** * @template T * * @param T $new * @param T $old * * @return T * * @TODO v4.0: remove this method, ensure code compiles, create getV5OrV4. While removing, ensure to document in `UPGRADE-vX.md` file. */ public static function getV4OrV3($new, $old) { return self::getNewOrOld($new, $old); } /** * @template T * * @param T $new * @param T $old * * @return T */ private static function getNewOrOld($new, $old) { return self::isFutureModeEnabled() ? $new : $old; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Hasher.php
src/Hasher.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; /** * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ final class Hasher { private function __construct() { // cannot create instance of util. class } /** * @return non-empty-string */ public static function calculate(string $code): string { return \PHP_VERSION_ID >= 8_01_00 ? hash('xxh128', $code) : md5($code); } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractFopenFlagFixer.php
src/AbstractFopenFlagFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Tokenizer\Analyzer\ArgumentsAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @internal * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractFopenFlagFixer extends AbstractFunctionReferenceFixer { public function isCandidate(Tokens $tokens): bool { return $tokens->isAllTokenKindsFound([\T_STRING, \T_CONSTANT_ENCAPSED_STRING]); } protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { $argumentsAnalyzer = new ArgumentsAnalyzer(); $index = 0; $end = $tokens->count() - 1; while (true) { $candidate = $this->find('fopen', $tokens, $index, $end); if (null === $candidate) { break; } $index = $candidate[1]; // proceed to '(' of `fopen` // fetch arguments $arguments = $argumentsAnalyzer->getArguments( $tokens, $index, $candidate[2], ); $argumentsCount = \count($arguments); // argument count sanity check if ($argumentsCount < 2 || $argumentsCount > 4) { continue; } $argumentStartIndex = array_keys($arguments)[1]; // get second argument index $this->fixFopenFlagToken( $tokens, $argumentStartIndex, $arguments[$argumentStartIndex], ); } } abstract protected function fixFopenFlagToken(Tokens $tokens, int $argumentStartIndex, int $argumentEndIndex): void; protected function isValidModeString(string $mode): bool { $modeLength = \strlen($mode); if ($modeLength < 1 || $modeLength > 13) { // 13 === length 'r+w+a+x+c+etb' return false; } $validFlags = [ 'a' => true, 'b' => true, 'c' => true, 'e' => true, 'r' => true, 't' => true, 'w' => true, 'x' => true, ]; if (!isset($validFlags[$mode[0]])) { return false; } unset($validFlags[$mode[0]]); for ($i = 1; $i < $modeLength; ++$i) { if (isset($validFlags[$mode[$i]])) { unset($validFlags[$mode[$i]]); continue; } if ('+' !== $mode[$i] || ( 'a' !== $mode[$i - 1] // 'a+','c+','r+','w+','x+' && 'c' !== $mode[$i - 1] && 'r' !== $mode[$i - 1] && 'w' !== $mode[$i - 1] && 'x' !== $mode[$i - 1] ) ) { return false; } } return true; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/AbstractNoUselessElseFixer.php
src/AbstractNoUselessElseFixer.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use PhpCsFixer\Tokenizer\Tokens; /** * @no-named-arguments Parameter names are not covered by the backward compatibility promise. */ abstract class AbstractNoUselessElseFixer extends AbstractFixer { public function getPriority(): int { // should be run before NoWhitespaceInBlankLineFixer, NoExtraBlankLinesFixer, BracesFixer and after NoEmptyStatementFixer. return 39; } protected function isSuperfluousElse(Tokens $tokens, int $index): bool { $previousBlockStart = $index; do { // Check if all 'if', 'else if ' and 'elseif' blocks above this 'else' always end, // if so this 'else' is overcomplete. [$previousBlockStart, $previousBlockEnd] = $this->getPreviousBlock($tokens, $previousBlockStart); // short 'if' detection $previous = $previousBlockEnd; if ($tokens[$previous]->equals('}')) { $previous = $tokens->getPrevMeaningfulToken($previous); } if ( !$tokens[$previous]->equals(';') // 'if' block doesn't end with semicolon, keep 'else' || $tokens[$tokens->getPrevMeaningfulToken($previous)]->equals('{') // empty 'if' block, keep 'else' ) { return false; } $candidateIndex = $tokens->getPrevTokenOfKind( $previous, [ ';', [\T_BREAK], [\T_CLOSE_TAG], [\T_CONTINUE], [\T_EXIT], [\T_GOTO], [\T_IF], [\T_RETURN], [\T_THROW], ], ); if (null === $candidateIndex || $tokens[$candidateIndex]->equalsAny([';', [\T_CLOSE_TAG], [\T_IF]])) { return false; } if ($tokens[$candidateIndex]->isGivenKind(\T_THROW)) { $previousIndex = $tokens->getPrevMeaningfulToken($candidateIndex); if (!$tokens[$previousIndex]->equalsAny([';', '{'])) { return false; } } if ($this->isInConditional($tokens, $candidateIndex, $previousBlockStart) || $this->isInConditionWithoutBraces($tokens, $candidateIndex, $previousBlockStart) ) { return false; } // implicit continue, i.e. delete candidate } while (!$tokens[$previousBlockStart]->isGivenKind(\T_IF)); return true; } /** * Return the first and last token index of the previous block. * * [0] First is either T_IF, T_ELSE or T_ELSEIF * [1] Last is either '}' or ';' / T_CLOSE_TAG for short notation blocks * * @param int $index T_IF, T_ELSE, T_ELSEIF * * @return array{int, int} */ private function getPreviousBlock(Tokens $tokens, int $index): array { $close = $previous = $tokens->getPrevMeaningfulToken($index); // short 'if' detection if ($tokens[$close]->equals('}')) { $previous = $tokens->findBlockStart(Tokens::BLOCK_TYPE_CURLY_BRACE, $close); } $open = $tokens->getPrevTokenOfKind($previous, [[\T_IF], [\T_ELSE], [\T_ELSEIF]]); if ($tokens[$open]->isGivenKind(\T_IF)) { $elseCandidate = $tokens->getPrevMeaningfulToken($open); if ($tokens[$elseCandidate]->isGivenKind(\T_ELSE)) { $open = $elseCandidate; } } return [$open, $close]; } /** * @param int $index Index of the token to check * @param int $lowerLimitIndex Lower limit index. Since the token to check will always be in a conditional we must stop checking at this index */ private function isInConditional(Tokens $tokens, int $index, int $lowerLimitIndex): bool { $candidateIndex = $tokens->getPrevTokenOfKind($index, [')', ';', ':']); if ($tokens[$candidateIndex]->equals(':')) { return true; } if (!$tokens[$candidateIndex]->equals(')')) { return false; // token is ';' or close tag } // token is always ')' here. // If it is part of the condition the token is always in, return false. // If it is not it is a nested condition so return true $open = $tokens->findBlockStart(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $candidateIndex); return $tokens->getPrevMeaningfulToken($open) > $lowerLimitIndex; } /** * For internal use only, as it is not perfect. * * Returns if the token at given index is part of an if/elseif/else statement * without {}. Assumes not passing the last `;`/close tag of the statement, not * out of range index, etc. * * @param int $index Index of the token to check */ private function isInConditionWithoutBraces(Tokens $tokens, int $index, int $lowerLimitIndex): bool { do { if ($tokens[$index]->isComment() || $tokens[$index]->isWhitespace()) { $index = $tokens->getPrevMeaningfulToken($index); } $token = $tokens[$index]; if ($token->isGivenKind([\T_IF, \T_ELSEIF, \T_ELSE])) { return true; } if ($token->equals(';')) { return false; } if ($token->equals('{')) { $index = $tokens->getPrevMeaningfulToken($index); // OK if belongs to: for, do, while, foreach // Not OK if belongs to: if, else, elseif if ($tokens[$index]->isGivenKind(\T_DO)) { --$index; continue; } if (!$tokens[$index]->equals(')')) { return false; // like `else {` } $index = $tokens->findBlockStart( Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index, ); $index = $tokens->getPrevMeaningfulToken($index); if ($tokens[$index]->isGivenKind([\T_IF, \T_ELSEIF])) { return false; } } elseif ($token->equals(')')) { $type = Tokens::detectBlockType($token); $index = $tokens->findBlockStart( $type['type'], $index, ); $index = $tokens->getPrevMeaningfulToken($index); } else { --$index; } } while ($index > $lowerLimitIndex); return false; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false
PHP-CS-Fixer/PHP-CS-Fixer
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/63b024eaaf8a48445494964bd21a6c38c788f40f/src/Finder.php
src/Finder.php
<?php declare(strict_types=1); /* * This file is part of PHP CS Fixer. * * (c) Fabien Potencier <fabien@symfony.com> * Dariusz Rumiński <dariusz.ruminski@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer; use Symfony\Component\Finder\Finder as BaseFinder; /** * @author Fabien Potencier <fabien@symfony.com> * @author Dariusz Rumiński <dariusz.ruminski@gmail.com> * * @no-named-arguments Parameter names are not covered by the backward compatibility promise. * * @api-extendable */ class Finder extends BaseFinder { public function __construct() { parent::__construct(); $this ->files() ->name('/\.php$/') ->exclude('vendor') ->ignoreDotFiles(Future::getV4OrV3(false, true)) ->ignoreVCS(true) // explicitly configure to not rely on Symfony default ; } }
php
MIT
63b024eaaf8a48445494964bd21a6c38c788f40f
2026-01-04T15:02:54.911792Z
false