diff --git a/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php b/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php index a6303a7a..59fa12be 100644 --- a/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php +++ b/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php @@ -31,6 +31,10 @@ public static function propertyExists($value, $property) public static function propertyCount($value) { + if (!is_object($value)) { + return 0; + } + return count(get_object_vars($value)); } } diff --git a/tests/Constraints/MinMaxPropertiesTest.php b/tests/Constraints/MinMaxPropertiesTest.php index 2063122c..90774b91 100644 --- a/tests/Constraints/MinMaxPropertiesTest.php +++ b/tests/Constraints/MinMaxPropertiesTest.php @@ -123,6 +123,16 @@ public function getInvalidTests() } }' ), + array( + '{ + "value": [] + }', + '{ + "properties": { + "value": {"minProperties": 1,"maxProperties": 2} + } + }' + ), ); } }