I have a class that looks like the following (shortened):
class Request
{
/**
* @var array $get get request, singleton
*/
private static $get = [];
/**
* Returns an instance of the request
*
* @param string $string request type to return
*
* @return array instance of request array
*/
public static function getInstance($string)
{
switch ($string) {
case 'get':
if (count(static::$get) === 0) {
static::$get = filter_input_array(INPUT_GET);
}
return static::$get;
break;
}
}
}
The line if (count(static::$get) === 0) {
throws a warning
Warning: count(): Parameter must be an array or an object that implements Countable
I am aware of the changes in PHP 7 and above, but I don't understand why static::$get is not known as an array, which should be countable. Where do I think wrong? It's an empty array, so counting it should account to 0?