diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index b76bccc81..77762338d 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -406,6 +406,10 @@ abstract class Type ); } + if ($parse_tree instanceof ParseTree\MethodTree) { + throw new TypeParseTreeException('Misplaced brackets'); + } + if (!$parse_tree instanceof ParseTree\Value) { throw new \InvalidArgumentException('Unrecognised parse tree type ' . get_class($parse_tree)); } diff --git a/tests/TypeParseTest.php b/tests/TypeParseTest.php index 052f15960..bf8530026 100644 --- a/tests/TypeParseTest.php +++ b/tests/TypeParseTest.php @@ -489,6 +489,16 @@ class TypeParseTest extends TestCase Type::parseString(':array'); } + /** + * @expectedException \Psalm\Exception\TypeParseTreeException + * + * @return void + */ + public function testBadBrackets() + { + Type::parseString('max(a)'); + } + /** * @expectedException \Psalm\Exception\TypeParseTreeException *