function Loader::php
1 call to Loader::php()
- Loader::load in vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ Loader.php
File
-
vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ Loader.php, line 620
Class
- Loader
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\TextUI\XmlConfigurationCode
private function php(string $filename, DOMXPath $xpath) : Php {
$includePaths = [];
foreach ($xpath->query('php/includePath') as $includePath) {
assert($includePath instanceof DOMNode);
$path = $includePath->textContent;
if ($path) {
$includePaths[] = new Directory($this->toAbsolutePath($filename, $path));
}
}
$iniSettings = [];
foreach ($xpath->query('php/ini') as $ini) {
assert($ini instanceof DOMElement);
$iniSettings[] = new IniSetting($ini->getAttribute('name'), $ini->getAttribute('value'));
}
$constants = [];
foreach ($xpath->query('php/const') as $const) {
assert($const instanceof DOMElement);
$value = $const->getAttribute('value');
$constants[] = new Constant($const->getAttribute('name'), $this->getValue($value));
}
$variables = [
'var' => [],
'env' => [],
'post' => [],
'get' => [],
'cookie' => [],
'server' => [],
'files' => [],
'request' => [],
];
foreach ([
'var',
'env',
'post',
'get',
'cookie',
'server',
'files',
'request',
] as $array) {
foreach ($xpath->query('php/' . $array) as $var) {
assert($var instanceof DOMElement);
$name = $var->getAttribute('name');
$value = $var->getAttribute('value');
$force = false;
$verbatim = false;
if ($var->hasAttribute('force')) {
$force = $this->getBoolean($var->getAttribute('force'), false);
}
if ($var->hasAttribute('verbatim')) {
$verbatim = $this->getBoolean($var->getAttribute('verbatim'), false);
}
if (!$verbatim) {
$value = $this->getValue($value);
}
$variables[$array][] = new Variable($name, $value, $force);
}
}
return new Php(DirectoryCollection::fromArray($includePaths), IniSettingCollection::fromArray($iniSettings), ConstantCollection::fromArray($constants), VariableCollection::fromArray($variables['var']), VariableCollection::fromArray($variables['env']), VariableCollection::fromArray($variables['post']), VariableCollection::fromArray($variables['get']), VariableCollection::fromArray($variables['cookie']), VariableCollection::fromArray($variables['server']), VariableCollection::fromArray($variables['files']), VariableCollection::fromArray($variables['request']));
}