Skip to content

Commit 26d74ec

Browse files
committed
Fix that empty default value was converted to an empty array despite of strict mode
If Request parameter is an array without default value, then an error should be thrown that "parameter value is not an array" in strict mode
1 parent 2e0302e commit 26d74ec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Request/ParamFetcher.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ public function get($name, $strict = null)
110110
$default = $config->default;
111111
$paramType = $config instanceof QueryParam ? 'Query' : 'Request';
112112

113-
if ($config->array) {
114-
$default = (array) $default;
115-
}
116-
117113
if (null === $strict) {
118114
$strict = $config->strict;
119115
}
120116

117+
if ($config->array && (null !== $default || !$strict)) {
118+
$default = (array) $default;
119+
}
120+
121121
if ($config instanceof RequestParam) {
122122
$param = $this->request->request->get($config->getKey(), $default);
123123
} elseif ($config instanceof QueryParam) {
@@ -130,7 +130,7 @@ public function get($name, $strict = null)
130130
if (!is_array($param)) {
131131
if ($strict) {
132132
throw new BadRequestHttpException(
133-
sprintf("% parameter value of '%s' is not an array", $paramType, $name)
133+
sprintf("%s parameter value of '%s' is not an array", $paramType, $name)
134134
);
135135
}
136136

0 commit comments

Comments
 (0)