diff --git a/Controller/Annotations/QueryParam.php b/Controller/Annotations/QueryParam.php index e87c209e2..6a8eb0017 100644 --- a/Controller/Annotations/QueryParam.php +++ b/Controller/Annotations/QueryParam.php @@ -22,9 +22,9 @@ class QueryParam /** @var string */ public $name; /** @var string */ - public $requirements; + public $requirements = ''; /** @var string */ - public $default; + public $default = ''; /** @var string */ public $description; } diff --git a/Request/QueryFetcher.php b/Request/QueryFetcher.php index 1842ea9bd..719fbec9c 100644 --- a/Request/QueryFetcher.php +++ b/Request/QueryFetcher.php @@ -88,7 +88,10 @@ public function get($name, $strict = false) $param = $this->request->query->get($name, $default); // Set default if the requirements do not match - if ($param !== $default && !preg_match('#^'.$config->requirements.'$#xs', $param)) { + if ("" !== $config->requirements + && $param !== $default + && !preg_match('#^'.$config->requirements.'$#xs', $param) + ) { if ($strict) { throw new \RuntimeException("Query parameter value '$param', does not match requirements '{$config->requirements}'"); }