1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix issues with single-letter classes

This commit is contained in:
Matthew Brown 2016-12-31 00:14:00 -05:00
parent ee4a3882a7
commit 393297786d
3 changed files with 40 additions and 2 deletions

View File

@ -11,7 +11,7 @@ use Psalm\Type;
class CommentChecker
{
const TYPE_REGEX =
'(\\\?[A-Za-z0-9_\<,\>\[\]\-\{\}:|\\\]+[A-Za-z0-9_\<,\>\[\]-\{\}:]|\$[a-zA-Z_0-9_\<,\>\|\[\]-\{\}:]+)';
'(\\\?[A-Za-z0-9_\<,\>\[\]\-\{\}:|\\\]+|\$[a-zA-Z_0-9_\<,\>\|\[\]-\{\}:]+)';
/**
* @param string $comment

View File

@ -366,7 +366,7 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
$function_param->code_location
)
)) {
return false;
// fall through
}
}
}

View File

@ -202,4 +202,42 @@ class AnnotationTest extends PHPUnit_Framework_TestCase
$file_checker->check(true, true, $context);
$this->assertEquals('int', (string) $context->vars_in_scope['$a']);
}
public function testGoodDocblock()
{
$stmts = self::$parser->parse('<?php
class A {
/**
* @param A $a
* @param bool $b
*/
public function g(A $a, $b) : void {
}
}
');
$file_checker = new FileChecker('somefile.php', $stmts);
$context = new Context('somefile.php');
$file_checker->check(true, true, $context);
}
public function testGoodDocblockInNamespace()
{
$stmts = self::$parser->parse('<?php
namespace Foo;
class A {
/**
* @param \Foo\A $a
* @param bool $b
*/
public function g(A $a, $b) : void {
}
}
');
$file_checker = new FileChecker('somefile.php', $stmts);
$context = new Context('somefile.php');
$file_checker->check(true, true, $context);
}
}