Skip to content

Commit adde6b0

Browse files
committed
Fix min/maxProperties check for invalid array input
1 parent 17b6e5d commit adde6b0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public static function propertyExists($value, $property)
3131

3232
public static function propertyCount($value)
3333
{
34+
if (!is_object($value)) {
35+
return 0;
36+
}
37+
3438
return count(get_object_vars($value));
3539
}
3640
}

tests/Constraints/MinMaxPropertiesTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ public function getInvalidTests()
123123
}
124124
}'
125125
),
126+
array(
127+
'{
128+
"value": []
129+
}',
130+
'{
131+
"properties": {
132+
"value": {"minProperties": 1,"maxProperties": 2}
133+
}
134+
}'
135+
),
126136
);
127137
}
128138
}

0 commit comments

Comments
 (0)