Skip to content

Commit 082c935

Browse files
committed
Increased unit test coverage of DocBlock;
Moved the tag block checks outside (and prior to) the tag line loop; Doc and CS fixes.
1 parent 233e4b3 commit 082c935

File tree

11 files changed

+71
-36
lines changed

11 files changed

+71
-36
lines changed

src/phpDocumentor/Reflection/DocBlock.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -200,30 +200,32 @@ protected function splitDocBlock($comment)
200200
protected function parseTags($tags)
201201
{
202202
$result = array();
203-
foreach (explode("\n", trim($tags)) as $tag_line) {
204-
if (trim($tag_line) === '') {
205-
continue;
203+
$tags = trim($tags);
204+
if ('' !== $tags) {
205+
if ('@' !== $tags[0]) {
206+
throw new \LogicException(
207+
'A tag block started with text instead of an actual tag,'
208+
. ' this makes the tag block invalid: ' . $tags
209+
);
206210
}
207-
208-
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
209-
$result[] = $tag_line;
210-
} else {
211-
if (count($result) == 0) {
212-
throw new \LogicException(
213-
'A tag block started with text instead of an actual tag,'
214-
. ' this makes the tag block invalid: ' . $tags
215-
);
211+
foreach (explode("\n", $tags) as $tag_line) {
212+
if (trim($tag_line) === '') {
213+
continue;
216214
}
217215

218-
$result[count($result) - 1] .= PHP_EOL . $tag_line;
216+
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
217+
$result[] = $tag_line;
218+
} else {
219+
$result[count($result) - 1] .= PHP_EOL . $tag_line;
220+
}
219221
}
220-
}
221222

222-
// create proper Tag objects
223-
foreach ($result as $key => $tag_line) {
224-
$tag = DocBlock\Tag::createInstance($tag_line);
225-
$tag->setDocBlock($this);
226-
$result[$key] = $tag;
223+
// create proper Tag objects
224+
foreach ($result as $key => $tag_line) {
225+
$tag = DocBlock\Tag::createInstance($tag_line);
226+
$tag->setDocBlock($this);
227+
$result[$key] = $tag;
228+
}
227229
}
228230

229231
$this->tags = $result;
@@ -388,6 +390,7 @@ public function expandType($type, $ignore_keywords = null)
388390
* implement it.
389391
*
390392
* @return string
393+
* @codeCoverageIgnore Not yet implemented
391394
*/
392395
public static function export()
393396
{
@@ -399,6 +402,7 @@ public static function export()
399402
* BUT this throws an exception at this point).
400403
*
401404
* @return string
405+
* @codeCoverageIgnore Not yet implemented
402406
*/
403407
public function __toString()
404408
{

src/phpDocumentor/Reflection/DocBlock/LongDescription.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getParsedContents()
100100
$this->parsedContents[$i]
101101
);
102102
}
103-
103+
104104
//In order to allow "literal" inline tags, the otherwise invalid
105105
//sequence "{@}" is changed to "@", and "{}" is changed to "}".
106106
//See unit tests for examples.
@@ -153,6 +153,7 @@ public function getFormattedContents()
153153
* and implement it.
154154
*
155155
* @return void
156+
* @codeCoverageIgnore Not yet implemented
156157
*/
157158
public static function export()
158159
{
@@ -164,9 +165,10 @@ public static function export()
164165
* BUT this throws an exception at this point).
165166
*
166167
* @return string
168+
* @codeCoverageIgnore Not yet implemented
167169
*/
168170
public function __toString()
169171
{
170172
return 'Not yet implemented';
171173
}
172-
}
174+
}

src/phpDocumentor/Reflection/DocBlock/Tag.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public function setDocBlock($docblock)
173173
* @todo determine the exact format as used by PHP Reflection and implement it.
174174
*
175175
* @return void
176+
* @codeCoverageIgnore Not yet implemented
176177
*/
177178
public static function export()
178179
{
@@ -184,6 +185,7 @@ public static function export()
184185
* BUT this throws an exception at this point).
185186
*
186187
* @return string
188+
* @codeCoverageIgnore Not yet implemented
187189
*/
188190
public function __toString()
189191
{

tests/phpDocumentor/Reflection/DocBlock/LongDescriptionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testInlineTagParsing()
5757
$parsedContents[2]
5858
);
5959
}
60-
60+
6161
public function testInlineTagAtStartParsing()
6262
{
6363
$fixture = <<<LONGDESC
@@ -69,7 +69,7 @@ public function testInlineTagAtStartParsing()
6969

7070
$parsedContents = $object->getParsedContents();
7171
$this->assertCount(3, $parsedContents);
72-
72+
7373
$this->assertSame('', $parsedContents[0]);
7474
$this->assertInstanceOf(
7575
__NAMESPACE__ . '\Tag\LinkTag',
@@ -81,7 +81,7 @@ public function testInlineTagAtStartParsing()
8181
$parsedContents[2]
8282
);
8383
}
84-
84+
8585
public function testNestedInlineTagParsing()
8686
{
8787
$fixture = <<<LONGDESC
@@ -93,7 +93,7 @@ public function testNestedInlineTagParsing()
9393

9494
$parsedContents = $object->getParsedContents();
9595
$this->assertCount(3, $parsedContents);
96-
96+
9797
$this->assertSame(
9898
'This is text for a description with ',
9999
$parsedContents[0]
@@ -198,7 +198,7 @@ public function testNestedLiteralClosingDelimiter()
198198
$parsedContents[1]->getParsedDescription()
199199
);
200200
}
201-
201+
202202
public function testInlineTagEscapingSequence()
203203
{
204204
$fixture = <<<LONGDESC
@@ -242,4 +242,4 @@ public function testNestedInlineTagEscapingSequence()
242242
$parsedContents[1]->getParsedDescription()
243243
);
244244
}
245-
}
245+
}

tests/phpDocumentor/Reflection/DocBlock/Tag/LinkTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
27-
* a link for the @link doc block
27+
* a link for the @link doc block.
2828
*
2929
* @param string $type
3030
* @param string $content

tests/phpDocumentor/Reflection/DocBlock/Tag/ParamTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
27-
* understand the param DocBlock.
27+
* understand the @param DocBlock.
2828
*
2929
* @param string $type
3030
* @param string $content

tests/phpDocumentor/Reflection/DocBlock/Tag/ReturnTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ReturnTagTest extends ParamTagTest
2424
{
2525
/**
2626
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
27-
* understand the Return DocBlock.
27+
* understand the @return DocBlock.
2828
*
2929
* @param string $content
3030
* @param string $extractedType

tests/phpDocumentor/Reflection/DocBlock/Tag/SeeTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
27-
* for the @see doc block
27+
* for the @see doc block.
2828
*
2929
* @param string $type
3030
* @param string $content

tests/phpDocumentor/Reflection/DocBlock/Tag/UsesTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
27-
* a link for the @uses doc block
27+
* a link for the @uses doc block.
2828
*
2929
* @param string $type
3030
* @param string $content

tests/phpDocumentor/Reflection/DocBlock/Tag/VarTagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
2626
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
27-
* understand the @var doc block
27+
* understand the @var doc block.
2828
*
2929
* @param string $type
3030
* @param string $content

0 commit comments

Comments
 (0)