Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions system/Debug/BaseExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ abstract public function handle(

/**
* Gathers the variables that will be made available to the view.
*
* @return array{
* title: string,
* type: string,
* code: int,
* message: string,
* file: string,
* line: int,
* trace: list<array<string, mixed>>,
* }
*/
protected function collectVars(Throwable $exception, int $statusCode): array
{
Expand Down Expand Up @@ -99,6 +109,11 @@ protected function collectVars(Throwable $exception, int $statusCode): array

/**
* Mask sensitive data in the trace.
*
* @param list<array<string, mixed>> $trace
* @param list<string> $keysToMask
*
* @return list<array<string, mixed>>
*/
protected function maskSensitiveData(array $trace, array $keysToMask, string $path = ''): array
{
Expand All @@ -110,9 +125,10 @@ protected function maskSensitiveData(array $trace, array $keysToMask, string $pa
}

/**
* @param array|object $args
* @param array<array-key, mixed>|object $args
* @param list<string> $keysToMask
*
* @return array|object
* @return array<array-key, mixed>|object
*/
private function maskData($args, array $keysToMask, string $path = '')
{
Expand Down
14 changes: 10 additions & 4 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ protected function render(Throwable $exception, int $statusCode)
/**
* Gathers the variables that will be made available to the view.
*
* @return array{title: string, type: string, code: int, message: string, file: string, line: int, trace: list<array<string, mixed>>}
*
* @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler.
*/
protected function collectVars(Throwable $exception, int $statusCode): array
Expand Down Expand Up @@ -386,9 +388,10 @@ protected function collectVars(Throwable $exception, int $statusCode): array
/**
* Mask sensitive data in the trace.
*
* @param array $trace
* @param list<array<string, mixed>> $trace
* @param list<string> $keysToMask
*
* @return array
* @return list<array<string, mixed>>
*
* @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler.
*/
Expand All @@ -402,9 +405,10 @@ protected function maskSensitiveData($trace, array $keysToMask, string $path = '
}

/**
* @param array|object $args
* @param array<array-key, mixed>|object $args
* @param list<string> $keysToMask
*
* @return array|object
* @return array<array-key, mixed>|object
*
* @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler.
*/
Expand Down Expand Up @@ -441,6 +445,8 @@ private function maskData($args, array $keysToMask, string $path = '')

/**
* Determines the HTTP status code and the exit status code for this request.
*
* @return array{int, int}
*/
protected function determineCodes(Throwable $exception): array
{
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class Iterator
/**
* Stores the tests that we are to run.
*
* @var array
* @var array<string, Closure(): mixed>
*/
protected $tests = [];

/**
* Stores the results of each of the tests.
*
* @var array
* @var array<string, array{time: float, memory: int, n: int}>
*/
protected $results = [];

Expand Down
4 changes: 3 additions & 1 deletion system/Debug/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Timer
/**
* List of all timers.
*
* @var array
* @var array<string, array{start: float, end: float|null}>
*/
protected $timers = [];

Expand Down Expand Up @@ -107,6 +107,8 @@ public function getElapsedTime(string $name, int $decimals = 4)
* Returns the array of timers, with the duration pre-calculated for you.
*
* @param int $decimals Number of decimal places
*
* @return array<string, array{start: float, end: float, duration: float}>
*/
public function getTimers(int $decimals = 4): array
{
Expand Down
16 changes: 15 additions & 1 deletion system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public function run(float $startTime, float $totalTime, RequestInterface $reques

/**
* Called within the view to display the timeline itself.
*
* @param list<array{hasTimelineData: bool, timelineData: list<array<string, mixed>>}> $collectors
* @param array<string, string> $styles
*/
protected function renderTimeline(array $collectors, float $startTime, int $segmentCount, int $segmentDuration, array &$styles): string
{
Expand All @@ -202,6 +205,9 @@ protected function renderTimeline(array $collectors, float $startTime, int $segm

/**
* Recursively renders timeline elements and their children.
*
* @param list<array<string, mixed>> $rows
* @param array<string, string> $styles
*/
protected function renderTimelineRecursive(array $rows, float $startTime, int $segmentCount, int $segmentDuration, array &$styles, int &$styleCount, int $level = 0, bool $isChild = false): string
{
Expand Down Expand Up @@ -268,7 +274,9 @@ protected function renderTimelineRecursive(array $rows, float $startTime, int $s
/**
* Returns a sorted array of timeline data arrays from the collectors.
*
* @param array $collectors
* @param list<array{hasTimelineData: bool, timelineData: list<array<string, mixed>>}> $collectors
*
* @return list<array<string, mixed>>
*/
protected function collectTimelineData($collectors): array
{
Expand Down Expand Up @@ -305,6 +313,10 @@ protected function collectTimelineData($collectors): array

/**
* Arranges the already sorted timeline data into a parent => child structure.
*
* @param list<array<string, mixed>> $elements
*
* @return list<array<string, mixed>>
*/
protected function structureTimelineData(array $elements): array
{
Expand Down Expand Up @@ -333,6 +345,8 @@ protected function structureTimelineData(array $elements): array
/**
* Returns an array of data from all of the modules
* that should be displayed in the 'Vars' tab.
*
* @return array<string, mixed>
*/
protected function collectVarData(): array
{
Expand Down
22 changes: 20 additions & 2 deletions system/Debug/Toolbar/Collectors/BaseCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public function hasTimelineData(): bool
/**
* Grabs the data for the timeline, properly formatted,
* or returns an empty array.
*
* @return list<array<string, mixed>>
*/
public function timelineData(): array
{
Expand Down Expand Up @@ -140,7 +142,7 @@ public function hasVarData(): bool
* ],
* ];
*
* @return array|null
* @return array<string, mixed>|null
*/
public function getVarData()
{
Expand All @@ -159,6 +161,8 @@ public function getVarData()
* 'start' => 10 // milliseconds
* 'duration' => 15 // milliseconds
* ]
*
* @return list<array<string, mixed>>
*/
protected function formatTimelineData(): array
{
Expand All @@ -168,7 +172,7 @@ protected function formatTimelineData(): array
/**
* Returns the data of this collector to be formatted in the toolbar
*
* @return array|string
* @return array<string, mixed>|string
*/
public function display()
{
Expand Down Expand Up @@ -218,6 +222,20 @@ public function icon(): string

/**
* Return settings as an array.
*
* @return array{
* title: string,
* titleSafe: string,
* titleDetails: string,
* display: array<string, mixed>|string,
* badgeValue: int|null,
* isEmpty: bool,
* hasTabContent: bool,
* hasLabel: bool,
* icon: string,
* hasTimelineData: bool,
* timelineData: list<array<string, mixed>>,
* }
*/
public function getAsArray(): array
{
Expand Down
11 changes: 11 additions & 0 deletions system/Debug/Toolbar/Collectors/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ class Config
{
/**
* Return toolbar config values as an array.
*
* @return array{
* ciVersion: string,
* phpVersion: string,
* phpSAPI: string,
* environment: string,
* baseURL: string,
* timezone: string,
* locale: string,
* cspEnabled: bool,
* }
*/
public static function display(): array
{
Expand Down
23 changes: 20 additions & 3 deletions system/Debug/Toolbar/Collectors/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace CodeIgniter\Debug\Toolbar\Collectors;

use CodeIgniter\Database\BaseConnection;
use CodeIgniter\Database\Query;
use CodeIgniter\I18n\Time;
use Config\Toolbar;
Expand Down Expand Up @@ -55,15 +56,15 @@ class Database extends BaseCollector
/**
* Array of database connections.
*
* @var array
* @var array<string, BaseConnection>
*/
protected $connections;

/**
* The query instances that have been collected
* through the DBQuery Event.
*
* @var array
* @var list<array{query: Query, string: string, duplicate: bool, trace: list<array<string, mixed>>}>
*/
protected static $queries = [];

Expand Down Expand Up @@ -113,7 +114,13 @@ public static function collect(Query $query)
/**
* Returns timeline data formatted for the toolbar.
*
* @return array The formatted data or an empty array.
* @return list<array{
* name: string,
* component: string,
* start: float|string|null,
* duration: string,
* query?: string,
* }>
*/
protected function formatTimelineData(): array
{
Expand Down Expand Up @@ -144,6 +151,16 @@ protected function formatTimelineData(): array

/**
* Returns the data of this collector to be formatted in the toolbar
*
* @return array{queries: list<array{
* hover: string,
* class: string,
* duration: string,
* sql: string,
* trace: list<array<string, mixed>>,
* trace-file: string,
* qid: string
* }>}
*/
public function display(): array
{
Expand Down
4 changes: 4 additions & 0 deletions system/Debug/Toolbar/Collectors/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Events extends BaseCollector
/**
* Child classes should implement this to return the timeline data
* formatted for correct usage.
*
* @return list<array{name: string, component: string, start: float, duration: float}>
*/
protected function formatTimelineData(): array
{
Expand All @@ -74,6 +76,8 @@ protected function formatTimelineData(): array

/**
* Returns the data of this collector to be formatted in the toolbar
*
* @return array{events: array<string, array{event: string, duration: string, count: int}>}
*/
public function display(): array
{
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Toolbar/Collectors/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function getTitleDetails(): string

/**
* Returns the data of this collector to be formatted in the toolbar
*
* @return array{coreFiles: list<array{path: string, name: string}>, userFiles: list<array{path: string, name: string}>}
*/
public function display(): array
{
Expand Down
22 changes: 21 additions & 1 deletion system/Debug/Toolbar/Collectors/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ class History extends BaseCollector
protected $title = 'History';

/**
* @var array History files
* @var list<array{
* time: string,
* datetime: string,
* active: bool,
* status: mixed,
* method: mixed,
* url: mixed,
* isAJAX: string,
* contentType: mixed
* }>
*/
protected $files = [];

Expand Down Expand Up @@ -111,6 +120,17 @@ public function setFiles(string $current, int $limit = 20)

/**
* Returns the data of this collector to be formatted in the toolbar
*
* @return array{files: list<array{
* time: string,
* datetime: string,
* active: bool,
* status: mixed,
* method: mixed,
* url: mixed,
* isAJAX: string,
* contentType: mixed
* }>}
*/
public function display(): array
{
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Toolbar/Collectors/Timers.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Timers extends BaseCollector
/**
* Child classes should implement this to return the timeline data
* formatted for correct usage.
*
* @return list<array{name: string, component: string, start: float, duration: float}>
*/
protected function formatTimelineData(): array
{
Expand Down
Loading
Loading