Skip to content

Commit

Permalink
FQCN rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Aug 18, 2024
1 parent b9bd6d3 commit 81c0e84
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 129 deletions.
6 changes: 3 additions & 3 deletions src/Kint.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ class Kint implements FacadeInterface
* @var array Kint aliases. Add debug functions in Kint wrappers here to fix modifiers and backtraces
*/
public static array $aliases = [
['Kint\\Kint', 'dump'],
['Kint\\Kint', 'trace'],
['Kint\\Kint', 'dumpAll'],
[self::class, 'dump'],
[self::class, 'trace'],
[self::class, 'dumpAll'],
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/ClassMethodsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function parse(&$var, Value &$o, int $trigger): void
* @psalm-suppress InvalidArgument
* Appears to have been fixed in master
*/
\usort($methods, ['Kint\\Parser\\ClassMethodsPlugin', 'sort']);
\usort($methods, [self::class, 'sort']);

self::$cache[$class] = $methods;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Parser/ToStringPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
use Kint\Zval\Representation\Representation;
use Kint\Zval\Value;
use ReflectionClass;
use SimpleXMLElement;
use SplFileObject;

class ToStringPlugin extends AbstractPlugin
{
public static array $blacklist = [
'SimpleXMLElement',
'SplFileObject',
SimpleXMLElement::class,
SplFileObject::class,
];

public function getTypes(): array
Expand Down
4 changes: 2 additions & 2 deletions src/Parser/XmlPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function parse(&$var, Value &$o, int $trigger): void
return;
}

if (!\method_exists(\get_class($this), 'xmlTo'.self::$parse_method)) {
if (!\method_exists(self::class, 'xmlTo'.self::$parse_method)) {
return;
}

$xml = \call_user_func([\get_class($this), 'xmlTo'.self::$parse_method], $var, $o->access_path);
$xml = \call_user_func([self::class, 'xmlTo'.self::$parse_method], $var, $o->access_path);

if (empty($xml)) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/Renderer/PlainRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class PlainRenderer extends TextRenderer
{
public static array $pre_render_sources = [
'script' => [
['Kint\\Renderer\\PlainRenderer', 'renderJs'],
['Kint\\Renderer\\Text\\MicrotimePlugin', 'renderJs'],
[self::class, 'renderJs'],
[Text\MicrotimePlugin::class, 'renderJs'],
],
'style' => [
['Kint\\Renderer\\PlainRenderer', 'renderCss'],
[self::class, 'renderCss'],
],
'raw' => [],
];
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public function testToplevelTracedumpNoCallerMatch()
$bt = \debug_backtrace();

$d2 = Kint::trace();
Kint::$aliases = [['Kint\\Kint', 'dump']];
Kint::$aliases = [[Kint::class, 'dump']];
$d1 = \preg_replace('/^\\$bt\\b/', 'Kint\\Kint::trace()', Kint::dump($bt));

$this->assertSame($d1, $d2);
Expand Down
51 changes: 26 additions & 25 deletions tests/KintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace Kint\Test;

use InvalidArgumentException;
use Kint\Kint;
use Kint\Parser\ConstructablePluginInterface;
use Kint\Parser\Parser;
Expand Down Expand Up @@ -149,7 +150,7 @@ public function testSetStatesFromStatics()
*/
public function testSetStatesFromStaticsStringPlugins()
{
$r = new ReflectionProperty('Kint\\Kint', 'plugin_pool');
$r = new ReflectionProperty(Kint::class, 'plugin_pool');
$r->setAccessible(true);
$r->setValue([]);

Expand All @@ -159,8 +160,8 @@ public function testSetStatesFromStaticsStringPlugins()

$statics = [
'plugins' => [
'Kint\\Parser\\TimestampPlugin',
'Kint\\Parser\\MicrotimePlugin',
TimestampPlugin::class,
\Kint\Parser\MicrotimePlugin::class,
],
];

Expand Down Expand Up @@ -310,7 +311,7 @@ public function testDumpNothing()
*/
public function testDumpAllUnmatchingArgs()
{
$this->expectException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);

$p = new Parser();
$r = new TextRenderer();
Expand All @@ -324,7 +325,7 @@ public function testDumpAllUnmatchingArgs()
*/
public function testDumpAllIncorrectBase()
{
$this->expectException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);

$p = new Parser();
$r = new TextRenderer();
Expand Down Expand Up @@ -367,12 +368,12 @@ public function staticModeProvider()
'cli_detection' => false,
'mode_default_cli' => 43,
'renderers' => [
42 => 'Kint\\Renderer\\RichRenderer',
43 => 'Kint\\Renderer\\CliRenderer',
44 => 'Kint\\Renderer\\PlainRenderer',
42 => \Kint\Renderer\RichRenderer::class,
43 => \Kint\Renderer\CliRenderer::class,
44 => \Kint\Renderer\PlainRenderer::class,
],
],
'Kint\\Renderer\\RichRenderer',
\Kint\Renderer\RichRenderer::class,
],
'auto with cli' => [
[
Expand All @@ -381,12 +382,12 @@ public function staticModeProvider()
'cli_detection' => true,
'mode_default_cli' => 43,
'renderers' => [
42 => 'Kint\\Renderer\\RichRenderer',
43 => 'Kint\\Renderer\\CliRenderer',
44 => 'Kint\\Renderer\\PlainRenderer',
42 => \Kint\Renderer\RichRenderer::class,
43 => \Kint\Renderer\CliRenderer::class,
44 => \Kint\Renderer\PlainRenderer::class,
],
],
'Kint\\Renderer\\CliRenderer',
\Kint\Renderer\CliRenderer::class,
],
'specific' => [
[
Expand All @@ -395,12 +396,12 @@ public function staticModeProvider()
'cli_detection' => true,
'mode_default_cli' => 43,
'renderers' => [
42 => 'Kint\\Renderer\\RichRenderer',
43 => 'Kint\\Renderer\\CliRenderer',
44 => 'Kint\\Renderer\\PlainRenderer',
42 => \Kint\Renderer\RichRenderer::class,
43 => \Kint\Renderer\CliRenderer::class,
44 => \Kint\Renderer\PlainRenderer::class,
],
],
'Kint\\Renderer\\PlainRenderer',
\Kint\Renderer\PlainRenderer::class,
],
'disabled' => [
['enabled_mode' => false],
Expand All @@ -413,12 +414,12 @@ public function staticModeProvider()
'cli_detection' => true,
'mode_default_cli' => 43,
'renderers' => [
42 => 'Kint\\Renderer\\RichRenderer',
43 => 'Kint\\Renderer\\CliRenderer',
44 => 'Kint\\Renderer\\PlainRenderer',
42 => \Kint\Renderer\RichRenderer::class,
43 => \Kint\Renderer\CliRenderer::class,
44 => \Kint\Renderer\PlainRenderer::class,
],
],
'Kint\\Renderer\\TextRenderer',
TextRenderer::class,
],
'falsey renderer' => [
[
Expand All @@ -427,12 +428,12 @@ public function staticModeProvider()
'cli_detection' => false,
'mode_default_cli' => 1,
'renderers' => [
0 => 'Kint\\Renderer\\RichRenderer',
1 => 'Kint\\Renderer\\CliRenderer',
2 => 'Kint\\Renderer\\PlainRenderer',
0 => \Kint\Renderer\RichRenderer::class,
1 => \Kint\Renderer\CliRenderer::class,
2 => \Kint\Renderer\PlainRenderer::class,
],
],
'Kint\\Renderer\\RichRenderer',
\Kint\Renderer\RichRenderer::class,
],
];
}
Expand Down
11 changes: 6 additions & 5 deletions tests/Parser/ArrayLimitPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace Kint\Test\Parser;

use InvalidArgumentException;
use Kint\Parser\ArrayLimitPlugin;
use Kint\Parser\JsonPlugin;
use Kint\Parser\Parser;
Expand Down Expand Up @@ -204,10 +205,10 @@ public function testParseManipulated()
$subv = \end($o->value->contents);
$this->assertNotContains('array_limit', $subv->hints);
$subv = $subv->getRepresentation('json');
$this->assertInstanceOf('Kint\\Zval\\Representation\\Representation', $subv);
$this->assertInstanceOf(\Kint\Zval\Representation\Representation::class, $subv);
// array
$subv = $subv->contents;
$this->assertInstanceOf('Kint\\Zval\\Value', $subv);
$this->assertInstanceOf(Value::class, $subv);
$this->assertContains('array_limit', $subv->hints);

// Testing manipulated topography with arrays as representation contents
Expand All @@ -232,14 +233,14 @@ public function testParseManipulated()
$subv = \end($o->value->contents);
$this->assertNotContains('array_limit', $subv->hints);
$subv = $subv->getRepresentation('json');
$this->assertInstanceOf('Kint\\Zval\\Representation\\Representation', $subv);
$this->assertInstanceOf(\Kint\Zval\Representation\Representation::class, $subv);
// wrapped array
$subv = $subv->contents;
$this->assertSame('array', \gettype($subv));
$this->assertCount(1, $subv);
// array
$subv = \reset($subv);
$this->assertInstanceOf('Kint\\Zval\\Value', $subv);
$this->assertInstanceOf(Value::class, $subv);
$this->assertContains('array_limit', $subv->hints);
}

Expand All @@ -249,7 +250,7 @@ public function testParseManipulated()
*/
public function testInvalidSettings()
{
$this->expectException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);

ArrayLimitPlugin::$trigger = 20;
ArrayLimitPlugin::$limit = 30;
Expand Down
6 changes: 3 additions & 3 deletions tests/Parser/BlacklistPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function () use (&$completed) {
$this->assertNotContains('blacklist', $o->hints);
$this->assertTrue($completed);

BlacklistPlugin::$shallow_blacklist[] = 'Kint\\Test\\Fixtures\\TestClass';
BlacklistPlugin::$shallow_blacklist[] = \Kint\Test\Fixtures\TestClass::class;

$completed = false;
$o = $p->parse($v, clone $b);
Expand All @@ -106,12 +106,12 @@ function () use (&$completed) {

$this->assertContains('blacklist', $bo->hints);
$this->assertFalse($completed);
$this->assertInstanceOf('Kint\\Zval\\InstanceValue', $bo);
$this->assertInstanceOf(\Kint\Zval\InstanceValue::class, $bo);
$this->assertSame($o->spl_object_hash, $bo->spl_object_hash);
$this->assertSame($o->classname, $bo->classname);

$v = \reset($v);
BlacklistPlugin::$blacklist[] = 'Kint\\Test\\Fixtures\\TestClass';
BlacklistPlugin::$blacklist[] = \Kint\Test\Fixtures\TestClass::class;

$completed = false;
$bo = $p->parse($v, clone $b);
Expand Down
2 changes: 1 addition & 1 deletion tests/Parser/FsPathPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testParse($path, $expect)

if ($expect) {
$this->assertInstanceOf(
'\\Kint\\Zval\\Representation\\SplFileInfoRepresentation',
\Kint\Zval\Representation\SplFileInfoRepresentation::class,
$obj->getRepresentation('splfileinfo')
);

Expand Down
Loading

0 comments on commit 81c0e84

Please sign in to comment.