Skip to content

Commit

Permalink
fix Debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Oct 25, 2024
1 parent b507edc commit 032a612
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Utils/Pool/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function validate(mixed $value): bool
{
$debugger = new static();
$res = $debugger->cloneValidate($value);

unset($debugger);
return $res->getReturn();
}

Expand Down
31 changes: 24 additions & 7 deletions tests/UtilsCase/Pool/DebuggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class DebuggerTest extends TestCase
{
protected static ?\WeakMap $seen = null;
protected function tearDown(): void
{
parent::tearDown();
Expand Down Expand Up @@ -411,15 +412,31 @@ public function testCloneValidateException()

public function testSeenMechanism()
{
$object = new stdClass();
$object->prop = 'value';
$this->expectOutputString(
"construct\n"
. "1\n"
. "destruct\n"
. "0\n"
. "over\n"
);
$object = new class
{
protected $prop = 'value';

Debugger::validate($object);
$seen = Debugger::getSeen();
$this->assertNotEquals(0, $seen->count());
public function __construct()
{
echo "construct\n";
}

public function __destruct()
{
echo "destruct\n";
}
};
Debugger::validate($object);
echo Debugger::getSeen()->count() . "\n";
unset($object);

$this->assertEquals(0, $seen->count());
echo Debugger::getSeen()->count() . "\n";
echo "over\n";
}
}

0 comments on commit 032a612

Please sign in to comment.