\Symfony\Component\HttpFoundationFileBag

FileBag is a container for uploaded files.

Summary

Methods
Properties
Constants
__construct()
all()
keys()
replace()
add()
get()
set()
has()
remove()
getAlpha()
getAlnum()
getDigits()
getInt()
getBoolean()
filter()
getIterator()
count()
No public properties found
No constants found
convertFileInformation()
fixPhpFilesArray()
$parameters
N/A
No private methods found
$fileKeys
N/A

Properties

$parameters

$parameters : 

Parameter storage.

Type

$fileKeys

$fileKeys : 

Type

Methods

__construct()

__construct(array  $parameters = array()) 

Parameters

array $parameters

An array of HTTP files

all()

all() : array

Returns the parameters.

Returns

array —

An array of parameters

keys()

keys() : array

Returns the parameter keys.

Returns

array —

An array of parameter keys

replace()

replace(array  $files = array()) 

Replaces the current parameters by a new set.

Parameters

array $files

add()

add(array  $files = array()) 

Adds parameters.

Parameters

array $files

get()

get(string  $key, mixed  $default = null) : mixed

Returns a parameter by name.

Parameters

string $key

The key

mixed $default

The default value if the parameter key does not exist

Returns

mixed

set()

set(string  $key, mixed  $value) 

Sets a parameter by name.

Parameters

string $key

The key

mixed $value

The value

has()

has(string  $key) : boolean

Returns true if the parameter is defined.

Parameters

string $key

The key

Returns

boolean —

true if the parameter exists, false otherwise

remove()

remove(string  $key) 

Removes a parameter.

Parameters

string $key

The key

getAlpha()

getAlpha(string  $key, string  $default = '') : string

Returns the alphabetic characters of the parameter value.

Parameters

string $key

The parameter key

string $default

The default value if the parameter key does not exist

Returns

string —

The filtered value

getAlnum()

getAlnum(string  $key, string  $default = '') : string

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key

The parameter key

string $default

The default value if the parameter key does not exist

Returns

string —

The filtered value

getDigits()

getDigits(string  $key, string  $default = '') : string

Returns the digits of the parameter value.

Parameters

string $key

The parameter key

string $default

The default value if the parameter key does not exist

Returns

string —

The filtered value

getInt()

getInt(string  $key, integer  $default) : integer

Returns the parameter value converted to integer.

Parameters

string $key

The parameter key

integer $default

The default value if the parameter key does not exist

Returns

integer —

The filtered value

getBoolean()

getBoolean(string  $key, mixed  $default = false) : boolean

Returns the parameter value converted to boolean.

Parameters

string $key

The parameter key

mixed $default

The default value if the parameter key does not exist

Returns

boolean —

The filtered value

filter()

filter(string  $key, mixed  $default = null, integer  $filter = FILTER_DEFAULT, mixed  $options = array()) : mixed

Filter key.

Parameters

string $key

Key

mixed $default

Default = null

integer $filter

FILTER_* constant

mixed $options

Filter options

Returns

mixed

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for parameters.

Returns

\ArrayIterator —

An \ArrayIterator instance

count()

count() : integer

Returns the number of parameters.

Returns

integer —

The number of parameters

convertFileInformation()

convertFileInformation(array|\Symfony\Component\HttpFoundation\File\UploadedFile  $file) : array<mixed,\Symfony\Component\HttpFoundation\File\UploadedFile>|\Symfony\Component\HttpFoundation\File\UploadedFile|null

Converts uploaded files to UploadedFile instances.

Parameters

array|\Symfony\Component\HttpFoundation\File\UploadedFile $file

A (multi-dimensional) array of uploaded file information

Returns

array<mixed,\Symfony\Component\HttpFoundation\File\UploadedFile>|\Symfony\Component\HttpFoundation\File\UploadedFile|null —

A (multi-dimensional) array of UploadedFile instances

fixPhpFilesArray()

fixPhpFilesArray(  $data) : array

Fixes a malformed PHP $_FILES array.

PHP has a bug that the format of the $_FILES array differs, depending on whether the uploaded file fields had normal field names or array-like field names ("normal" vs. "parent[child]").

This method fixes the array to look like the "normal" $_FILES array.

It's safe to pass an already converted array, in which case this method just returns the original array unmodified.

Parameters

$data

Returns

array