Skip to content
Permalink
Browse files

catch cases of invalid use of backslash (#1983)

  • Loading branch information...
jeffreyyoo authored and muglug committed Aug 1, 2019
1 parent 6a213a6 commit 73a6fbe5579c33ee70846916a74894723d59ac50
Showing with 16 additions and 0 deletions.
  1. +6 −0 src/Psalm/Type.php
  2. +10 −0 tests/AnnotationTest.php
@@ -944,6 +944,12 @@ public static function fixUpLocalType(
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 @@ function fooBar(): void {
}',
'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
/**

0 comments on commit 73a6fbe

Please sign in to comment.
You can’t perform that action at this time.