function Form::getPhpFiles
Gets the file field values as PHP.
This method converts fields with the array notation (like foo[bar] to arrays) like PHP does. The returned array is consistent with the array for field values (For a compound file field foo[bar] it will create foo[bar][name], instead of foo[name][bar] which would be found in $_FILES.
See also
getPhpValues), rather than uploaded files found in $_FILES.
File
-
vendor/
symfony/ dom-crawler/ Form.php, line 146
Class
- Form
- Form represents an HTML form.
Namespace
Symfony\Component\DomCrawlerCode
public function getPhpFiles() : array {
$values = [];
foreach ($this->getFiles() as $name => $value) {
$qs = http_build_query([
$name => $value,
], '', '&');
if ($qs) {
parse_str($qs, $expandedValue);
$varName = substr($name, 0, \strlen(key($expandedValue)));
array_walk_recursive($expandedValue, function (&$value, $key) {
if (ctype_digit($value) && ('size' === $key || 'error' === $key)) {
$value = (int) $value;
}
});
reset($expandedValue);
$values[] = [
$varName => current($expandedValue),
];
}
}
return array_replace_recursive([], ...$values);
}