Skip to content

Commit fa2d3be

Browse files
committed
fixed content for properties $documents
1 parent 912fa94 commit fa2d3be

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function from($from)
7171
$class->final = $from->isFinal() && $class->type === 'class';
7272
$class->abstract = $from->isAbstract() && $class->type === 'class';
7373
$class->implements = $from->getInterfaceNames();
74-
$class->documents = preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"));
74+
$class->documents = $from->getDocComment() ? array(preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array();
7575
$namespace = $from->getNamespaceName();
7676
if ($from->getParentClass()) {
7777
$class->extends = $from->getParentClass()->getName();
@@ -118,7 +118,7 @@ public function __toString()
118118

119119
$properties = array();
120120
foreach ($this->properties as $property) {
121-
$doc = str_replace("\n", "\n * ", implode("\n", (array) $property->getDocuments()));
121+
$doc = str_replace("\n", "\n * ", implode("\n", $property->getDocuments()));
122122
$properties[] = ($property->getDocuments() ? (strpos($doc, "\n") === FALSE ? "/** $doc */\n" : "/**\n * $doc\n */\n") : '')
123123
. $property->getVisibility() . ($property->isStatic() ? ' static' : '') . ' $' . $property->getName()
124124
. ($property->value === NULL ? '' : ' = ' . Helpers::dump($property->value))
@@ -139,7 +139,7 @@ public function __toString()
139139
}
140140

141141
return Strings::normalize(
142-
($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '')
142+
($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", $this->documents)) . "\n */\n" : '')
143143
. ($this->abstract ? 'abstract ' : '')
144144
. ($this->final ? 'final ' : '')
145145
. $this->type . ' '

src/PhpGenerator/Method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function from($from)
7070
$method->body = $from->isAbstract() ? FALSE : '';
7171
$method->returnReference = $from->returnsReference();
7272
$method->variadic = PHP_VERSION_ID >= 50600 && $from->isVariadic();
73-
$method->documents = preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"));
73+
$method->documents = $from->getDocComment() ? array(preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array();
7474
return $method;
7575
}
7676

@@ -98,7 +98,7 @@ public function __toString()
9898
foreach ($this->uses as $param) {
9999
$uses[] = ($param->isReference() ? '&' : '') . '$' . $param->getName();
100100
}
101-
return ($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '')
101+
return ($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", $this->documents)) . "\n */\n" : '')
102102
. ($this->abstract ? 'abstract ' : '')
103103
. ($this->final ? 'final ' : '')
104104
. ($this->visibility ? $this->visibility . ' ' : '')

src/PhpGenerator/PhpFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class PhpFile extends Object
2323
{
2424
/** @var string[] */
25-
private $documents;
25+
private $documents = array();
2626

2727
/** @var PhpNamespace[] */
2828
private $namespaces = array();
@@ -119,7 +119,7 @@ public function __toString()
119119

120120
return Strings::normalize(
121121
"<?php\n"
122-
. ($this->documents ? "\n" . str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n\n" : '')
122+
. ($this->documents ? "\n" . str_replace("\n", "\n * ", "/**\n" . implode("\n", $this->documents)) . "\n */\n\n" : '')
123123
. implode("\n\n", $this->namespaces)
124124
) . "\n";
125125
}

src/PhpGenerator/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function from(\ReflectionProperty $from)
4242
$prop->value = isset($defaults[$prop->name]) ? $defaults[$prop->name] : NULL;
4343
$prop->static = $from->isStatic();
4444
$prop->visibility = $from->isPrivate() ? 'private' : ($from->isProtected() ? 'protected' : 'public');
45-
$prop->documents = preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"));
45+
$prop->documents = $from->getDocComment() ? array(preg_replace('#^\s*\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array();
4646
return $prop;
4747
}
4848

0 commit comments

Comments
 (0)