Skip to content

Commit 6a31be4

Browse files
authored
Merge pull request #6436 from kenjis/update-kint-to-420
chore: update Kint to 4.2.0
2 parents a65e57a + 596b629 commit 6a31be4

File tree

10 files changed

+205
-4
lines changed

10 files changed

+205
-4
lines changed

admin/framework/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ext-intl": "*",
1111
"ext-json": "*",
1212
"ext-mbstring": "*",
13-
"kint-php/kint": "^4.1.1",
13+
"kint-php/kint": "^4.2",
1414
"laminas/laminas-escaper": "^2.9",
1515
"psr/log": "^1.1"
1616
},

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ext-intl": "*",
1111
"ext-json": "*",
1212
"ext-mbstring": "*",
13-
"kint-php/kint": "^4.1.1",
13+
"kint-php/kint": "^4.2",
1414
"laminas/laminas-escaper": "^2.9",
1515
"psr/log": "^1.1"
1616
},

system/ThirdParty/Kint/Kint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class Kint
150150
'Kint\\Parser\\ClosurePlugin',
151151
'Kint\\Parser\\ColorPlugin',
152152
'Kint\\Parser\\DateTimePlugin',
153+
'Kint\\Parser\\EnumPlugin',
153154
'Kint\\Parser\\FsPathPlugin',
154155
'Kint\\Parser\\IteratorPlugin',
155156
'Kint\\Parser\\JsonPlugin',

system/ThirdParty/Kint/Parser/ClassStaticsPlugin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Kint\Zval\Value;
3131
use ReflectionClass;
3232
use ReflectionProperty;
33+
use UnitEnum;
3334

3435
class ClassStaticsPlugin extends Plugin
3536
{
@@ -56,6 +57,11 @@ public function parse(&$var, Value &$o, $trigger)
5657
$consts = [];
5758

5859
foreach ($reflection->getConstants() as $name => $val) {
60+
// Skip enum constants
61+
if ($var instanceof UnitEnum && $val instanceof UnitEnum && $o->classname == \get_class($val)) {
62+
continue;
63+
}
64+
5965
$const = Value::blank($name, '\\'.$class.'::'.$name);
6066
$const->const = true;
6167
$const->depth = $o->depth + 1;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
/*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2013 Jonathan Vollebregt ([email protected]), Rokas Šleinius ([email protected])
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12+
* the Software, and to permit persons to whom the Software is furnished to do so,
13+
* subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
26+
namespace Kint\Parser;
27+
28+
use BackedEnum;
29+
use Kint\Zval\EnumValue;
30+
use Kint\Zval\Representation\Representation;
31+
use Kint\Zval\Value;
32+
use UnitEnum;
33+
34+
class EnumPlugin extends Plugin
35+
{
36+
private static $cache = [];
37+
38+
public function getTypes()
39+
{
40+
return ['object'];
41+
}
42+
43+
public function getTriggers()
44+
{
45+
if (!KINT_PHP81) {
46+
return Parser::TRIGGER_NONE;
47+
}
48+
49+
return Parser::TRIGGER_SUCCESS;
50+
}
51+
52+
public function parse(&$var, Value &$o, $trigger)
53+
{
54+
if (!$var instanceof UnitEnum) {
55+
return;
56+
}
57+
58+
$class = \get_class($var);
59+
60+
if (!isset(self::$cache[$class])) {
61+
$cases = new Representation('Enum values', 'enum');
62+
$cases->contents = [];
63+
64+
foreach ($var->cases() as $case) {
65+
$base_obj = Value::blank($class.'::'.$case->name, '\\'.$class.'::'.$case->name);
66+
$base_obj->depth = $o->depth + 1;
67+
68+
if ($var instanceof BackedEnum) {
69+
$c = $case->value;
70+
$cases->contents[] = $this->parser->parse($c, $base_obj);
71+
} else {
72+
$cases->contents[] = $base_obj;
73+
}
74+
}
75+
76+
self::$cache[$class] = $cases;
77+
}
78+
79+
$object = new EnumValue($var);
80+
$object->transplant($o);
81+
82+
$object->addRepresentation(self::$cache[$class], 0);
83+
84+
$o = $object;
85+
}
86+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2013 Jonathan Vollebregt ([email protected]), Rokas Šleinius ([email protected])
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12+
* the Software, and to permit persons to whom the Software is furnished to do so,
13+
* subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
26+
namespace Kint\Renderer\Text;
27+
28+
use Kint\Zval\Value;
29+
30+
class EnumPlugin extends Plugin
31+
{
32+
public function render(Value $o)
33+
{
34+
$out = '';
35+
36+
if (0 == $o->depth) {
37+
$out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL;
38+
}
39+
40+
$out .= $this->renderer->renderHeader($o).PHP_EOL;
41+
42+
return $out;
43+
}
44+
}

system/ThirdParty/Kint/Renderer/TextRenderer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TextRenderer extends Renderer
4242
'microtime' => 'Kint\\Renderer\\Text\\MicrotimePlugin',
4343
'recursion' => 'Kint\\Renderer\\Text\\RecursionPlugin',
4444
'trace' => 'Kint\\Renderer\\Text\\TracePlugin',
45+
'enum' => 'Kint\\Renderer\\Text\\EnumPlugin',
4546
];
4647

4748
/**
@@ -55,6 +56,7 @@ class TextRenderer extends Renderer
5556
'Kint\\Parser\\MicrotimePlugin',
5657
'Kint\\Parser\\StreamPlugin',
5758
'Kint\\Parser\\TracePlugin',
59+
'Kint\\Parser\\EnumPlugin',
5860
];
5961

6062
/**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2013 Jonathan Vollebregt ([email protected]), Rokas Šleinius ([email protected])
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
* this software and associated documentation files (the "Software"), to deal in
10+
* the Software without restriction, including without limitation the rights to
11+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12+
* the Software, and to permit persons to whom the Software is furnished to do so,
13+
* subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
26+
namespace Kint\Zval;
27+
28+
use BackedEnum;
29+
use UnitEnum;
30+
31+
class EnumValue extends InstanceValue
32+
{
33+
public $enumval;
34+
35+
public $hints = ['object', 'enum'];
36+
37+
public function __construct(UnitEnum $enumval)
38+
{
39+
$this->enumval = $enumval;
40+
}
41+
42+
public function getValueShort()
43+
{
44+
if ($this->enumval instanceof BackedEnum) {
45+
if (\is_string($this->enumval->value)) {
46+
return '"'.$this->enumval->value.'"';
47+
}
48+
if (\is_int($this->enumval->value)) {
49+
return (string) $this->enumval->value;
50+
}
51+
}
52+
}
53+
54+
public function getType()
55+
{
56+
return $this->classname.'::'.$this->enumval->name;
57+
}
58+
59+
public function getSize()
60+
{
61+
}
62+
}

system/ThirdParty/Kint/resources/compiled/rich.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

user_guide_src/source/changelogs/v4.2.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BREAKING
1919
Enhancements
2020
************
2121

22-
none.
22+
- Kint has been updated to 4.2.0.
2323

2424
Changes
2525
*******

0 commit comments

Comments
 (0)