1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #812 - deal with errant colon without crashing

This commit is contained in:
Matthew Brown 2018-06-12 09:11:13 -04:00
parent 54893fdd55
commit 3891b08fc2
2 changed files with 14 additions and 0 deletions

View File

@ -252,6 +252,10 @@ class ParseTree
throw new TypeParseTreeException('Unexpected LHS of property');
}
if (!$current_parent instanceof ParseTree\ObjectLikeTree) {
throw new TypeParseTreeException('Saw : outside of object-like array');
}
$new_parent_leaf = new ParseTree\ObjectLikePropertyTree($current_leaf->value, $current_parent);
$new_parent_leaf->possibly_undefined = $last_token === '?';
$current_leaf->parent = $new_parent_leaf;

View File

@ -493,6 +493,16 @@ class TypeParseTest extends TestCase
Type::parseString('|array');
}
/**
* @expectedException \Psalm\Exception\TypeParseTreeException
*
* @return void
*/
public function testBadColonDash()
{
Type::parseString('array|string:-');
}
/**
* @expectedException \Psalm\Exception\TypeParseTreeException
*