1
0
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:
Jeffrey Yoo 2019-08-01 16:10:12 -04:00 committed by Matthew Brown
parent 6a213a60aa
commit 73a6fbe557
2 changed files with 16 additions and 0 deletions

View File

@ -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'

View File

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