mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #812 - deal with errant colon without crashing
This commit is contained in:
parent
54893fdd55
commit
3891b08fc2
@ -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;
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user