mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
08855c806f
* Added method to not add newline before return in docblock. * Made setting of newline before return statically setable on docblock. * Created psalter parameter for setting of newline before return in doc block annotation. * Added tests to cover adding new line or not before return annotation in doc block via psalter. * Psalm and style fixes. * Changed flag for new lines between annotations to be considered for all annotations. * Extended tests to reflect changed behavior for new lines between annotations in psalter.
122 lines
2.8 KiB
PHP
122 lines
2.8 KiB
PHP
<?php
|
|
namespace Psalm\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
|
use Psalm\DocComment;
|
|
|
|
class DocCommentTest extends BaseTestCase
|
|
{
|
|
public function testNewLineIsAddedBetweenAnnotationsByDefault(): void
|
|
{
|
|
$docComment = [
|
|
'description' => 'some desc',
|
|
'specials' =>
|
|
[
|
|
'param' =>
|
|
[
|
|
2 => 'string $bli',
|
|
3 => 'int $bla',
|
|
],
|
|
'throws' =>
|
|
[
|
|
0 => '\Exception',
|
|
],
|
|
'return' =>
|
|
[
|
|
0 => 'bool',
|
|
],
|
|
],
|
|
];
|
|
|
|
$expectedDoc = '/**
|
|
* some desc
|
|
*
|
|
* @param string $bli
|
|
* @param int $bla
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @return bool
|
|
*/
|
|
';
|
|
|
|
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
|
|
}
|
|
|
|
public function testNewLineIsNotAddedBetweenAnnotationsIfDisabled(): void
|
|
{
|
|
DocComment::addNewLineBetweenAnnotations(false);
|
|
|
|
$docComment = [
|
|
'description' => 'some desc',
|
|
'specials' =>
|
|
[
|
|
'param' =>
|
|
[
|
|
2 => 'string $bli',
|
|
3 => 'int $bla',
|
|
],
|
|
'throws' =>
|
|
[
|
|
0 => '\Exception',
|
|
],
|
|
'return' =>
|
|
[
|
|
0 => 'bool',
|
|
],
|
|
],
|
|
];
|
|
|
|
$expectedDoc = '/**
|
|
* some desc
|
|
*
|
|
* @param string $bli
|
|
* @param int $bla
|
|
* @throws \Exception
|
|
* @return bool
|
|
*/
|
|
';
|
|
|
|
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
|
|
}
|
|
|
|
public function testNewLineIsAddedBetweenAnnotationsIfEnabled(): void
|
|
{
|
|
DocComment::addNewLineBetweenAnnotations(true);
|
|
|
|
$docComment = [
|
|
'description' => 'some desc',
|
|
'specials' =>
|
|
[
|
|
'param' =>
|
|
[
|
|
2 => 'string $bli',
|
|
3 => 'int $bla',
|
|
],
|
|
'throws' =>
|
|
[
|
|
0 => '\Exception',
|
|
],
|
|
'return' =>
|
|
[
|
|
0 => 'bool',
|
|
],
|
|
],
|
|
];
|
|
|
|
$expectedDoc = '/**
|
|
* some desc
|
|
*
|
|
* @param string $bli
|
|
* @param int $bla
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @return bool
|
|
*/
|
|
';
|
|
|
|
$this->assertSame($expectedDoc, DocComment::render($docComment, ''));
|
|
}
|
|
}
|