Documentation

Get
in package
implements Iterator, ArrayAccess

This class is meant to wrap around the _GET array. This allows Spitfire to register read and write data of your application for canonicalization of URLs.

Canonical URLs are important for your application to report the most recommended way of accessing a certain content it provides.

Canonical get has been especially tricky, as many applications simply will return the current page as canonical. Using the entire content of the GET variable for that.

An attacker could missuse your app to generate hundreds, thousands or even millions of URLs that point to the same content and use search engines to harm the performance and SEO of your app.

It will also trim the contents of the Array. So, it may modify data that relies on trailing spaces, newline characters or similar.

Interfaces, Classes and Traits

Iterator
ArrayAccess

Table of Contents

$data  : mixed
The actual data that this element wraps. It will be provided to an array like interface (it actually mainly implements ArrayAccess and Iterator by calling the functions on the array) that you can use to access the data the visitor sent with his request.
$used  : mixed
The list of values your application has read from this object. It will contain the indexes of the data array that have been requested from this object. It is used to generate the canonical array of data for the request.
__clone()  : mixed
Clones the data in case the Get element is cloned. This prevents editions to the object to be made global if this is desired.
__construct()  : mixed
Reads in the data that the GET variable holds. This allows it to trim the data and replace the _GET object in the global scope.
__get()  : mixed
Allows read access to the properties sent in the query string.
__isset()  : bool
This method allows you to test if a value was sent with the request by using isset() with the parameter like this isset($_GET->a)
__set()  : mixed
Allows writing back to the get object. Although you can, you should not :P
__toString()  : mixed
current()  : mixed
Returns the current element the array is iterating over.
getCanonical()  : mixed
Gets the canonical _GET. This is the array of data that actually was used from the Request after it was processed. Although this may not be 100% accurate it will work for most web applications and provide a level of security for parameter injection (which is not the same as SQL injection) that will work for most of Spitfire based applications.
getRaw()  : array<string|int, mixed>
Returns the data the way it was received. As an array of basic types (usually strings), just like PHP would usually return them. This function can be used to 'restore' the original _GET in case a component of your application needs it.
key()  : int|string
Returns the current key being used. This is also used for iteration and is not meant to be used by a actual user.
make()  : string|Get
Parses the content of a _GET array to fetch the data the user sent. This function converts Arrays into another Object to make the canonicalization work on different nesting levels.
next()  : mixed
Returns the next element in the array. This is also part of the iterator, so let's just implement it for people to have this.
offsetExists()  : mixed
Returns true if the offset is defined in the get. This is also part of the implementation of Iterator and should just mirror the operation on the source.
offsetGet()  : mixed
Gets a parameter by the name of it's key. Basically the equivalent of doing $array['key'] on any normal array.
offsetSet()  : mixed
Sets a key on the get array. This is usually considered bad practice but Spitfire respects the user doing so.
offsetUnset()  : mixed
Removes an element from the Get array. This allows your application to 'banish' any key that should not be used or could be potentially unsafe.
rewind()  : mixed
Rewinds the array and does not return anything. Just required by the iterator, so here it is.
toArray()  : mixed
toString()  : mixed
valid()  : bool
Tells whether a field in the array is set / exists. The function uses key() to detect whether the array has been pointed beyond it's end or not, if not it will return true.

Properties

$data

The actual data that this element wraps. It will be provided to an array like interface (it actually mainly implements ArrayAccess and Iterator by calling the functions on the array) that you can use to access the data the visitor sent with his request.

private mixed $data

$used

The list of values your application has read from this object. It will contain the indexes of the data array that have been requested from this object. It is used to generate the canonical array of data for the request.

private mixed $used

Methods

__clone()

Clones the data in case the Get element is cloned. This prevents editions to the object to be made global if this is desired.

public __clone() : mixed
Return values
mixed

__construct()

Reads in the data that the GET variable holds. This allows it to trim the data and replace the _GET object in the global scope.

public __construct(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

__get()

Allows read access to the properties sent in the query string.

public __get(string $name) : mixed
Parameters
$name : string
Return values
mixed

The content of the get variable on that index

__isset()

This method allows you to test if a value was sent with the request by using isset() with the parameter like this isset($_GET->a)

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

Allows writing back to the get object. Although you can, you should not :P

public __set(string $name, mixed $value) : mixed
Parameters
$name : string
$value : mixed
Return values
mixed

The content of the get variable on that index

__toString()

public __toString() : mixed
Return values
mixed

current()

Returns the current element the array is iterating over.

public current() : mixed
Return values
mixed

getCanonical()

Gets the canonical _GET. This is the array of data that actually was used from the Request after it was processed. Although this may not be 100% accurate it will work for most web applications and provide a level of security for parameter injection (which is not the same as SQL injection) that will work for most of Spitfire based applications.

public getCanonical() : mixed
Return values
mixed

getRaw()

Returns the data the way it was received. As an array of basic types (usually strings), just like PHP would usually return them. This function can be used to 'restore' the original _GET in case a component of your application needs it.

public getRaw() : array<string|int, mixed>

This is useful in situations where applications use the GET array in a manner that is not recommended and read the data in a way that is not completely standard.

Return values
array<string|int, mixed>

key()

Returns the current key being used. This is also used for iteration and is not meant to be used by a actual user.

public key() : int|string
Return values
int|string

make()

Parses the content of a _GET array to fetch the data the user sent. This function converts Arrays into another Object to make the canonicalization work on different nesting levels.

public make(Get|string $value) : string|Get
Parameters
$value : Get|string
Return values
string|Get

next()

Returns the next element in the array. This is also part of the iterator, so let's just implement it for people to have this.

public next() : mixed
Return values
mixed

offsetExists()

Returns true if the offset is defined in the get. This is also part of the implementation of Iterator and should just mirror the operation on the source.

public offsetExists(string $offset) : mixed
Parameters
$offset : string
Return values
mixed

offsetGet()

Gets a parameter by the name of it's key. Basically the equivalent of doing $array['key'] on any normal array.

public offsetGet(string $offset) : mixed
Parameters
$offset : string
Return values
mixed

offsetSet()

Sets a key on the get array. This is usually considered bad practice but Spitfire respects the user doing so.

public offsetSet(string $offset, mixed $value) : mixed
Parameters
$offset : string
$value : mixed
Return values
mixed

offsetUnset()

Removes an element from the Get array. This allows your application to 'banish' any key that should not be used or could be potentially unsafe.

public offsetUnset(string $offset) : mixed
Parameters
$offset : string
Return values
mixed

rewind()

Rewinds the array and does not return anything. Just required by the iterator, so here it is.

public rewind() : mixed
Return values
mixed

toArray()

public toArray(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

toString()

public toString(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

valid()

Tells whether a field in the array is set / exists. The function uses key() to detect whether the array has been pointed beyond it's end or not, if not it will return true.

public valid() : bool
Return values
bool

Search results