mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #617 - catch exception on bad square brackets
This commit is contained in:
parent
f5ef864168
commit
74aa376ec7
@ -60,6 +60,8 @@ abstract class Type
|
||||
$parsed_type = self::getTypeFromTree($parse_tree, $php_compatible);
|
||||
} catch (TypeParseTreeException $e) {
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
throw new TypeParseTreeException($e->getMessage());
|
||||
}
|
||||
|
||||
if (!($parsed_type instanceof Union)) {
|
||||
|
@ -116,6 +116,10 @@ abstract class Atomic
|
||||
throw new \Psalm\Exception\TypeParseTreeException('no hyphens allowed');
|
||||
}
|
||||
|
||||
if (is_numeric($value[0])) {
|
||||
throw new \Psalm\Exception\TypeParseTreeException('First character of type cannot be numeric');
|
||||
}
|
||||
|
||||
return new TNamedObject($value);
|
||||
}
|
||||
}
|
||||
|
@ -765,6 +765,36 @@ class AnnotationTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
'invalidReturnBrackets' => [
|
||||
'<?php
|
||||
interface I {
|
||||
/**
|
||||
* @return []
|
||||
*/
|
||||
public static function barBar();
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
'invalidPropertyClass' => [
|
||||
'<?php
|
||||
class A {
|
||||
/**
|
||||
* @var 1
|
||||
*/
|
||||
public $bar;
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
'invalidPropertyBrackets' => [
|
||||
'<?php
|
||||
class A {
|
||||
/**
|
||||
* @var []
|
||||
*/
|
||||
public $bar;
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
'invalidReturnClassWithComma' => [
|
||||
'<?php
|
||||
interface I {
|
||||
|
Loading…
x
Reference in New Issue
Block a user