mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
add more unit tests and fixed the output
This commit is contained in:
@@ -85,7 +85,9 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
// if the next item starts with a $ or ...$ or &$ or &...$ it must be the variable name
|
||||
if (isset($parts[0]) && self::strStartsWithVariable($parts[0])) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
if ($type) {
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
Assert::notNull($variableName);
|
||||
|
||||
@@ -141,8 +143,8 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. ($this->isReference() ? '&' : '')
|
||||
. ($this->isVariadic() ? '...' : '')
|
||||
. ($this->variableName !== null ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
|
||||
}
|
||||
|
||||
private static function strStartsWithVariable(string $str) : bool
|
||||
|
||||
@@ -68,10 +68,12 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
array_unshift($parts, $firstPart);
|
||||
}
|
||||
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
// if the next item starts with a $ it must be the variable name
|
||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
if ($type) {
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
Assert::notNull($variableName);
|
||||
|
||||
@@ -98,6 +100,6 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,9 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
if ($type) {
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
Assert::notNull($variableName);
|
||||
|
||||
@@ -98,6 +100,6 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,9 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
if ($type) {
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
Assert::notNull($variableName);
|
||||
|
||||
@@ -98,6 +100,6 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,9 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
// if the next item starts with a $ or ...$ it must be the variable name
|
||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||
$variableName = array_shift($parts);
|
||||
array_shift($parts);
|
||||
if ($type) {
|
||||
array_shift($parts);
|
||||
}
|
||||
|
||||
Assert::notNull($variableName);
|
||||
|
||||
@@ -98,7 +100,7 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
public function __toString() : string
|
||||
{
|
||||
return ($this->type ? $this->type . ' ' : '')
|
||||
. (empty($this->variableName) ? '' : '$' . $this->variableName)
|
||||
. ($this->description ? ' ' . $this->description : '');
|
||||
. ($this->variableName ? '$' . $this->variableName : '')
|
||||
. ($this->description ? ($this->variableName ? ' ' : '') . $this->description : '');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user