Skip to content

Commit

Permalink
Merge pull request #250 from DanAtFh/remove_line_feed_when_no_descrip…
Browse files Browse the repository at this point in the history
…tion

Remove line feed when no description in DocBlock
  • Loading branch information
moufmouf committed Mar 26, 2020
2 parents 32b6959 + 7bfab49 commit 4d474a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use function get_parent_class;
use function is_string;
use function reset;
use function rtrim;
use function trim;
use function ucfirst;

Expand Down Expand Up @@ -408,7 +409,7 @@ private function getQueryFieldsFromSourceFields(array $sourceFields, ReflectionC
$fieldDescriptor->setTargetMethodOnSource($methodName);

$docBlockObj = $this->cachedDocBlockFactory->getDocBlock($refMethod);
$docBlockComment = $docBlockObj->getSummary() . "\n" . $docBlockObj->getDescription()->render();
$docBlockComment = rtrim($docBlockObj->getSummary() . "\n" . $docBlockObj->getDescription()->render());

$deprecated = $docBlockObj->getTagsByName('deprecated');
if (count($deprecated) >= 1) {
Expand Down
1 change: 1 addition & 0 deletions tests/FieldsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public function testSourceField(): void
$this->assertInstanceOf(NonNull::class, $fields['sibling']->getType());
$this->assertInstanceOf(ObjectType::class, $fields['sibling']->getType()->getWrappedType());
$this->assertSame('TestObject', $fields['sibling']->getType()->getWrappedType()->name);
$this->assertSame('This is a test summary', $fields['test']->description);
}

public function testSourceFieldOnSelfType(): void
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/TestObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(string $test, bool $testBool = false)
}

/**
* This is a test summary
* @return string
*/
public function getTest(): string
Expand Down

0 comments on commit 4d474a5

Please sign in to comment.