Skip to content

Commit d7edb37

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
2 parents 437314c + c5cb69e commit d7edb37

32 files changed

+208
-107
lines changed

system/Pager/PagerRenderer.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
class PagerRenderer
2626
{
2727
/**
28-
* First page number.
28+
* First page number in the set of links to be displayed.
2929
*
3030
* @var int
3131
*/
3232
protected $first;
3333

3434
/**
35-
* Last page number.
35+
* Last page number in the set of links to be displayed.
3636
*
3737
* @var int
3838
*/
@@ -85,8 +85,11 @@ class PagerRenderer
8585
*/
8686
public function __construct(array $details)
8787
{
88-
$this->first = 1;
89-
$this->last = $details['pageCount'];
88+
// `first` and `last` will be updated by `setSurroundCount()`.
89+
// You must call `setSurroundCount()` after instantiation.
90+
$this->first = 1;
91+
$this->last = $details['pageCount'];
92+
9093
$this->current = $details['currentPage'];
9194
$this->total = $details['total'];
9295
$this->uri = $details['uri'];
@@ -122,8 +125,6 @@ public function hasPrevious(): bool
122125
* page before the current page, but is the page just before the
123126
* "first" page.
124127
*
125-
* You MUST call hasPrevious() first, or this value may be invalid.
126-
*
127128
* @return string|null
128129
*/
129130
public function getPrevious()
@@ -162,8 +163,6 @@ public function hasNext(): bool
162163
* page after the current page, but is the page that follows the
163164
* "last" page.
164165
*
165-
* You MUST call hasNext() first, or this value may be invalid.
166-
*
167166
* @return string|null
168167
*/
169168
public function getNext()
@@ -260,6 +259,8 @@ public function getCurrent(): string
260259
* is represented by another array containing of the URI the link
261260
* should go to, the title (number) of the link, and a boolean
262261
* value representing whether this link is active or not.
262+
*
263+
* @return list<array{uri:string, title:int, active:bool}>
263264
*/
264265
public function links(): array
265266
{
@@ -381,7 +382,7 @@ public function getNextPage()
381382
}
382383

383384
/**
384-
* Returns the page number of the first page.
385+
* Returns the page number of the first page in the set of links to be displayed.
385386
*/
386387
public function getFirstPageNumber(): int
387388
{
@@ -397,7 +398,7 @@ public function getCurrentPageNumber(): int
397398
}
398399

399400
/**
400-
* Returns the page number of the last page.
401+
* Returns the page number of the last page in the set of links to be displayed.
401402
*/
402403
public function getLastPageNumber(): int
403404
{

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

system/ThirdParty/Kint/Utils.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ public static function normalizeAliases(array &$aliases): void
255255

256256
/**
257257
* @psalm-param Encoding $encoding
258-
*
259-
* @param mixed $encoding
260258
*/
261259
public static function truncateString(string $input, int $length = PHP_INT_MAX, string $end = '...', $encoding = false): string
262260
{

system/ThirdParty/Kint/Zval/BlobValue.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public function transplant(Value $old): void
122122

123123
/**
124124
* @psalm-param Encoding $encoding
125-
*
126-
* @param mixed $encoding
127125
*/
128126
public static function strlen(string $string, $encoding = false): int
129127
{
@@ -142,10 +140,8 @@ public static function strlen(string $string, $encoding = false): int
142140

143141
/**
144142
* @psalm-param Encoding $encoding
145-
*
146-
* @param mixed $encoding
147143
*/
148-
public static function substr(string $string, int $start, ?int $length = null, $encoding = false): string
144+
public static function substr(string $string, int $start, int $length = null, $encoding = false): string
149145
{
150146
if (\function_exists('mb_substr')) {
151147
if (false === $encoding) {

0 commit comments

Comments
 (0)