mirror of
https://github.com/danog/psalm.git
synced 2024-12-12 01:09:38 +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>
60 lines
1.6 KiB
PHP
60 lines
1.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\PhpVisitor\Reflector\FunctionLikeDocblockParser;
|
|
|
|
class FunctionLikeDocblockParserTest extends BaseTestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
RuntimeCaches::clearAll();
|
|
}
|
|
|
|
public function testDocblockDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* Some Description
|
|
*
|
|
* @param string $bli
|
|
* @param int $bla
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @return bool
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$function_docblock = FunctionLikeDocblockParser::parse($php_parser_doc);
|
|
|
|
$this->assertSame('Some Description', $function_docblock->description);
|
|
}
|
|
|
|
public function testDocblockParamDescription(): void
|
|
{
|
|
$doc = '/**
|
|
* Some Description
|
|
*
|
|
* @param string $bli The BLI tag to iterate over.
|
|
* @param int $bla The blah tags
|
|
* that has a very long multiline description.
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @return bool
|
|
*/
|
|
';
|
|
$php_parser_doc = new \PhpParser\Comment\Doc($doc);
|
|
$function_docblock = FunctionLikeDocblockParser::parse($php_parser_doc);
|
|
|
|
$this->assertTrue(isset($function_docblock->params[0]['description']));
|
|
$this->assertSame('The BLI tag to iterate over.', $function_docblock->params[0]['description']);
|
|
|
|
$this->assertTrue(isset($function_docblock->params[1]['description']));
|
|
$this->assertSame('The blah tags that has a very long multiline description.', $function_docblock->params[1]['description']);
|
|
}
|
|
}
|