Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 4128350

Browse files
committed
Merge pull request #167 from MidnightDesign/remove-doc-block
Allow removing the doc block of a member
2 parents 2585658 + acadc3c commit 4128350

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/Generator/AbstractMemberGenerator.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class AbstractMemberGenerator extends AbstractGenerator
3636
/**#@-*/
3737

3838
/**
39-
* @var DocBlockGenerator
39+
* @var DocBlockGenerator|null
4040
*/
4141
protected $docBlock;
4242

@@ -236,8 +236,13 @@ public function setDocBlock($docBlock)
236236
return $this;
237237
}
238238

239+
public function removeDocBlock(): void
240+
{
241+
$this->docBlock = null;
242+
}
243+
239244
/**
240-
* @return DocBlockGenerator
245+
* @return DocBlockGenerator|null
241246
*/
242247
public function getDocBlock()
243248
{

test/Generator/AbstractMemberGeneratorTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use PHPUnit\Framework\TestCase;
1313
use Zend\Code\Generator\AbstractMemberGenerator;
14+
use Zend\Code\Generator\DocBlockGenerator;
1415
use Zend\Code\Generator\Exception\InvalidArgumentException;
1516

1617
class AbstractMemberGeneratorTest extends TestCase
@@ -43,4 +44,21 @@ public function testSetDocBlockThrowsExceptionWithInvalidType()
4344
$this->expectException(InvalidArgumentException::class);
4445
$this->fixture->setDocBlock(new \stdClass());
4546
}
47+
48+
public function testRemoveDocBlock(): void
49+
{
50+
$this->fixture->setDocBlock(new DocBlockGenerator());
51+
52+
$this->fixture->removeDocBlock();
53+
54+
$this->assertNull($this->fixture->getDocBlock());
55+
}
56+
57+
public function testRemoveDocBlockIsIdempotent(): void
58+
{
59+
$this->fixture->removeDocBlock();
60+
$this->fixture->removeDocBlock();
61+
62+
$this->assertNull($this->fixture->getDocBlock());
63+
}
4664
}

0 commit comments

Comments
 (0)