Skip to content

Commit 384b95a

Browse files
uestladg
authored andcommitted
phpDocs: one-line property docs rendered as /** comment */ [Closes #2]
1 parent d953c92 commit 384b95a

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ public function __toString()
188188

189189
$properties = array();
190190
foreach ($this->properties as $property) {
191-
$properties[] = ($property->getDocuments() ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $property->getDocuments())) . "\n */\n" : '')
191+
$doc = str_replace("\n", "\n * ", implode("\n", (array) $property->getDocuments()));
192+
$properties[] = ($property->getDocuments() ? (strpos($doc, "\n") === FALSE ? "/** $doc */\n" : "/**\n * $doc\n */\n") : '')
192193
. $property->getVisibility() . ($property->isStatic() ? ' static' : '') . ' $' . $property->getName()
193194
. ($property->value === NULL ? '' : ' = ' . Helpers::dump($property->value))
194195
. ";\n";

tests/PhpGenerator/ClassType.expect

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ abstract final class Example extends ParentClass implements IExample, IOne
1212
const ROLE = 'admin';
1313
const FORCE_ARRAY = Nette\Utils\Json::FORCE_ARRAY;
1414

15-
16-
/**
17-
* @var resource orignal file handle
18-
*/
15+
16+
/** @var resource orignal file handle */
1917
private $handle;
2018

2119
public $order = RecursiveIteratorIterator::SELF_FIRST;
2220

2321
public static $sections = array('first' => TRUE);
2422

25-
23+
2624
/**
2725
* Returns file handle.
2826
* @return resource

tests/PhpGenerator/ClassType.from.expect

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ class Class2 extends Class1 implements Interface2
4141
*/
4242
public $public;
4343

44-
/**
45-
* @var int
46-
*/
44+
/** @var int */
4745
protected $protected = 10;
4846

4947
private $private = array();

0 commit comments

Comments
 (0)