Skip to content

Commit ab913e3

Browse files
authored
Merge pull request #8274 from kenjis/update-kint-to-5.1.0
chore: update Kint to 5.1.0
2 parents 93e9c6b + 84903e0 commit ab913e3

25 files changed

Lines changed: 101 additions & 64 deletions

system/ThirdParty/Kint/CallFinder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class CallFinder
138138
/**
139139
* @psalm-param callable-array|callable-string $function
140140
*
141-
* @param mixed $function
141+
* @psalm-return list<array{parameters: list, modifiers: list<PhpToken>}>
142142
*
143143
* @return array List of matching calls on the relevant line
144144
*/
@@ -187,6 +187,7 @@ public static function getFunctionCalls(string $source, int $line, $function): a
187187
$identifier[T_NAME_RELATIVE] = true;
188188
}
189189

190+
/** @psalm-var list<PhpToken> */
190191
$tokens = \token_get_all($source);
191192
$cursor = 1;
192193
$function_calls = [];
@@ -449,8 +450,6 @@ private static function realTokenIndex(array $tokens, int $index): ?int
449450
* for `$token[0]` then "..." will incorrectly match the "." operator.
450451
*
451452
* @psalm-param PhpToken $token The token to check
452-
*
453-
* @param mixed $token
454453
*/
455454
private static function tokenIsOperator($token): bool
456455
{

system/ThirdParty/Kint/Kint.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class Kint implements FacadeInterface
133133
public static $aliases = [
134134
['Kint\\Kint', 'dump'],
135135
['Kint\\Kint', 'trace'],
136-
['Kint\\Kint', 'dumpArray'],
136+
['Kint\\Kint', 'dumpAll'],
137137
];
138138

139139
/**
@@ -537,7 +537,7 @@ public static function trace()
537537
*
538538
* Functionally equivalent to Kint::dump(1) or Kint::dump(debug_backtrace())
539539
*
540-
* @param mixed ...$args
540+
* @psalm-param array ...$args
541541
*
542542
* @return int|string
543543
*/
@@ -599,6 +599,7 @@ public static function shortenPath(string $file): string
599599
$match = '/';
600600

601601
foreach (static::$app_root_dirs as $path => $alias) {
602+
/** @psalm-var string $path */
602603
if (empty($path)) {
603604
continue;
604605
}

system/ThirdParty/Kint/Parser/BlacklistPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
use Kint\Zval\InstanceValue;
3131
use Kint\Zval\Value;
32+
use Psr\Container\ContainerInterface;
3233

3334
class BlacklistPlugin extends AbstractPlugin
3435
{
@@ -44,7 +45,7 @@ class BlacklistPlugin extends AbstractPlugin
4445
*
4546
* @var array
4647
*/
47-
public static $shallow_blacklist = ['Psr\\Container\\ContainerInterface'];
48+
public static $shallow_blacklist = [ContainerInterface::class];
4849

4950
public function getTypes(): array
5051
{

system/ThirdParty/Kint/Parser/ClosurePlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function parse(&$var, Value &$o, int $trigger): void
6767
}
6868

6969
$p = new Representation('Parameters');
70-
$p->contents = &$o->parameters;
70+
$p->contents = $o->parameters;
7171
$o->addRepresentation($p, 0);
7272

7373
$statics = [];

system/ThirdParty/Kint/Parser/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Parser
7272
* @param int $depth_limit Maximum depth to parse data
7373
* @param ?string $caller Caller class name
7474
*/
75-
public function __construct(int $depth_limit = 0, ?string $caller = null)
75+
public function __construct(int $depth_limit = 0, string $caller = null)
7676
{
7777
$this->marker = "kint\0".\random_bytes(16);
7878

@@ -83,7 +83,7 @@ public function __construct(int $depth_limit = 0, ?string $caller = null)
8383
/**
8484
* Set the caller class.
8585
*/
86-
public function setCallerClass(?string $caller = null): void
86+
public function setCallerClass(string $caller = null): void
8787
{
8888
$this->noRecurseCall();
8989

system/ThirdParty/Kint/Parser/PluginInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getTypes(): array;
3838
public function getTriggers(): int;
3939

4040
/**
41-
* @param mixed &$var
41+
* @psalm-param mixed &$var
4242
*/
4343
public function parse(&$var, Value &$o, int $trigger): void;
4444
}

system/ThirdParty/Kint/Parser/TablePlugin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
use Kint\Zval\Representation\Representation;
3131
use Kint\Zval\Value;
3232

33+
// Note: Interaction with ArrayLimitPlugin:
34+
// Any array limited children will be shown in tables identically to
35+
// non-array-limited children since the table only shows that it is an array
36+
// and it's size anyway. Because ArrayLimitPlugin halts the parse on finding
37+
// a limit all other plugins including this one are stopped, so you cannot get
38+
// a tabular representation of an array that is longer than the limit.
3339
class TablePlugin extends AbstractPlugin
3440
{
3541
public function getTypes(): array

system/ThirdParty/Kint/Renderer/RichRenderer.php

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ class RichRenderer extends AbstractRenderer
140140
*/
141141
public static $sort = self::SORT_NONE;
142142

143+
/**
144+
* Timestamp to print in footer in date() format.
145+
*
146+
* @var ?string
147+
*/
148+
public static $timestamp = null;
149+
143150
public static $needs_pre_render = true;
144151
public static $needs_folder_render = true;
145152

@@ -465,29 +472,7 @@ public function postRender(): string
465472
$output .= '<nav></nav>';
466473
}
467474

468-
if (isset($this->call_info['callee']['file'])) {
469-
$output .= 'Called from '.$this->ideLink(
470-
$this->call_info['callee']['file'],
471-
$this->call_info['callee']['line']
472-
);
473-
}
474-
475-
if (
476-
isset($this->call_info['callee']['function']) &&
477-
(
478-
!empty($this->call_info['callee']['class']) ||
479-
!\in_array(
480-
$this->call_info['callee']['function'],
481-
['include', 'include_once', 'require', 'require_once'],
482-
true
483-
)
484-
)
485-
) {
486-
$output .= ' [';
487-
$output .= $this->call_info['callee']['class'] ?? '';
488-
$output .= $this->call_info['callee']['type'] ?? '';
489-
$output .= $this->call_info['callee']['function'].'()]';
490-
}
475+
$output .= $this->calledFrom();
491476

492477
if (!empty($this->call_info['trace']) && \count($this->call_info['trace']) > 1) {
493478
$output .= '<ol>';
@@ -497,8 +482,8 @@ public function postRender(): string
497482
}
498483

499484
$output .= '<li>'.$this->ideLink($step['file'], $step['line']); // closing tag not required
500-
if (isset($step['function'])
501-
&& !\in_array($step['function'], ['include', 'include_once', 'require', 'require_once'], true)
485+
if (isset($step['function']) &&
486+
!\in_array($step['function'], ['include', 'include_once', 'require', 'require_once'], true)
502487
) {
503488
$output .= ' [';
504489
$output .= $step['class'] ?? '';
@@ -516,8 +501,6 @@ public function postRender(): string
516501

517502
/**
518503
* @psalm-param Encoding $encoding
519-
*
520-
* @param mixed $encoding
521504
*/
522505
public function escape(string $string, $encoding = false): string
523506
{
@@ -559,6 +542,45 @@ public function ideLink(string $file, int $line): string
559542
return '<a '.$class.'href="'.$this->escape($ideLink).'">'.$path.'</a>';
560543
}
561544

545+
protected function calledFrom(): string
546+
{
547+
$output = '';
548+
549+
if (isset($this->call_info['callee']['file'])) {
550+
$output .= ' '.$this->ideLink(
551+
$this->call_info['callee']['file'],
552+
$this->call_info['callee']['line']
553+
);
554+
}
555+
556+
if (
557+
isset($this->call_info['callee']['function']) &&
558+
(
559+
!empty($this->call_info['callee']['class']) ||
560+
!\in_array(
561+
$this->call_info['callee']['function'],
562+
['include', 'include_once', 'require', 'require_once'],
563+
true
564+
)
565+
)
566+
) {
567+
$output .= ' [';
568+
$output .= $this->call_info['callee']['class'] ?? '';
569+
$output .= $this->call_info['callee']['type'] ?? '';
570+
$output .= $this->call_info['callee']['function'].'()]';
571+
}
572+
573+
if ('' !== $output) {
574+
$output = 'Called from'.$output;
575+
}
576+
577+
if (null !== self::$timestamp) {
578+
$output .= ' '.\date(self::$timestamp);
579+
}
580+
581+
return $output;
582+
}
583+
562584
protected function renderTab(Value $o, Representation $rep): string
563585
{
564586
if (($plugin = $this->getPlugin(self::$tab_plugins, $rep->hints)) && $plugin instanceof TabPluginInterface) {

system/ThirdParty/Kint/Renderer/Text/AbstractPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(TextRenderer $r)
4242
$this->renderer = $r;
4343
}
4444

45-
public function renderLockedHeader(Value $o, ?string $content = null): string
45+
public function renderLockedHeader(Value $o, string $content = null): string
4646
{
4747
$out = '';
4848

system/ThirdParty/Kint/Renderer/TextRenderer.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ class TextRenderer extends AbstractRenderer
108108
*/
109109
public static $sort = self::SORT_NONE;
110110

111+
/**
112+
* Timestamp to print in footer in date() format.
113+
*
114+
* @var ?string
115+
*/
116+
public static $timestamp = null;
117+
111118
public $header_width = 80;
112119
public $indent_width = 4;
113120

@@ -300,7 +307,7 @@ public function filterParserPlugins(array $plugins): array
300307
{
301308
$return = [];
302309

303-
foreach ($plugins as $index => $plugin) {
310+
foreach ($plugins as $plugin) {
304311
foreach (self::$parser_plugin_whitelist as $whitelist) {
305312
if ($plugin instanceof $whitelist) {
306313
$return[] = $plugin;
@@ -319,8 +326,6 @@ public function ideLink(string $file, int $line): string
319326

320327
/**
321328
* @psalm-param Encoding $encoding
322-
*
323-
* @param mixed $encoding
324329
*/
325330
public function escape(string $string, $encoding = false): string
326331
{
@@ -355,6 +360,13 @@ protected function calledFrom(): string
355360
$output .= $this->call_info['callee']['function'].'()]';
356361
}
357362

363+
if (null !== self::$timestamp) {
364+
if (\strlen($output)) {
365+
$output .= ' ';
366+
}
367+
$output .= \date(self::$timestamp);
368+
}
369+
358370
return $output;
359371
}
360372

0 commit comments

Comments
 (0)