Skip to content

Commit

Permalink
ToString: Ignore SplFileInfo too
Browse files Browse the repository at this point in the history
Just results in repeated SplFileInfoRepresentation dumps
  • Loading branch information
jnvsor committed Sep 14, 2024
1 parent f579ff1 commit 46c22f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Binary file modified build/kint.phar
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Parser/ToStringPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
use Kint\Zval\Value;
use ReflectionClass;
use SimpleXMLElement;
use SplFileObject;
use SplFileInfo;
use Throwable;

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

public function getTypes(): array
Expand Down
10 changes: 5 additions & 5 deletions tests/Parser/ToStringPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

namespace Kint\Test\Parser;

use Exception;
use Kint\Parser\Parser;
use Kint\Parser\ToStringPlugin;
use Kint\Test\Fixtures\BadToStringClass;
use Kint\Test\KintTestCase;
use Kint\Zval\BlobValue;
use Kint\Zval\Value;
use SplFileInfo;
use stdClass;

/**
Expand Down Expand Up @@ -71,14 +71,14 @@ public function testParse()
$b = new Value('$v');
$b->access_path = '$v';

$v = new SplFileInfo(__FILE__);
$v = new Exception('There was an error');

$obj = $p->parse($v, clone $b);
$rep = $obj->getRepresentation('tostring');

$this->assertNotNull($rep);
$this->assertInstanceOf(BlobValue::class, $rep->contents);
$this->assertSame(__FILE__, $rep->contents->value->contents);
$this->assertSame((string) $v, $rep->contents->value->contents);
$this->assertSame('(string) $v', $rep->contents->access_path);

$b->access_path = null;
Expand Down Expand Up @@ -129,13 +129,13 @@ public function testParseBlacklist()
$p->addPlugin(new ToStringPlugin($p));
$b = new Value('$v');

$v = new SplFileInfo(__FILE__);
$v = new Exception('There was an error');

$obj = $p->parse($v, clone $b);

$this->assertNotNull($obj->getRepresentation('tostring'));

ToStringPlugin::$blacklist[] = SplFileInfo::class;
ToStringPlugin::$blacklist[] = Exception::class;

$obj = $p->parse($v, clone $b);

Expand Down

0 comments on commit 46c22f6

Please sign in to comment.