diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index a2d0b6aa6..3c5d64023 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -215,6 +215,10 @@ abstract class Type throw new \InvalidArgumentException('Object-like type must be array'); } + if (!$properties) { + throw new \InvalidArgumentException('No properties supplied for ObjectLike'); + } + return new ObjectLike($properties); } diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 0ec80b9c4..fd56bd264 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -729,6 +729,14 @@ class AnnotationTest extends TestCase }', 'error_message' => 'UndefinedClass', ], + 'preventBadObjectLikeFormat' => [ + ' 'InvalidDocblock', + ] ]; } }