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

Commit 14fee05

Browse files
committed
Merge branch 'feature/167' into develop
Close #167
2 parents 2585658 + ce1af33 commit 14fee05

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file, in reverse
88

99
- [#170](https://github.com/zendframework/zend-code/pull/170) adds class constant visibility modifiers support.
1010

11+
- [#167](https://github.com/zendframework/zend-code/pull/167) adds the ability to remove doc block of a member.
12+
1113
### Changed
1214

1315
- [#166](https://github.com/zendframework/zend-code/pull/166) changes omitting default property value if it is null.

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)