Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 30, 2023
2 parents 437314c + c5cb69e commit d7edb37
Show file tree
Hide file tree
Showing 32 changed files with 208 additions and 107 deletions.
21 changes: 11 additions & 10 deletions system/Pager/PagerRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
class PagerRenderer
{
/**
* First page number.
* First page number in the set of links to be displayed.
*
* @var int
*/
protected $first;

/**
* Last page number.
* Last page number in the set of links to be displayed.
*
* @var int
*/
Expand Down Expand Up @@ -85,8 +85,11 @@ class PagerRenderer
*/
public function __construct(array $details)
{
$this->first = 1;
$this->last = $details['pageCount'];
// `first` and `last` will be updated by `setSurroundCount()`.
// You must call `setSurroundCount()` after instantiation.
$this->first = 1;
$this->last = $details['pageCount'];

$this->current = $details['currentPage'];
$this->total = $details['total'];
$this->uri = $details['uri'];
Expand Down Expand Up @@ -122,8 +125,6 @@ public function hasPrevious(): bool
* page before the current page, but is the page just before the
* "first" page.
*
* You MUST call hasPrevious() first, or this value may be invalid.
*
* @return string|null
*/
public function getPrevious()
Expand Down Expand Up @@ -162,8 +163,6 @@ public function hasNext(): bool
* page after the current page, but is the page that follows the
* "last" page.
*
* You MUST call hasNext() first, or this value may be invalid.
*
* @return string|null
*/
public function getNext()
Expand Down Expand Up @@ -260,6 +259,8 @@ public function getCurrent(): string
* is represented by another array containing of the URI the link
* should go to, the title (number) of the link, and a boolean
* value representing whether this link is active or not.
*
* @return list<array{uri:string, title:int, active:bool}>
*/
public function links(): array
{
Expand Down Expand Up @@ -381,7 +382,7 @@ public function getNextPage()
}

/**
* Returns the page number of the first page.
* Returns the page number of the first page in the set of links to be displayed.
*/
public function getFirstPageNumber(): int
{
Expand All @@ -397,7 +398,7 @@ public function getCurrentPageNumber(): int
}

/**
* Returns the page number of the last page.
* Returns the page number of the last page in the set of links to be displayed.
*/
public function getLastPageNumber(): int
{
Expand Down
5 changes: 2 additions & 3 deletions system/ThirdParty/Kint/CallFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CallFinder
/**
* @psalm-param callable-array|callable-string $function
*
* @param mixed $function
* @psalm-return list<array{parameters: list, modifiers: list<PhpToken>}>
*
* @return array List of matching calls on the relevant line
*/
Expand Down Expand Up @@ -187,6 +187,7 @@ public static function getFunctionCalls(string $source, int $line, $function): a
$identifier[T_NAME_RELATIVE] = true;
}

/** @psalm-var list<PhpToken> */
$tokens = \token_get_all($source);
$cursor = 1;
$function_calls = [];
Expand Down Expand Up @@ -449,8 +450,6 @@ private static function realTokenIndex(array $tokens, int $index): ?int
* for `$token[0]` then "..." will incorrectly match the "." operator.
*
* @psalm-param PhpToken $token The token to check
*
* @param mixed $token
*/
private static function tokenIsOperator($token): bool
{
Expand Down
5 changes: 3 additions & 2 deletions system/ThirdParty/Kint/Kint.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Kint implements FacadeInterface
public static $aliases = [
['Kint\\Kint', 'dump'],
['Kint\\Kint', 'trace'],
['Kint\\Kint', 'dumpArray'],
['Kint\\Kint', 'dumpAll'],
];

/**
Expand Down Expand Up @@ -537,7 +537,7 @@ public static function trace()
*
* Functionally equivalent to Kint::dump(1) or Kint::dump(debug_backtrace())
*
* @param mixed ...$args
* @psalm-param array ...$args
*
* @return int|string
*/
Expand Down Expand Up @@ -599,6 +599,7 @@ public static function shortenPath(string $file): string
$match = '/';

foreach (static::$app_root_dirs as $path => $alias) {
/** @psalm-var string $path */
if (empty($path)) {
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion system/ThirdParty/Kint/Parser/BlacklistPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use Kint\Zval\InstanceValue;
use Kint\Zval\Value;
use Psr\Container\ContainerInterface;

class BlacklistPlugin extends AbstractPlugin
{
Expand All @@ -44,7 +45,7 @@ class BlacklistPlugin extends AbstractPlugin
*
* @var array
*/
public static $shallow_blacklist = ['Psr\\Container\\ContainerInterface'];
public static $shallow_blacklist = [ContainerInterface::class];

public function getTypes(): array
{
Expand Down
2 changes: 1 addition & 1 deletion system/ThirdParty/Kint/Parser/ClosurePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function parse(&$var, Value &$o, int $trigger): void
}

$p = new Representation('Parameters');
$p->contents = &$o->parameters;
$p->contents = $o->parameters;
$o->addRepresentation($p, 0);

$statics = [];
Expand Down
4 changes: 2 additions & 2 deletions system/ThirdParty/Kint/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Parser
* @param int $depth_limit Maximum depth to parse data
* @param ?string $caller Caller class name
*/
public function __construct(int $depth_limit = 0, ?string $caller = null)
public function __construct(int $depth_limit = 0, string $caller = null)
{
$this->marker = "kint\0".\random_bytes(16);

Expand All @@ -83,7 +83,7 @@ public function __construct(int $depth_limit = 0, ?string $caller = null)
/**
* Set the caller class.
*/
public function setCallerClass(?string $caller = null): void
public function setCallerClass(string $caller = null): void
{
$this->noRecurseCall();

Expand Down
2 changes: 1 addition & 1 deletion system/ThirdParty/Kint/Parser/PluginInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getTypes(): array;
public function getTriggers(): int;

/**
* @param mixed &$var
* @psalm-param mixed &$var
*/
public function parse(&$var, Value &$o, int $trigger): void;
}
6 changes: 6 additions & 0 deletions system/ThirdParty/Kint/Parser/TablePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
use Kint\Zval\Representation\Representation;
use Kint\Zval\Value;

// Note: Interaction with ArrayLimitPlugin:
// Any array limited children will be shown in tables identically to
// non-array-limited children since the table only shows that it is an array
// and it's size anyway. Because ArrayLimitPlugin halts the parse on finding
// a limit all other plugins including this one are stopped, so you cannot get
// a tabular representation of an array that is longer than the limit.
class TablePlugin extends AbstractPlugin
{
public function getTypes(): array
Expand Down
76 changes: 49 additions & 27 deletions system/ThirdParty/Kint/Renderer/RichRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class RichRenderer extends AbstractRenderer
*/
public static $sort = self::SORT_NONE;

/**
* Timestamp to print in footer in date() format.
*
* @var ?string
*/
public static $timestamp = null;

public static $needs_pre_render = true;
public static $needs_folder_render = true;

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

if (isset($this->call_info['callee']['file'])) {
$output .= 'Called from '.$this->ideLink(
$this->call_info['callee']['file'],
$this->call_info['callee']['line']
);
}

if (
isset($this->call_info['callee']['function']) &&
(
!empty($this->call_info['callee']['class']) ||
!\in_array(
$this->call_info['callee']['function'],
['include', 'include_once', 'require', 'require_once'],
true
)
)
) {
$output .= ' [';
$output .= $this->call_info['callee']['class'] ?? '';
$output .= $this->call_info['callee']['type'] ?? '';
$output .= $this->call_info['callee']['function'].'()]';
}
$output .= $this->calledFrom();

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

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

/**
* @psalm-param Encoding $encoding
*
* @param mixed $encoding
*/
public function escape(string $string, $encoding = false): string
{
Expand Down Expand Up @@ -559,6 +542,45 @@ public function ideLink(string $file, int $line): string
return '<a '.$class.'href="'.$this->escape($ideLink).'">'.$path.'</a>';
}

protected function calledFrom(): string
{
$output = '';

if (isset($this->call_info['callee']['file'])) {
$output .= ' '.$this->ideLink(
$this->call_info['callee']['file'],
$this->call_info['callee']['line']
);
}

if (
isset($this->call_info['callee']['function']) &&
(
!empty($this->call_info['callee']['class']) ||
!\in_array(
$this->call_info['callee']['function'],
['include', 'include_once', 'require', 'require_once'],
true
)
)
) {
$output .= ' [';
$output .= $this->call_info['callee']['class'] ?? '';
$output .= $this->call_info['callee']['type'] ?? '';
$output .= $this->call_info['callee']['function'].'()]';
}

if ('' !== $output) {
$output = 'Called from'.$output;
}

if (null !== self::$timestamp) {
$output .= ' '.\date(self::$timestamp);
}

return $output;
}

protected function renderTab(Value $o, Representation $rep): string
{
if (($plugin = $this->getPlugin(self::$tab_plugins, $rep->hints)) && $plugin instanceof TabPluginInterface) {
Expand Down
2 changes: 1 addition & 1 deletion system/ThirdParty/Kint/Renderer/Text/AbstractPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(TextRenderer $r)
$this->renderer = $r;
}

public function renderLockedHeader(Value $o, ?string $content = null): string
public function renderLockedHeader(Value $o, string $content = null): string
{
$out = '';

Expand Down
18 changes: 15 additions & 3 deletions system/ThirdParty/Kint/Renderer/TextRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ class TextRenderer extends AbstractRenderer
*/
public static $sort = self::SORT_NONE;

/**
* Timestamp to print in footer in date() format.
*
* @var ?string
*/
public static $timestamp = null;

public $header_width = 80;
public $indent_width = 4;

Expand Down Expand Up @@ -300,7 +307,7 @@ public function filterParserPlugins(array $plugins): array
{
$return = [];

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

/**
* @psalm-param Encoding $encoding
*
* @param mixed $encoding
*/
public function escape(string $string, $encoding = false): string
{
Expand Down Expand Up @@ -355,6 +360,13 @@ protected function calledFrom(): string
$output .= $this->call_info['callee']['function'].'()]';
}

if (null !== self::$timestamp) {
if (\strlen($output)) {
$output .= ' ';
}
$output .= \date(self::$timestamp);
}

return $output;
}

Expand Down
2 changes: 0 additions & 2 deletions system/ThirdParty/Kint/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ public static function normalizeAliases(array &$aliases): void

/**
* @psalm-param Encoding $encoding
*
* @param mixed $encoding
*/
public static function truncateString(string $input, int $length = PHP_INT_MAX, string $end = '...', $encoding = false): string
{
Expand Down
6 changes: 1 addition & 5 deletions system/ThirdParty/Kint/Zval/BlobValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public function transplant(Value $old): void

/**
* @psalm-param Encoding $encoding
*
* @param mixed $encoding
*/
public static function strlen(string $string, $encoding = false): int
{
Expand All @@ -142,10 +140,8 @@ public static function strlen(string $string, $encoding = false): int

/**
* @psalm-param Encoding $encoding
*
* @param mixed $encoding
*/
public static function substr(string $string, int $start, ?int $length = null, $encoding = false): string
public static function substr(string $string, int $start, int $length = null, $encoding = false): string
{
if (\function_exists('mb_substr')) {
if (false === $encoding) {
Expand Down
Loading

0 comments on commit d7edb37

Please sign in to comment.