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

Commit

Permalink
Merge pull request #7299 from lstrojny/bug/oneline-doc-blocks
Browse files Browse the repository at this point in the history
Fix reflection for one line docblocks
  • Loading branch information
weierophinney committed Mar 10, 2015
2 parents ebf49b5 + ab51d73 commit ba706f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Code/Reflection/DocBlockReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function reflect()
return;
}

$docComment = $this->docComment; // localize variable
$docComment = preg_replace('#[ ]{0,1}\*/$#', '', $this->docComment);

// create a clean docComment
$this->cleanDocComment = preg_replace("#[ \t]*(?:/\*\*|\*/|\*)[ ]{0,1}(.*)?#", '$1', $docComment);
Expand Down
16 changes: 14 additions & 2 deletions tests/ZendTest/Code/Reflection/DocBlockReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ public function testDocBlockTags()
$this->assertEquals('mixed', $returnTag->getType());
}

public function testShortDocBlocks()
{
$classReflection = new ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass13');
$this->assertEquals(0, count($classReflection->getDocBlock()->getTags()));

$this->assertSame('Short Method Description', $classReflection->getMethod('doSomething')->getDocBlock()->getShortDescription());
$this->assertSame('Short Class Description', $classReflection->getDocBlock()->getShortDescription());

$returnTag = $classReflection->getMethod('returnSomething')->getDocBlock()->getTag('return');
$this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\TagInterface', $returnTag);
$this->assertEquals('Something', $returnTag->getType());
$this->assertEquals('This describes something', $returnTag->getDescription());
}

public function testTabbedDocBlockTags()
{
$classReflection = new ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass10');
Expand All @@ -85,8 +99,6 @@ public function testTabbedDocBlockTags()

public function testDocBlockLines()
{
//$this->markTestIncomplete('Line numbers incomplete');

$classReflection = new ClassReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass5');

$classDocBlock = $classReflection->getDocBlock();
Expand Down
15 changes: 15 additions & 0 deletions tests/ZendTest/Code/Reflection/TestAsset/TestSampleClass13.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace ZendTest\Code\Reflection\TestAsset;

/** Short Class Description */
class TestSampleClass13
{
/** Short Method Description */
public function doSomething()
{}

/** @return Something This describes something */
public function returnSomething()
{}
}

0 comments on commit ba706f6

Please sign in to comment.