Skip to content

Commit 4b56b34

Browse files
author
Jamie Hannaford
committed
ensure strings are not considered default types; strengthen assoc checking
1 parent c0a6fc9 commit 4b56b34

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Common/Api/Parameter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ public function __construct(array $data)
125125
{
126126
$this->hydrate($data);
127127

128-
if (!$this->type) {
129-
$this->type = 'string';
130-
}
131-
132128
$this->required = (bool)$this->required;
133129

134130
$this->stockLocation($data);
@@ -272,7 +268,7 @@ private function hasCorrectType($userValue)
272268
{
273269
// Helper fn to see whether an array is associative (i.e. a JSON object)
274270
$isAssociative = function ($value) {
275-
return is_array($value) && (bool)count(array_filter(array_keys($value), 'is_string'));
271+
return is_array($value) && array_keys($value) !== range(0, count($value) - 1);
276272
};
277273

278274
// For params defined as objects, we'll let the user get away with
@@ -285,6 +281,10 @@ private function hasCorrectType($userValue)
285281
return is_a($userValue, $this->type);
286282
}
287283

284+
if (!$this->type) {
285+
return true;
286+
}
287+
288288
return gettype($userValue) == $this->type;
289289
}
290290

0 commit comments

Comments
 (0)