public static function ServerRequestFactory::normalizeFiles in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php \Zend\Diactoros\ServerRequestFactory::normalizeFiles()
Normalize uploaded files
Transforms each value into an UploadedFileInterface instance, and ensures that nested arrays are normalized.
Parameters
array $files:
Return value
array
Throws
InvalidArgumentException for unrecognized values
2 calls to ServerRequestFactory::normalizeFiles()
- DiactorosFactory::createRequest in vendor/
symfony/ psr-http-message-bridge/ Factory/ DiactorosFactory.php - Creates a PSR-7 Request instance from a Symfony one.
- ServerRequestFactory::fromGlobals in vendor/
zendframework/ zend-diactoros/ src/ ServerRequestFactory.php - Create a request from the supplied superglobal values.
File
- vendor/
zendframework/ zend-diactoros/ src/ ServerRequestFactory.php, line 165
Class
- ServerRequestFactory
- Class for marshaling a request object from the current PHP environment.
Namespace
Zend\DiactorosCode
public static function normalizeFiles(array $files) {
$normalized = [];
foreach ($files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
continue;
}
if (is_array($value) && isset($value['tmp_name'])) {
$normalized[$key] = self::createUploadedFileFromSpec($value);
continue;
}
if (is_array($value)) {
$normalized[$key] = self::normalizeFiles($value);
continue;
}
throw new InvalidArgumentException('Invalid value in files specification');
}
return $normalized;
}