1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #239 - warn about bad brackets

This commit is contained in:
Matt Brown 2017-10-12 14:02:06 -04:00
parent ed3e429d2c
commit 024bcbc371
3 changed files with 18 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}'
]
}',
],
];
}

View File

@ -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
*/