first commit

This commit is contained in:
CHIEFSOFT\ameye
2025-11-22 09:54:51 -05:00
commit 07a07ab49f
722 changed files with 125787 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Renderer\RichRenderer;
use Kint\Value\AbstractValue;
use Kint\Value\Context\ClassDeclaredContext;
use Kint\Value\Context\PropertyContext;
use Kint\Value\InstanceValue;
abstract class AbstractPlugin implements PluginInterface
{
protected RichRenderer $renderer;
public function __construct(RichRenderer $r)
{
$this->renderer = $r;
}
/**
* @param string $content The replacement for the getValueShort contents
*/
public function renderLockedHeader(AbstractValue $v, string $content): string
{
$header = '<dt class="kint-parent kint-locked">';
$c = $v->getContext();
if (RichRenderer::$access_paths && $c->getDepth() > 0 && null !== ($ap = $c->getAccessPath())) {
$header .= '<span class="kint-access-path-trigger" title="Show access path">&rlarr;</span>';
}
$header .= '<nav></nav>';
if ($c instanceof ClassDeclaredContext) {
$header .= '<var>'.$c->getModifiers().'</var> ';
}
$header .= '<dfn>'.$this->renderer->escape($v->getDisplayName()).'</dfn> ';
if ($c instanceof PropertyContext && null !== ($s = $c->getHooks())) {
$header .= '<var>'.$this->renderer->escape($s).'</var> ';
}
if (null !== ($s = $c->getOperator())) {
$header .= $this->renderer->escape($s, 'ASCII').' ';
}
$s = $v->getDisplayType();
if (RichRenderer::$escape_types) {
$s = $this->renderer->escape($s);
}
if ($c->isRef()) {
$s = '&amp;'.$s;
}
$header .= '<var>'.$s.'</var>';
if ($v instanceof InstanceValue && $this->renderer->shouldRenderObjectIds()) {
$header .= '#'.$v->getSplObjectId();
}
$header .= ' ';
if (null !== ($s = $v->getDisplaySize())) {
if (RichRenderer::$escape_types) {
$s = $this->renderer->escape($s);
}
$header .= '('.$s.') ';
}
$header .= $content;
if (!empty($ap)) {
$header .= '<div class="access-path">'.$this->renderer->escape($ap).'</div>';
}
return $header.'</dt>';
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\BinaryRepresentation;
use Kint\Value\Representation\RepresentationInterface;
class BinaryPlugin extends AbstractPlugin implements TabPluginInterface
{
/** @psalm-var positive-int */
public static int $line_length = 0x10;
/** @psalm-var positive-int */
public static int $chunk_length = 0x2;
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof BinaryRepresentation) {
return null;
}
$out = '<pre>';
$lines = \str_split($r->getValue(), self::$line_length);
foreach ($lines as $index => $line) {
$out .= \sprintf('%08X', $index * self::$line_length).":\t";
$chunks = \str_split(\str_pad(\bin2hex($line), 2 * self::$line_length, ' '), 2 * self::$chunk_length);
$out .= \implode(' ', $chunks);
$out .= "\t".\preg_replace('/[^\\x20-\\x7E]/', '.', $line)."\n";
}
$out .= '</pre>';
return $out;
}
}
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Utils;
use Kint\Value\AbstractValue;
use Kint\Value\MethodValue;
use Kint\Value\Representation\CallableDefinitionRepresentation;
use Kint\Value\Representation\RepresentationInterface;
class CallableDefinitionPlugin extends AbstractPlugin implements TabPluginInterface
{
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof CallableDefinitionRepresentation) {
return null;
}
$docstring = [];
if ($v instanceof MethodValue) {
$c = $v->getContext();
if ($c->inherited) {
$docstring[] = 'Inherited from '.$this->renderer->escape($c->owner_class);
}
}
$docstring[] = 'Defined in '.$this->renderer->escape(Utils::shortenPath($r->getFileName())).':'.$r->getLine();
$docstring = '<small>'.\implode("\n", $docstring).'</small>';
if (null !== ($trimmed = $r->getDocstringTrimmed())) {
$docstring = $this->renderer->escape($trimmed)."\n\n".$docstring;
}
return '<pre>'.$docstring.'</pre>';
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Renderer\RichRenderer;
use Kint\Utils;
use Kint\Value\AbstractValue;
use Kint\Value\Context\MethodContext;
use Kint\Value\MethodValue;
class CallablePlugin extends AbstractPlugin implements ValuePluginInterface
{
protected static array $method_cache = [];
public function renderValue(AbstractValue $v): ?string
{
if (!$v instanceof MethodValue) {
return null;
}
$c = $v->getContext();
if (!$c instanceof MethodContext) {
return null;
}
if (!isset(self::$method_cache[$c->owner_class][$c->name])) {
$children = $this->renderer->renderChildren($v);
$header = '<var>'.$c->getModifiers();
if ($v->getCallableBag()->return_reference) {
$header .= ' &amp;';
}
$header .= '</var> ';
$function = $this->renderer->escape($v->getDisplayName());
if (null !== ($url = $v->getPhpDocUrl())) {
$function = '<a href="'.$url.'" target=_blank>'.$function.'</a>';
}
$header .= '<dfn>'.$function.'</dfn>';
if (null !== ($rt = $v->getCallableBag()->returntype)) {
$header .= ': <var>';
$header .= $this->renderer->escape($rt).'</var>';
} elseif (null !== ($ds = $v->getCallableBag()->docstring)) {
if (\preg_match('/@return\\s+(.*)\\r?\\n/m', $ds, $matches)) {
if (\trim($matches[1])) {
$header .= ': <var>'.$this->renderer->escape(\trim($matches[1])).'</var>';
}
}
}
if (null !== ($s = $v->getDisplayValue())) {
if (RichRenderer::$strlen_max) {
$s = Utils::truncateString($s, RichRenderer::$strlen_max);
}
$header .= ' '.$this->renderer->escape($s);
}
self::$method_cache[$c->owner_class][$c->name] = [
'header' => $header,
'children' => $children,
];
}
$children = self::$method_cache[$c->owner_class][$c->name]['children'];
$header = $this->renderer->renderHeaderWrapper(
$c,
(bool) \strlen($children),
self::$method_cache[$c->owner_class][$c->name]['header']
);
return '<dl>'.$header.$children.'</dl>';
}
}
+102
View File
@@ -0,0 +1,102 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\ColorRepresentation;
use Kint\Value\Representation\RepresentationInterface;
class ColorPlugin extends AbstractPlugin implements TabPluginInterface, ValuePluginInterface
{
public function renderValue(AbstractValue $v): ?string
{
$r = $v->getRepresentation('color');
if (!$r instanceof ColorRepresentation) {
return null;
}
$children = $this->renderer->renderChildren($v);
$header = $this->renderer->renderHeader($v);
$header .= '<div class="kint-color-preview"><div style="background:';
$header .= $r->getColor(ColorRepresentation::COLOR_RGBA);
$header .= '"></div></div>';
$header = $this->renderer->renderHeaderWrapper($v->getContext(), (bool) \strlen($children), $header);
return '<dl>'.$header.$children.'</dl>';
}
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof ColorRepresentation) {
return null;
}
$out = '';
if ($color = $r->getColor(ColorRepresentation::COLOR_NAME)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_HEX_3)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_HEX_6)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($r->hasAlpha()) {
if ($color = $r->getColor(ColorRepresentation::COLOR_HEX_4)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_HEX_8)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_RGBA)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_HSLA)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
} else {
if ($color = $r->getColor(ColorRepresentation::COLOR_RGB)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
if ($color = $r->getColor(ColorRepresentation::COLOR_HSL)) {
$out .= '<dfn>'.$color."</dfn>\n";
}
}
if (!\strlen($out)) {
return null;
}
return '<pre>'.$out.'</pre>';
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
class LockPlugin extends AbstractPlugin implements ValuePluginInterface
{
public function renderValue(AbstractValue $v): ?string
{
switch ($v->getHint()) {
case 'blacklist':
return '<dl>'.$this->renderLockedHeader($v, '<var>Blacklisted</var>').'</dl>';
case 'recursion':
return '<dl>'.$this->renderLockedHeader($v, '<var>Recursion</var>').'</dl>';
case 'depth_limit':
return '<dl>'.$this->renderLockedHeader($v, '<var>Depth Limit</var>').'</dl>';
case 'array_limit':
return '<dl>'.$this->renderLockedHeader($v, '<var>Array Limit</var>').'</dl>';
}
return null;
}
}
@@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Utils;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\MicrotimeRepresentation;
use Kint\Value\Representation\RepresentationInterface;
class MicrotimePlugin extends AbstractPlugin implements TabPluginInterface
{
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof MicrotimeRepresentation || !($dt = $r->getDateTime())) {
return null;
}
$out = $dt->format('Y-m-d H:i:s.u');
if (null !== ($lap = $r->getLapTime())) {
$out .= '<br><b>SINCE LAST CALL:</b> <span class="kint-microtime-lap">'.\round($lap, 4).'</span>s.';
}
if (null !== ($total = $r->getTotalTime())) {
$out .= '<br><b>SINCE START:</b> '.\round($total, 4).'s.';
}
if (null !== ($avg = $r->getAverageTime())) {
$out .= '<br><b>AVERAGE DURATION:</b> <span class="kint-microtime-avg">'.\round($avg, 4).'</span>s.';
}
$bytes = Utils::getHumanReadableBytes($r->getMemoryUsage());
$out .= '<br><b>MEMORY USAGE:</b> '.$r->getMemoryUsage().' bytes ('.\round($bytes['value'], 3).' '.$bytes['unit'].')';
$bytes = Utils::getHumanReadableBytes($r->getMemoryUsageReal());
$out .= ' (real '.\round($bytes['value'], 3).' '.$bytes['unit'].')';
$bytes = Utils::getHumanReadableBytes($r->getMemoryPeakUsage());
$out .= '<br><b>PEAK MEMORY USAGE:</b> '.$r->getMemoryPeakUsage().' bytes ('.\round($bytes['value'], 3).' '.$bytes['unit'].')';
$bytes = Utils::getHumanReadableBytes($r->getMemoryPeakUsageReal());
$out .= ' (real '.\round($bytes['value'], 3).' '.$bytes['unit'].')';
return '<pre data-kint-microtime-group="'.$r->getGroup().'">'.$out.'</pre>';
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Renderer\RichRenderer;
interface PluginInterface
{
public function __construct(RichRenderer $r);
}
+56
View File
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\ProfileRepresentation;
use Kint\Value\Representation\RepresentationInterface;
class ProfilePlugin extends AbstractPlugin implements TabPluginInterface
{
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof ProfileRepresentation) {
return null;
}
$out = '<pre>';
$out .= 'Complexity: '.$r->complexity.PHP_EOL;
if (isset($r->instance_counts)) {
$out .= 'Instance repetitions: '.\var_export($r->instance_counts, true).PHP_EOL;
}
if (isset($r->instance_complexity)) {
$out .= 'Instance complexity: '.\var_export($r->instance_complexity, true).PHP_EOL;
}
$out .= '</pre>';
return $out;
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\RepresentationInterface;
use Kint\Value\Representation\SourceRepresentation;
class SourcePlugin extends AbstractPlugin implements TabPluginInterface
{
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof SourceRepresentation) {
return null;
}
$source = $r->getSourceLines();
// Trim empty lines from the start and end of the source
foreach ($source as $linenum => $line) {
if (\strlen(\trim($line)) || $linenum === $r->getLine()) {
break;
}
unset($source[$linenum]);
}
foreach (\array_reverse($source, true) as $linenum => $line) {
if (\strlen(\trim($line)) || $linenum === $r->getLine()) {
break;
}
unset($source[$linenum]);
}
$output = '';
foreach ($source as $linenum => $line) {
if ($linenum === $r->getLine()) {
$output .= '<div class="kint-highlight">'.$this->renderer->escape($line)."\n".'</div>';
} else {
$output .= '<div>'.$this->renderer->escape($line)."\n".'</div>';
}
}
if ($output) {
$data = '';
if ($r->showFileName()) {
$data = ' data-kint-filename="'.$this->renderer->escape($r->getFileName()).'"';
}
return '<div><pre class="kint-source"'.$data.' style="counter-reset: kint-l '.((int) \array_key_first($source) - 1).';">'.$output.'</pre></div><div></div>';
}
return null;
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\Representation\RepresentationInterface;
interface TabPluginInterface extends PluginInterface
{
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string;
}
+132
View File
@@ -0,0 +1,132 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Renderer\RichRenderer;
use Kint\Utils;
use Kint\Value\AbstractValue;
use Kint\Value\ArrayValue;
use Kint\Value\FixedWidthValue;
use Kint\Value\Representation\RepresentationInterface;
use Kint\Value\Representation\TableRepresentation;
use Kint\Value\StringValue;
class TablePlugin extends AbstractPlugin implements TabPluginInterface
{
public static bool $respect_str_length = true;
public function renderTab(RepresentationInterface $r, AbstractValue $v): ?string
{
if (!$r instanceof TableRepresentation) {
return null;
}
$contents = $r->getContents();
$firstrow = \reset($contents);
if (!$firstrow instanceof ArrayValue) {
return null;
}
$out = '<pre><table><thead><tr><th></th>';
foreach ($firstrow->getContents() as $field) {
$out .= '<th>'.$this->renderer->escape($field->getDisplayName()).'</th>';
}
$out .= '</tr></thead><tbody>';
foreach ($contents as $row) {
if (!$row instanceof ArrayValue) {
return null;
}
$out .= '<tr><th>'.$this->renderer->escape($row->getDisplayName()).'</th>';
foreach ($row->getContents() as $field) {
$ref = $field->getContext()->isRef() ? '&amp;' : '';
$type = $this->renderer->escape($field->getDisplayType());
$out .= '<td title="'.$ref.$type;
if (null !== ($size = $field->getDisplaySize())) {
$size = $this->renderer->escape($size);
$out .= ' ('.$size.')';
}
$out .= '">';
if ($field instanceof FixedWidthValue) {
if (null === ($dv = $field->getDisplayValue())) {
$out .= '<var>'.$ref.'null</var>';
} elseif ('boolean' === $field->getType()) {
$out .= '<var>'.$ref.$dv.'</var>';
} else {
$out .= $dv;
}
} elseif ($field instanceof StringValue) {
if (false !== $field->getEncoding()) {
$val = $field->getValueUtf8();
if (RichRenderer::$strlen_max && self::$respect_str_length) {
$val = Utils::truncateString($val, RichRenderer::$strlen_max, 'UTF-8');
}
$out .= $this->renderer->escape($val);
} else {
$out .= '<var>'.$ref.$type.'</var>';
}
} elseif ($field instanceof ArrayValue) {
$out .= '<var>'.$ref.'array</var> ('.$field->getSize().')';
} else {
$out .= '<var>'.$ref.$type.'</var>';
if (null !== $size) {
$out .= ' ('.$size.')';
}
}
if ($field->flags & AbstractValue::FLAG_BLACKLIST) {
$out .= ' <var>Blacklisted</var>';
} elseif ($field->flags & AbstractValue::FLAG_RECURSION) {
$out .= ' <var>Recursion</var>';
} elseif ($field->flags & AbstractValue::FLAG_DEPTH_LIMIT) {
$out .= ' <var>Depth Limit</var>';
}
$out .= '</td>';
}
$out .= '</tr>';
}
$out .= '</tbody></table></pre>';
return $out;
}
}
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
use Kint\Value\MethodValue;
use Kint\Value\TraceFrameValue;
class TraceFramePlugin extends AbstractPlugin implements ValuePluginInterface
{
public function renderValue(AbstractValue $v): ?string
{
if (!$v instanceof TraceFrameValue) {
return null;
}
if (null !== ($file = $v->getFile()) && null !== ($line = $v->getLine())) {
$header = '<var>'.$this->renderer->ideLink($file, $line).'</var> ';
} else {
$header = '<var>PHP internal call</var> ';
}
if ($callable = $v->getCallable()) {
if ($callable instanceof MethodValue) {
$function = $callable->getFullyQualifiedDisplayName();
} else {
$function = $callable->getDisplayName();
}
$function = $this->renderer->escape($function);
if (null !== ($url = $callable->getPhpDocUrl())) {
$function = '<a href="'.$url.'" target=_blank>'.$function.'</a>';
}
$header .= $function;
}
$children = $this->renderer->renderChildren($v);
$header = $this->renderer->renderHeaderWrapper($v->getContext(), (bool) \strlen($children), $header);
return '<dl>'.$header.$children.'</dl>';
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* 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\Rich;
use Kint\Value\AbstractValue;
interface ValuePluginInterface extends PluginInterface
{
public function renderValue(AbstractValue $v): ?string;
}