Skip to content

Commit 7df651d

Browse files
committed
getDocComment() doesn't return string, per PhpParser code;
1 parent e0b7763 commit 7df651d

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ public function getFqsen(): Fqsen
7373
* Gets the doc comment of the node.
7474
*
7575
* The doc comment has to be the last comment associated with the node.
76-
*
77-
* @return null|Doc Doc comment object or null
7876
*/
79-
public function getDocComment()
77+
public function getDocComment(): ?Doc
8078
{
8179
$docComment = $this->classConstants->consts[$this->index]->getDocComment();
8280
if ($docComment === null) {

src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@ public function getLine(): int
8888
* Gets the doc comment of the node.
8989
*
9090
* The doc comment has to be the last comment associated with the node.
91-
*
92-
* @return null|Doc Doc comment object or null
9391
*/
94-
public function getDocComment()
92+
public function getDocComment(): ?Doc
9593
{
9694
$docComment = $this->property->props[$this->index]->getDocComment();
9795
if ($docComment === null) {

tests/unit/phpDocumentor/Reflection/Php/Factory/ClassConstantIteratorTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use Mockery as m;
1616
use phpDocumentor\Reflection\Fqsen;
17+
use PhpParser\Comment\Doc;
1718
use PhpParser\Node\Const_;
1819
use PhpParser\Node\Expr\Variable;
1920
use PhpParser\Node\Stmt\ClassConst;
@@ -94,12 +95,12 @@ public function testGetDocCommentPropFirst()
9495
$classConstants = m::mock(ClassConst::class);
9596
$classConstants->consts = [$const];
9697

97-
$const->shouldReceive('getDocComment')->once()->andReturn('test');
98+
$const->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
9899
$classConstants->shouldReceive('getDocComment')->never();
99100

100101
$fixture = new ClassConstantIterator($classConstants);
101102

102-
$this->assertEquals('test', $fixture->getDocComment());
103+
$this->assertEquals('test', $fixture->getDocComment()->getText());
103104
}
104105

105106
/**
@@ -112,10 +113,10 @@ public function testGetDocComment()
112113
$classConstants->consts = [$const];
113114

114115
$const->shouldReceive('getDocComment')->once()->andReturnNull();
115-
$classConstants->shouldReceive('getDocComment')->once()->andReturn('test');
116+
$classConstants->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
116117

117118
$fixture = new ClassConstantIterator($classConstants);
118119

119-
$this->assertEquals('test', $fixture->getDocComment());
120+
$this->assertEquals('test', $fixture->getDocComment()->getText());
120121
}
121122
}

tests/unit/phpDocumentor/Reflection/Php/Factory/PropertyIteratorTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace phpDocumentor\Reflection\Php\Factory;
1414

1515
use Mockery as m;
16+
use PhpParser\Comment\Doc;
1617
use PhpParser\Node\Stmt\Property as PropertyNode;
1718
use PhpParser\Node\Stmt\PropertyProperty;
1819
use PHPUnit\Framework\TestCase;
@@ -114,12 +115,12 @@ public function testGetDocCommentPropFirst()
114115
$propertyNode = m::mock(PropertyNode::class);
115116
$propertyNode->props = [$prop];
116117

117-
$prop->shouldReceive('getDocComment')->once()->andReturn('test');
118+
$prop->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
118119
$propertyNode->shouldReceive('getDocComment')->never();
119120

120121
$fixture = new PropertyIterator($propertyNode);
121122

122-
$this->assertEquals('test', $fixture->getDocComment());
123+
$this->assertEquals('test', $fixture->getDocComment()->getText());
123124
}
124125

125126
/**
@@ -132,10 +133,10 @@ public function testGetDocComment()
132133
$propertyNode->props = [$prop];
133134

134135
$prop->shouldReceive('getDocComment')->once()->andReturnNull();
135-
$propertyNode->shouldReceive('getDocComment')->once()->andReturn('test');
136+
$propertyNode->shouldReceive('getDocComment')->once()->andReturn(new Doc('test'));
136137

137138
$fixture = new PropertyIterator($propertyNode);
138139

139-
$this->assertEquals('test', $fixture->getDocComment());
140+
$this->assertEquals('test', $fixture->getDocComment()->getText());
140141
}
141142
}

0 commit comments

Comments
 (0)