FileAccess Orion

FileBag extends ParameterBag
in package

FileBag is a container for uploaded files.

Tags
author

Fabien Potencier fabien@symfony.com

author

Bulat Shakirzyanov mallluhuct@gmail.com

Table of Contents

$parameters  : mixed
Parameter storage.
$fileKeys  : mixed
__construct()  : mixed
add()  : mixed
Adds parameters.
all()  : array<string|int, mixed>
Returns the parameters.
count()  : int
Returns the number of parameters.
filter()  : mixed
Filter key.
get()  : mixed
Returns a parameter by name.
getAlnum()  : string
Returns the alphabetic characters and digits of the parameter value.
getAlpha()  : string
Returns the alphabetic characters of the parameter value.
getBoolean()  : bool
Returns the parameter value converted to boolean.
getDigits()  : string
Returns the digits of the parameter value.
getInt()  : int
Returns the parameter value converted to integer.
getIterator()  : ArrayIterator
Returns an iterator for parameters.
has()  : bool
Returns true if the parameter is defined.
keys()  : array<string|int, mixed>
Returns the parameter keys.
remove()  : mixed
Removes a parameter.
replace()  : mixed
Replaces the current parameters by a new set.
set()  : mixed
Sets a parameter by name.
convertFileInformation()  : array<string|int, UploadedFile>|UploadedFile|null
Converts uploaded files to UploadedFile instances.
fixPhpFilesArray()  : array<string|int, mixed>
Fixes a malformed PHP $_FILES array.

Properties

$parameters

Parameter storage.

protected mixed $parameters

$fileKeys

private static mixed $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type']

Methods

__construct()

public __construct([array<string|int, mixed>|array<string|int, UploadedFile$parameters = [] ]) : mixed
Parameters
$parameters : array<string|int, mixed>|array<string|int, UploadedFile> = []

An array of HTTP files

Return values
mixed

add()

Adds parameters.

public add([array<string|int, mixed> $files = [] ]) : mixed
Parameters
$files : array<string|int, mixed> = []
Return values
mixed

all()

Returns the parameters.

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of parameters

count()

Returns the number of parameters.

public count() : int
Return values
int

The number of parameters

filter()

Filter key.

public filter(string $key[, mixed $default = null ][, int $filter = FILTER_DEFAULT ][, mixed $options = [] ]) : mixed
Parameters
$key : string

Key

$default : mixed = null

Default = null

$filter : int = FILTER_DEFAULT

FILTER_* constant

$options : mixed = []

Filter options

Tags
see
https://php.net/filter-var
Return values
mixed

get()

Returns a parameter by name.

public get(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string

The key

$default : mixed = null

The default value if the parameter key does not exist

Return values
mixed

getAlnum()

Returns the alphabetic characters and digits of the parameter value.

public getAlnum(string $key[, string $default = '' ]) : string
Parameters
$key : string

The parameter key

$default : string = ''

The default value if the parameter key does not exist

Return values
string

The filtered value

getAlpha()

Returns the alphabetic characters of the parameter value.

public getAlpha(string $key[, string $default = '' ]) : string
Parameters
$key : string

The parameter key

$default : string = ''

The default value if the parameter key does not exist

Return values
string

The filtered value

getBoolean()

Returns the parameter value converted to boolean.

public getBoolean(string $key[, bool $default = false ]) : bool
Parameters
$key : string

The parameter key

$default : bool = false

The default value if the parameter key does not exist

Return values
bool

The filtered value

getDigits()

Returns the digits of the parameter value.

public getDigits(string $key[, string $default = '' ]) : string
Parameters
$key : string

The parameter key

$default : string = ''

The default value if the parameter key does not exist

Return values
string

The filtered value

getInt()

Returns the parameter value converted to integer.

public getInt(string $key, int $default) : int
Parameters
$key : string

The parameter key

$default : int

The default value if the parameter key does not exist

Return values
int

The filtered value

getIterator()

Returns an iterator for parameters.

public getIterator() : ArrayIterator
Return values
ArrayIterator

An \ArrayIterator instance

has()

Returns true if the parameter is defined.

public has(string $key) : bool
Parameters
$key : string

The key

Return values
bool

true if the parameter exists, false otherwise

keys()

Returns the parameter keys.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of parameter keys

remove()

Removes a parameter.

public remove(string $key) : mixed
Parameters
$key : string

The key

Return values
mixed

replace()

Replaces the current parameters by a new set.

public replace([array<string|int, mixed> $files = [] ]) : mixed
Parameters
$files : array<string|int, mixed> = []
Return values
mixed

set()

Sets a parameter by name.

public set(mixed $key, mixed $value) : mixed
Parameters
$key : mixed

The key

$value : mixed

The value

Return values
mixed

convertFileInformation()

Converts uploaded files to UploadedFile instances.

protected convertFileInformation(array<string|int, mixed>|UploadedFile $file) : array<string|int, UploadedFile>|UploadedFile|null
Parameters
$file : array<string|int, mixed>|UploadedFile

A (multi-dimensional) array of uploaded file information

Return values
array<string|int, UploadedFile>|UploadedFile|null

A (multi-dimensional) array of UploadedFile instances

fixPhpFilesArray()

Fixes a malformed PHP $_FILES array.

protected fixPhpFilesArray(array<string|int, mixed> $data) : array<string|int, mixed>

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 : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results