Skip to content

Commit 4d5c643

Browse files
committed
chore: bump dependencies kint-php/kint to v6.1.1 as minimum required
1 parent 84d84d3 commit 4d5c643

25 files changed

Lines changed: 181 additions & 55 deletions

‎admin/framework/composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"codeigniter/coding-standard": "^1.7",
2121
"fakerphp/faker": "^1.24",
2222
"friendsofphp/php-cs-fixer": "^3.47.1",
23-
"kint-php/kint": "^6.1",
23+
"kint-php/kint": "^6.1.1",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/cs-config": "^3.6",
2626
"phpunit/phpunit": "^10.5.16 || ^11.2",

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"boundwize/structarmed": "^0.21",
2121
"codeigniter/phpstan-codeigniter": "^2.3",
2222
"fakerphp/faker": "^1.24",
23-
"kint-php/kint": "^6.1",
23+
"kint-php/kint": "^6.1.1",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/tachycardia": "^2.0",
2626
"phpstan/extension-installer": "^1.4",

‎system/ThirdParty/Kint/CallFinder.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static function getFunctionCalls(string $source, int $line, $function): a
208208
$function_calls = [];
209209

210210
// Performance optimization preventing backwards loops
211-
/** @psalm-var array<PhpToken|null> */
211+
/** @psalm-var array<null|PhpToken> */
212212
$prev_tokens = [null, null, null];
213213

214214
if (\is_array($function)) {
@@ -522,11 +522,11 @@ public static function getFunctionCalls(string $source, int $line, $function): a
522522
'literal' => $literal,
523523
'new_without_parens' => $new_without_parens,
524524
];
525-
}
526525

527-
// Skip first-class callables
528-
if (KINT_PHP81 && 1 === \count($formatted_parameters) && '...' === \reset($formatted_parameters)['path']) {
529-
continue;
526+
// Skip callable assignment
527+
if ('...' === $path || '?' === $path) {
528+
continue 2;
529+
}
530530
}
531531

532532
// Get the modifiers

‎system/ThirdParty/Kint/Kint.php‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
* @psalm-type KintCallInfo = array{
5151
* params: ?list<CallParameter>,
5252
* modifiers: array,
53-
* callee: ?callable,
54-
* caller: ?callable,
53+
* callee: ?TraceFrame,
54+
* caller: ?TraceFrame,
5555
* trace: TraceFrame[],
5656
* }
5757
*
@@ -126,7 +126,7 @@ class Kint implements FacadeInterface
126126
];
127127

128128
/**
129-
* @psalm-var array<RendererInterface|class-string<ConstructableRendererInterface>>
129+
* @psalm-var array<class-string<ConstructableRendererInterface>|RendererInterface>
130130
*
131131
* Array of modes to renderer class names
132132
*/
@@ -138,7 +138,7 @@ class Kint implements FacadeInterface
138138
];
139139

140140
/**
141-
* @psalm-var array<PluginInterface|class-string<ConstructablePluginInterface>>
141+
* @psalm-var array<class-string<ConstructablePluginInterface>|PluginInterface>
142142
*/
143143
public static array $plugins = [
144144
\Kint\Parser\ArrayLimitPlugin::class,
@@ -433,16 +433,10 @@ public static function getCallInfo(array $aliases, array $trace, array $args): a
433433
}
434434

435435
foreach ($miniTrace as $index => $frame) {
436-
if ((0 === $index && $callee === $frame) || isset($frame['file'], $frame['line'])) {
437-
unset($frame['object'], $frame['args']);
438-
$miniTrace[$index] = $frame;
439-
} else {
440-
unset($miniTrace[$index]);
441-
}
436+
unset($frame['object'], $frame['args']);
437+
$miniTrace[$index] = $frame;
442438
}
443439

444-
$miniTrace = \array_values($miniTrace);
445-
446440
$call = static::getSingleCall($callee ?: [], $args);
447441

448442
$ret = [

‎system/ThirdParty/Kint/Parser/BlacklistPlugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function parseBegin(&$var, ContextInterface $c): ?AbstractValue
8888
*/
8989
protected function blacklistValue(&$var, ContextInterface $c): InstanceValue
9090
{
91-
$object = new InstanceValue($c, \get_class($var), \spl_object_hash($var), \spl_object_id($var));
91+
$object = new InstanceValue($c, \get_class($var), @\spl_object_hash($var), \spl_object_id($var));
9292
$object->flags |= AbstractValue::FLAG_BLACKLIST;
9393

9494
return $object;

‎system/ThirdParty/Kint/Parser/ClassStaticsPlugin.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class ClassStaticsPlugin extends AbstractPlugin implements PluginCompleteInterface
4343
{
44-
/** @psalm-var array<class-string, array<1|0, array<AbstractValue>>> */
44+
/** @psalm-var array<class-string, array<0|1, array<AbstractValue>>> */
4545
private array $cache = [];
4646

4747
public function getTypes(): array
@@ -137,7 +137,7 @@ private function buildStaticValue(ReflectionProperty $pr, int $depth): AbstractV
137137
}
138138

139139
if (KINT_PHP81 === false) {
140-
$pr->setAccessible(true);
140+
$pr->setAccessible(true); // @codeCoverageIgnore
141141
}
142142

143143
/**

‎system/ThirdParty/Kint/Parser/DomPlugin.php‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private function parseProperty(object $var, string $prop, ContextInterface $c):
274274
}
275275

276276
if (isset(self::$blacklist[$prop])) {
277-
$b = new InstanceValue($c, \get_class($value), \spl_object_hash($value), \spl_object_id($value));
277+
$b = new InstanceValue($c, \get_class($value), @\spl_object_hash($value), \spl_object_id($value));
278278
$b->flags |= AbstractValue::FLAG_GENERATED | AbstractValue::FLAG_BLACKLIST;
279279

280280
return $b;
@@ -311,7 +311,7 @@ private function parseList(object $var, ContextInterface $c): InstanceValue
311311
if ($var instanceof NodeList || $var instanceof DOMNodeList) {
312312
$v = new DomNodeListValue($c, $var);
313313
} else {
314-
$v = new InstanceValue($c, \get_class($var), \spl_object_hash($var), \spl_object_id($var));
314+
$v = new InstanceValue($c, \get_class($var), @\spl_object_hash($var), \spl_object_id($var));
315315
}
316316

317317
$parser = $this->getParser();
@@ -461,10 +461,6 @@ public static function getKnownProperties(object $var): array
461461
self::$property_cache[$classname] = [];
462462

463463
foreach ($r->getProperties() as $prop) {
464-
if ($prop->isStatic()) {
465-
continue;
466-
}
467-
468464
$declaring = $prop->getDeclaringClass()->getName();
469465
$name = $prop->name;
470466

@@ -490,16 +486,18 @@ public static function getKnownProperties(object $var): array
490486

491487
$known_properties = self::$property_cache[$classname];
492488
} else {
489+
// @codeCoverageIgnoreStart
493490
$known_properties = self::DOMNODE_PROPS;
494491
if ($var instanceof DOMElement) {
495492
$known_properties += self::DOMELEMENT_PROPS;
496493
}
497494

498495
foreach (self::DOM_VERSIONS as $key => $val) {
499496
if (false === $val) {
500-
unset($known_properties[$key]); // @codeCoverageIgnore
497+
unset($known_properties[$key]);
501498
}
502499
}
500+
// @codeCoverageIgnoreEnd
503501
}
504502

505503
/** @psalm-var non-empty-array $known_properties */

‎system/ThirdParty/Kint/Parser/FsPathPlugin.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Kint\Value\Representation\SplFileInfoRepresentation;
3232
use SplFileInfo;
3333
use TypeError;
34+
use ValueError;
3435

3536
class FsPathPlugin extends AbstractPlugin implements PluginCompleteInterface
3637
{
@@ -64,8 +65,8 @@ public function parseComplete(&$var, AbstractValue $v, int $trigger): AbstractVa
6465
if (!@\file_exists($var)) {
6566
return $v;
6667
}
67-
} catch (TypeError $e) {// @codeCoverageIgnore
68-
// Only possible in PHP 7
68+
} catch (TypeError|ValueError $e) {// @codeCoverageIgnore
69+
// TypeError only possible in PHP 7, ValueError from 8.6+
6970
return $v; // @codeCoverageIgnore
7071
}
7172

‎system/ThirdParty/Kint/Parser/Parser.php‎

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
use Kint\Value\ArrayValue;
3535
use Kint\Value\ClosedResourceValue;
3636
use Kint\Value\Context\ArrayContext;
37+
use Kint\Value\Context\BaseContext;
3738
use Kint\Value\Context\ClassDeclaredContext;
3839
use Kint\Value\Context\ClassOwnedContext;
3940
use Kint\Value\Context\ContextInterface;
4041
use Kint\Value\Context\PropertyContext;
4142
use Kint\Value\FixedWidthValue;
4243
use Kint\Value\InstanceValue;
44+
use Kint\Value\LazyInstanceValue;
45+
use Kint\Value\ProxyInstanceValue;
4346
use Kint\Value\Representation\ContainerRepresentation;
4447
use Kint\Value\Representation\StringRepresentation;
4548
use Kint\Value\ResourceValue;
@@ -77,6 +80,7 @@ class Parser
7780
public const TRIGGER_SUCCESS = 1 << 1;
7881
public const TRIGGER_RECURSION = 1 << 2;
7982
public const TRIGGER_DEPTH_LIMIT = 1 << 3;
83+
public const TRIGGER_LAZY = 1 << 4;
8084
public const TRIGGER_COMPLETE = self::TRIGGER_SUCCESS | self::TRIGGER_RECURSION | self::TRIGGER_DEPTH_LIMIT;
8185

8286
/** @psalm-var ?class-string */
@@ -368,7 +372,7 @@ private function getPropsOrderedOld(ReflectionClass $r): array
368372

369373
private function parseObject(object &$var, ContextInterface $c): AbstractValue
370374
{
371-
$hash = \spl_object_hash($var);
375+
$hash = @\spl_object_hash($var);
372376
$classname = \get_class($var);
373377

374378
if (isset($this->object_hashes[$hash])) {
@@ -383,26 +387,44 @@ private function parseObject(object &$var, ContextInterface $c): AbstractValue
383387

384388
$cdepth = $c->getDepth();
385389
$ap = $c->getAccessPath();
390+
$robj = new ReflectionObject($var);
391+
392+
if (KINT_PHP84 && $robj->isUninitializedLazyObject($var)) {
393+
// Since getProperties on ReflectionObject also gets dynamic
394+
// properties we have to use a ReflectionClass so as not to
395+
// accidentally initialize lazy objects
396+
$robj = new ReflectionClass($var);
397+
$object = new LazyInstanceValue($c, $classname, $hash, \spl_object_id($var));
398+
} elseif (KINT_PHP84 && ($innerVar = $robj->initializeLazyObject($var)) !== $var) {
399+
$innerContext = new BaseContext('instance');
400+
$innerContext->access_path = $ap;
401+
$innerContext->depth = $cdepth + 1;
402+
$inner = $this->parse($innerVar, $innerContext);
403+
$innerContext->access_path = null;
404+
405+
return new ProxyInstanceValue($c, $inner, $classname, $hash, \spl_object_id($var));
406+
} else {
407+
$object = new InstanceValue($c, $classname, $hash, \spl_object_id($var));
408+
}
386409

387410
if ($this->depth_limit && $cdepth >= $this->depth_limit) {
388-
$object = new InstanceValue($c, $classname, $hash, \spl_object_id($var));
389411
$object->flags |= AbstractValue::FLAG_DEPTH_LIMIT;
390412

391413
return $this->applyPluginsComplete($var, $object, self::TRIGGER_DEPTH_LIMIT);
392414
}
393415

394416
if (KINT_PHP81) {
395-
$props = $this->getPropsOrdered(new ReflectionObject($var));
417+
$props = $this->getPropsOrdered($robj);
396418
} else {
397-
$props = $this->getPropsOrderedOld(new ReflectionObject($var)); // @codeCoverageIgnore
419+
$props = $this->getPropsOrderedOld($robj); // @codeCoverageIgnore
398420
}
399421

400422
$values = (array) $var;
401423
$properties = [];
402424

403425
foreach ($props as $rprop) {
404426
if (KINT_PHP81 === false) {
405-
$rprop->setAccessible(true);
427+
$rprop->setAccessible(true); // @codeCoverageIgnore
406428
}
407429

408430
$name = $rprop->getName();
@@ -503,7 +525,6 @@ private function parseObject(object &$var, ContextInterface $c): AbstractValue
503525
}
504526
}
505527

506-
$object = new InstanceValue($c, $classname, $hash, \spl_object_id($var));
507528
if ($props) {
508529
$object->setChildren($properties);
509530
}
@@ -512,7 +533,11 @@ private function parseObject(object &$var, ContextInterface $c): AbstractValue
512533
$object->addRepresentation(new ContainerRepresentation('Properties', $properties));
513534
}
514535

515-
return $this->applyPluginsComplete($var, $object, self::TRIGGER_SUCCESS);
536+
return $this->applyPluginsComplete(
537+
$var,
538+
$object,
539+
$object instanceof LazyInstanceValue ? self::TRIGGER_LAZY : self::TRIGGER_SUCCESS,
540+
);
516541
} finally {
517542
unset($this->object_hashes[$hash]);
518543
}

‎system/ThirdParty/Kint/Parser/ProfilePlugin.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getTypes(): array
5151

5252
public function getTriggers(): int
5353
{
54-
return Parser::TRIGGER_BEGIN | Parser::TRIGGER_COMPLETE;
54+
return Parser::TRIGGER_BEGIN | Parser::TRIGGER_COMPLETE | Parser::TRIGGER_LAZY;
5555
}
5656

5757
public function parseBegin(&$var, ContextInterface $c): ?AbstractValue
@@ -65,7 +65,7 @@ public function parseBegin(&$var, ContextInterface $c): ?AbstractValue
6565
}
6666

6767
if (\is_object($var)) {
68-
$hash = \spl_object_hash($var);
68+
$hash = @\spl_object_hash($var);
6969
$this->instance_counts[$hash] ??= 0;
7070
$this->instance_complexity[$hash] ??= 0;
7171
$this->instance_count_stack[$hash] ??= 0;

0 commit comments

Comments
 (0)