diff --git a/src/Psalm/Checker/CommentChecker.php b/src/Psalm/Checker/CommentChecker.php index ae6386a3b..760f14211 100644 --- a/src/Psalm/Checker/CommentChecker.php +++ b/src/Psalm/Checker/CommentChecker.php @@ -11,7 +11,7 @@ use Psalm\Type; class CommentChecker { const TYPE_REGEX = - '(\\\?[A-Za-z0-9_\<,\>\[\]\-\{\}:|\\\]+|\$[a-zA-Z_0-9_\<,\>\|\[\]-\{\}:]+)'; + '(\??\\\?[A-Za-z0-9_\<,\>\[\]\-\{\}:|\\\]+|\$[a-zA-Z_0-9_\<,\>\|\[\]-\{\}:]+)'; /** * @param string $comment diff --git a/tests/Php71Test.php b/tests/Php71Test.php index 80a169d53..9321a3215 100644 --- a/tests/Php71Test.php +++ b/tests/Php71Test.php @@ -55,6 +55,26 @@ class Php71Test extends PHPUnit_Framework_TestCase $this->assertEquals('string|null', (string) $context->vars_in_scope['$a']); } + /** + * @return void + */ + public function testNullableReturnTypeInDocblock() + { + $stmts = self::$parser->parse('project_checker, $stmts); + $context = new Context(); + $file_checker->visitAndAnalyzeMethods($context); + $this->assertEquals('null|string', (string) $context->vars_in_scope['$a']); + } + /** * @return void */