mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
e59670ef68
* Add documention to LSP Add descriptions for all Classes, Functions, Methods, Class Constants for LSP methods for Hover, SignatureInformation and Completions * Descriptions for class name completions * PHPCS * Fix docblock being overriden * Remove trailing comma in args * Add description to function param before early `continue` * Update php-language-server-protocol to 1.5 * Break up long array docblocks * Break up docblock onto newline Co-authored-by: Matthew Brown <github@muglug.com>
79 lines
2.6 KiB
PHP
79 lines
2.6 KiB
PHP
<?php
|
|
namespace Psalm\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
|
use Psalm\DocComment;
|
|
use Psalm\Internal\RuntimeCaches;
|
|
use Psalm\Internal\Scanner\ParsedDocblock;
|
|
use Psalm\Internal\Analyzer\CommentAnalyzer;
|
|
use Psalm\Internal\Scanner\FileScanner;
|
|
use Psalm\Aliases;
|
|
|
|
class CommentAnalyzerTest extends BaseTestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
RuntimeCaches::clearAll();
|
|
}
|
|
|
|
public function testDocblockVarDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* @var string Some Description
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$comment_docblock = CommentAnalyzer::getTypeFromComment($php_parser_doc, new FileScanner('somefile.php', 'somefile.php', false), new Aliases);
|
|
$this->assertSame('Some Description', $comment_docblock[0]->description);
|
|
}
|
|
|
|
public function testDocblockVarDescriptionWithVarId(): void
|
|
{
|
|
$doc = '/**
|
|
* @var string $foo Some Description
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$comment_docblock = CommentAnalyzer::getTypeFromComment($php_parser_doc, new FileScanner('somefile.php', 'somefile.php', false), new Aliases);
|
|
$this->assertSame('Some Description', $comment_docblock[0]->description);
|
|
}
|
|
|
|
public function testDocblockVarDescriptionMultiline(): void
|
|
{
|
|
$doc = '/**
|
|
* @var string $foo Some Description
|
|
* with a long description.
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$comment_docblock = CommentAnalyzer::getTypeFromComment($php_parser_doc, new FileScanner('somefile.php', 'somefile.php', false), new Aliases);
|
|
$this->assertSame('Some Description with a long description.', $comment_docblock[0]->description);
|
|
}
|
|
|
|
public function testDocblockDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* Some Description
|
|
*
|
|
* @var string
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$comment_docblock = CommentAnalyzer::getTypeFromComment($php_parser_doc, new FileScanner('somefile.php', 'somefile.php', false), new Aliases);
|
|
$this->assertSame('Some Description', $comment_docblock[0]->description);
|
|
}
|
|
|
|
public function testDocblockDescriptionWithVarDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* Some Description
|
|
*
|
|
* @var string Use a string
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$comment_docblock = CommentAnalyzer::getTypeFromComment($php_parser_doc, new FileScanner('somefile.php', 'somefile.php', false), new Aliases);
|
|
$this->assertSame('Use a string', $comment_docblock[0]->description);
|
|
}
|
|
}
|