<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\ParameterBag;
// Assume querystring = /path/of/route?foo=text&bar=anothertext2&qux=100
$request = new Request();
/** @var ParameterBag $parameterBag */
$parameterBag = $request->query;
dump(
$parameterBag->keys(),
$parameterBag->has('foo'),
$parameterBag->get('qux'),
$parameterBag->getBoolean('qux'),
$parameterBag->getAlpha('bar'),
$parameterBag->getDigits('bar'),
$parameterBag->getInt('bar'),
// returns false if value doesn't fit to filter
$parameterBag->filter('bar', null, FILTER_VALIDATE_INT, ['options' => ['default' => 1]]),
$parameterBag->filter('qux', 1, FILTER_VALIDATE_INT),
count($parameterBag)
);
^ array:3 [
0 => "foo"
1 => "bar"
2 => "qux"
]
^ true
^ 100
^ false
^ "anothertext"
^ "2"
^ 0
^ 1
^ 100
^ 3