mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
use PhpParser\Comment\Doc;
|
|
use PhpParser\Node\Stmt\Class_;
|
|
use Psalm\Aliases;
|
|
use Psalm\Internal\PhpVisitor\Reflector\ClassLikeDocblockParser;
|
|
use Psalm\Tests\TestCase;
|
|
|
|
class ClassLikeDocblockParserTest extends TestCase
|
|
{
|
|
public function testDocblockDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* Some Description
|
|
*
|
|
*/
|
|
';
|
|
$node = new Class_(null);
|
|
$php_parser_doc = new Doc($doc);
|
|
$class_docblock = ClassLikeDocblockParser::parse($node, $php_parser_doc, new Aliases());
|
|
|
|
$this->assertSame('Some Description', $class_docblock->description);
|
|
}
|
|
|
|
public function testPreferPsalmPrefixedAnnotationsOverPhpstanOnes(): void
|
|
{
|
|
$doc = '/**
|
|
* @psalm-template-covariant T of string
|
|
* @phpstan-template T of int
|
|
*/
|
|
';
|
|
$node = new Class_(null);
|
|
$php_parser_doc = new Doc($doc);
|
|
$class_docblock = ClassLikeDocblockParser::parse($node, $php_parser_doc, new Aliases());
|
|
$this->assertSame([['T', 'of', 'string', true, 33]], $class_docblock->templates);
|
|
}
|
|
}
|