function PhptTestCase::parse
Throws
1 call to PhptTestCase::parse()
- PhptTestCase::run in vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php - Runs a test and collects its result in a TestResult instance.
File
-
vendor/
phpunit/ phpunit/ src/ Runner/ PhptTestCase.php, line 442
Class
- PhptTestCase
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\RunnerCode
private function parse() : array {
$sections = [];
$section = '';
$unsupportedSections = [
'CGI',
'COOKIE',
'DEFLATE_POST',
'EXPECTHEADERS',
'EXTENSIONS',
'GET',
'GZIP_POST',
'HEADERS',
'PHPDBG',
'POST',
'POST_RAW',
'PUT',
'REDIRECTTEST',
'REQUEST',
];
$lineNr = 0;
foreach (file($this->filename) as $line) {
$lineNr++;
if (preg_match('/^--([_A-Z]+)--/', $line, $result)) {
$section = $result[1];
$sections[$section] = '';
$sections[$section . '_offset'] = $lineNr;
continue;
}
if (empty($section)) {
throw new InvalidPhptFileException();
}
$sections[$section] .= $line;
}
if (isset($sections['FILEEOF'])) {
$sections['FILE'] = rtrim($sections['FILEEOF'], "\r\n");
unset($sections['FILEEOF']);
}
$this->parseExternal($sections);
if (!$this->validate($sections)) {
throw new InvalidPhptFileException();
}
foreach ($unsupportedSections as $section) {
if (isset($sections[$section])) {
throw new UnsupportedPhptSectionException($section);
}
}
return $sections;
}