mediatekformation

NativeRequestHandler
in package
implements RequestHandlerInterface

A request handler using PHP super globals $_GET, $_POST and $_SERVER.

Tags
author

Bernhard Schussek bschussek@gmail.com

Interfaces, Classes, Traits and Enums

RequestHandlerInterface
Submits forms if they were submitted.

Table of Contents

FILE_KEYS  = ['error', 'name', 'size', 'tmp_name', 'type']
The allowed keys of the $_FILES array.
$serverParams  : mixed
__construct()  : mixed
getUploadFileError()  : int|null
handleRequest()  : mixed
Submits a form if it was submitted.
isFileUpload()  : bool
Returns true if the given data is a file upload.
fixPhpFilesArray()  : mixed
Fixes a malformed PHP $_FILES array.
getRequestMethod()  : string
Returns the method used to submit the request to the server.
stripEmptyFiles()  : mixed
Sets empty uploaded files to NULL in the given uploaded files array.

Constants

FILE_KEYS

The allowed keys of the $_FILES array.

private mixed FILE_KEYS = ['error', 'name', 'size', 'tmp_name', 'type']

Properties

Methods

getUploadFileError()

public getUploadFileError(mixed $data) : int|null
Parameters
$data : mixed
Return values
int|null

isFileUpload()

Returns true if the given data is a file upload.

public isFileUpload(mixed $data) : bool
Parameters
$data : mixed

The form field data

Return values
bool

fixPhpFilesArray()

Fixes a malformed PHP $_FILES array.

private static fixPhpFilesArray(mixed $data) : 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.

This method is identical to and should be kept as such in order to port fixes quickly and easily.

Parameters
$data : mixed
Return values
mixed

getRequestMethod()

Returns the method used to submit the request to the server.

private static getRequestMethod() : string
Return values
string

stripEmptyFiles()

Sets empty uploaded files to NULL in the given uploaded files array.

private static stripEmptyFiles(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

Returns the stripped upload data

Search results