2021-02-24 16:14:04 +01:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2021-12-03 20:11:20 +01:00
|
|
|
use PhpParser\Comment\Doc;
|
2021-06-08 04:55:21 +02:00
|
|
|
use PhpParser\Node\Stmt\Class_;
|
2021-02-24 16:14:04 +01:00
|
|
|
use Psalm\Aliases;
|
|
|
|
use Psalm\Internal\PhpVisitor\Reflector\ClassLikeDocblockParser;
|
2021-12-03 20:11:20 +01:00
|
|
|
use Psalm\Tests\TestCase;
|
2021-02-24 16:14:04 +01:00
|
|
|
|
2021-12-03 20:11:20 +01:00
|
|
|
class ClassLikeDocblockParserTest extends TestCase
|
2021-02-24 16:14:04 +01:00
|
|
|
{
|
|
|
|
public function testDocblockDescription(): void
|
|
|
|
{
|
|
|
|
$doc = '/**
|
|
|
|
* Some Description
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
';
|
|
|
|
$node = new Class_(null);
|
2021-12-03 20:11:20 +01:00
|
|
|
$php_parser_doc = new Doc($doc);
|
2021-02-24 16:14:04 +01:00
|
|
|
$class_docblock = ClassLikeDocblockParser::parse($node, $php_parser_doc, new Aliases());
|
|
|
|
|
|
|
|
$this->assertSame('Some Description', $class_docblock->description);
|
|
|
|
}
|
2021-05-06 03:47:01 +02:00
|
|
|
|
|
|
|
public function testPreferPsalmPrefixedAnnotationsOverPhpstanOnes(): void
|
|
|
|
{
|
|
|
|
$doc = '/**
|
|
|
|
* @psalm-template-covariant T of string
|
|
|
|
* @phpstan-template T of int
|
|
|
|
*/
|
|
|
|
';
|
|
|
|
$node = new Class_(null);
|
2021-12-03 20:11:20 +01:00
|
|
|
$php_parser_doc = new Doc($doc);
|
2021-05-06 03:47:01 +02:00
|
|
|
$class_docblock = ClassLikeDocblockParser::parse($node, $php_parser_doc, new Aliases());
|
|
|
|
$this->assertSame([['T', 'of', 'string', true, 33]], $class_docblock->templates);
|
|
|
|
}
|
2021-02-24 16:14:04 +01:00
|
|
|
}
|