prevent parse errors by escaping the quote used for filename property

This commit is contained in:
jordanbrauer
2021-02-13 11:17:52 -06:00
parent 40f2065575
commit 301ff155a4

View File

@ -170,7 +170,8 @@ final class TestCaseFactory
}, $filename); }, $filename);
} }
$filename = (string) realpath($filename); $quote = '\'';
$filename = str_replace($quote, sprintf('\\%s', $quote), (string) realpath($filename));
$rootPath = TestSuite::getInstance()->rootPath; $rootPath = TestSuite::getInstance()->rootPath;
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename); $relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php'); $relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php');
@ -203,7 +204,7 @@ final class TestCaseFactory
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN { final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
$traitsCode $traitsCode
private static \$__filename = '$filename'; private static \$__filename = $quote$filename$quote;
} }
"); ");
} catch (ParseError $caught) { } catch (ParseError $caught) {