mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
catch cases of invalid use of backslash (#1983)
This commit is contained in:
parent
6a213a60aa
commit
73a6fbe557
@ -944,6 +944,12 @@ abstract class Type
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($string_type_token[0][0] === '\\'
|
||||
&& strlen($string_type_token[0]) === 1
|
||||
) {
|
||||
throw new TypeParseTreeException("Backslash \"\\\" has to be part of class name.");
|
||||
}
|
||||
|
||||
if ($string_type_token[0][0] === '"'
|
||||
|| $string_type_token[0][0] === '\''
|
||||
|| $string_type_token[0] === '0'
|
||||
|
@ -1195,6 +1195,16 @@ class AnnotationTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock - src' . DIRECTORY_SEPARATOR . 'somefile.php:5:21 - Badly-formatted @param',
|
||||
],
|
||||
'invalidSlashWithString' => [
|
||||
'<?php
|
||||
/**
|
||||
* @return \?string
|
||||
*/
|
||||
function foo() {
|
||||
return rand(0, 1) ? "hello" : null;
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
'missingReturnTypeWithBadDocblock' => [
|
||||
'<?php
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user