Query strings and type safety

Query strings are usually strings, but - as some might not be aware of - can also be quite easily an array. So not checking on the type and blindly using it in stringish operations can currently cause undesired results.

$result = 'string' . $this->request->query('key'); // Dangerous without checking if set and a string
So with the current implementation of how query strings (and named params) work, one should always assert the correct type first:
$key = $this->request->query('key');
if (is_array($key)) { // Or: if (!is_scalar($key))
	throw new NotFoundException('Invalid query string'); // Simple 404
}
$result = 'string' . $this->request->query('key'); // Dangerous without checking if a stringish (=scalar) value
Annoying - I know. That's why I opened a ticket regarding this issue.

Demo/Example

Let's test:

A simple string A simple array

Named params also have the same issue

Result:
Array
(
    [key] => Array
        (
            [0] => v1
            [1] => v2
        )

)
Let's test:

A simple string A simple array

Even worse: Faulty JS appending params to the end of the url can also cause this:

A problematic array