diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index d83eaffce..e4063bdb6 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -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' diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 2e29e3d51..1686e58f2 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -1195,6 +1195,16 @@ class AnnotationTest extends TestCase }', 'error_message' => 'InvalidDocblock - src' . DIRECTORY_SEPARATOR . 'somefile.php:5:21 - Badly-formatted @param', ], + 'invalidSlashWithString' => [ + ' 'InvalidDocblock', + ], 'missingReturnTypeWithBadDocblock' => [ '