mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #239 - warn about bad brackets
This commit is contained in:
parent
ed3e429d2c
commit
024bcbc371
@ -40,6 +40,10 @@ abstract class Type
|
||||
$type_string = self::convertSquareBrackets($type_string);
|
||||
}
|
||||
|
||||
if (preg_match('/[\[\]()]/', $type_string)) {
|
||||
throw new TypeParseTreeException('Invalid characters in type');
|
||||
}
|
||||
|
||||
$type_string = str_replace('?', 'null|', $type_string);
|
||||
|
||||
$type_tokens = self::tokenize($type_string);
|
||||
|
@ -333,7 +333,7 @@ class TypeAlgebraTest extends TestCase
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}'
|
||||
}',
|
||||
],
|
||||
'noParadoxAfterArrayAppending' => [
|
||||
'<?php
|
||||
@ -361,7 +361,7 @@ class TypeAlgebraTest extends TestCase
|
||||
return false;
|
||||
}
|
||||
return $errors;
|
||||
}'
|
||||
}',
|
||||
],
|
||||
'noParadoxInCatch' => [
|
||||
'<?php
|
||||
@ -384,8 +384,8 @@ class TypeAlgebraTest extends TestCase
|
||||
if (!$arr) { return []; }
|
||||
}
|
||||
return $arr;
|
||||
}'
|
||||
]
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,16 @@ class TypeParseTest extends TestCase
|
||||
$this->assertSame('array<mixed, A|B>|C', (string) Type::parseString('A[]|B[]|C'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psalm\Exception\TypeParseTreeException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidType()
|
||||
{
|
||||
Type::parseString('array(A)');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user