Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update Kint to 4.2.0 #6436

Merged
merged 3 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"kint-php/kint": "^4.1.1",
"kint-php/kint": "^4.2",
"laminas/laminas-escaper": "^2.9",
"psr/log": "^1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"kint-php/kint": "^4.1.1",
"kint-php/kint": "^4.2",
"laminas/laminas-escaper": "^2.9",
"psr/log": "^1.1"
},
Expand Down
1 change: 1 addition & 0 deletions system/ThirdParty/Kint/Kint.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Kint
'Kint\\Parser\\ClosurePlugin',
'Kint\\Parser\\ColorPlugin',
'Kint\\Parser\\DateTimePlugin',
'Kint\\Parser\\EnumPlugin',
'Kint\\Parser\\FsPathPlugin',
'Kint\\Parser\\IteratorPlugin',
'Kint\\Parser\\JsonPlugin',
Expand Down
6 changes: 6 additions & 0 deletions system/ThirdParty/Kint/Parser/ClassStaticsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Kint\Zval\Value;
use ReflectionClass;
use ReflectionProperty;
use UnitEnum;

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

foreach ($reflection->getConstants() as $name => $val) {
// Skip enum constants
if ($var instanceof UnitEnum && $val instanceof UnitEnum && $o->classname == \get_class($val)) {
continue;
}

$const = Value::blank($name, '\\'.$class.'::'.$name);
$const->const = true;
$const->depth = $o->depth + 1;
Expand Down
86 changes: 86 additions & 0 deletions system/ThirdParty/Kint/Parser/EnumPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

namespace Kint\Parser;

use BackedEnum;
use Kint\Zval\EnumValue;
use Kint\Zval\Representation\Representation;
use Kint\Zval\Value;
use UnitEnum;

class EnumPlugin extends Plugin
{
private static $cache = [];

public function getTypes()
{
return ['object'];
}

public function getTriggers()
{
if (!KINT_PHP81) {
return Parser::TRIGGER_NONE;
}

return Parser::TRIGGER_SUCCESS;
}

public function parse(&$var, Value &$o, $trigger)
{
if (!$var instanceof UnitEnum) {
return;
}

$class = \get_class($var);

if (!isset(self::$cache[$class])) {
$cases = new Representation('Enum values', 'enum');
$cases->contents = [];

foreach ($var->cases() as $case) {
$base_obj = Value::blank($class.'::'.$case->name, '\\'.$class.'::'.$case->name);
$base_obj->depth = $o->depth + 1;

if ($var instanceof BackedEnum) {
$c = $case->value;
$cases->contents[] = $this->parser->parse($c, $base_obj);
} else {
$cases->contents[] = $base_obj;
}
}

self::$cache[$class] = $cases;
}

$object = new EnumValue($var);
$object->transplant($o);

$object->addRepresentation(self::$cache[$class], 0);

$o = $object;
}
}
44 changes: 44 additions & 0 deletions system/ThirdParty/Kint/Renderer/Text/EnumPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

namespace Kint\Renderer\Text;

use Kint\Zval\Value;

class EnumPlugin extends Plugin
{
public function render(Value $o)
{
$out = '';

if (0 == $o->depth) {
$out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL;
}

$out .= $this->renderer->renderHeader($o).PHP_EOL;

return $out;
}
}
2 changes: 2 additions & 0 deletions system/ThirdParty/Kint/Renderer/TextRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TextRenderer extends Renderer
'microtime' => 'Kint\\Renderer\\Text\\MicrotimePlugin',
'recursion' => 'Kint\\Renderer\\Text\\RecursionPlugin',
'trace' => 'Kint\\Renderer\\Text\\TracePlugin',
'enum' => 'Kint\\Renderer\\Text\\EnumPlugin',
];

/**
Expand All @@ -55,6 +56,7 @@ class TextRenderer extends Renderer
'Kint\\Parser\\MicrotimePlugin',
'Kint\\Parser\\StreamPlugin',
'Kint\\Parser\\TracePlugin',
'Kint\\Parser\\EnumPlugin',
];

/**
Expand Down
62 changes: 62 additions & 0 deletions system/ThirdParty/Kint/Zval/EnumValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Jonathan Vollebregt (jnvsor@gmail.com), Rokas Šleinius (raveren@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

namespace Kint\Zval;

use BackedEnum;
use UnitEnum;

class EnumValue extends InstanceValue
{
public $enumval;

public $hints = ['object', 'enum'];

public function __construct(UnitEnum $enumval)
{
$this->enumval = $enumval;
}

public function getValueShort()
{
if ($this->enumval instanceof BackedEnum) {
if (\is_string($this->enumval->value)) {
return '"'.$this->enumval->value.'"';
}
if (\is_int($this->enumval->value)) {
return (string) $this->enumval->value;
}
}
}

public function getType()
{
return $this->classname.'::'.$this->enumval->name;
}

public function getSize()
{
}
}
2 changes: 1 addition & 1 deletion system/ThirdParty/Kint/resources/compiled/rich.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion user_guide_src/source/changelogs/v4.2.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BREAKING
Enhancements
************

none.
- Kint has been updated to 4.2.0.

Changes
*******
Expand Down