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

Commit acadc3c

Browse files
Add removeDocBlock() to AbstractMemberGenerator
1 parent 35f60d7 commit acadc3c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/Generator/AbstractMemberGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public function setDocBlock($docBlock)
236236
return $this;
237237
}
238238

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

test/Generator/AbstractMemberGeneratorTest.php

Lines changed: 18 additions & 0 deletions
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)