From b8d0e640b4783157fcd78929969d232c7e07a471 Mon Sep 17 00:00:00 2001 From: Smuuf Date: Wed, 12 Jun 2024 16:30:27 +0200 Subject: [PATCH] Remove NULL byte from class names, which cause problems when using phpdbg. Resolves https://github.com/nette/tester/issues/449 --- src/Framework/TestCase.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index e72241c4..13a09d39 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -213,8 +213,13 @@ private function sendMethodList(array $methods): void { Environment::$checkAssertions = false; header('Content-Type: text/plain'); + + // Class name might contain NULL byte (e.g. for anonymous classes), + // which might mess up our output. + $cleanClassName = str_replace("\0", '', static::class); + echo "\n"; - echo 'TestCase:' . static::class . "\n"; + echo 'TestCase:' . $cleanClassName . "\n"; echo 'Method:' . implode("\nMethod:", $methods) . "\n"; $dependentFiles = [];