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

Default value of ParameterGenerator is always a ValueGenerator #133

Merged
merged 1 commit into from
Oct 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Generator/ParameterGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ParameterGenerator extends AbstractGenerator
protected $type;

/**
* @var string|ValueGenerator
* @var ValueGenerator
*/
protected $defaultValue;

Expand Down Expand Up @@ -226,7 +226,7 @@ public function setDefaultValue($defaultValue)
}

/**
* @return string
* @return ValueGenerator
*/
public function getDefaultValue()
{
Expand Down Expand Up @@ -306,16 +306,10 @@ public function generate()

$output .= '$' . $this->name;

if ($this->defaultValue !== null) {
if ($this->defaultValue instanceof ValueGenerator) {
$output .= ' = ';
if (is_string($this->defaultValue)) {
$output .= ValueGenerator::escape($this->defaultValue);
} elseif ($this->defaultValue instanceof ValueGenerator) {
$this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE);
$output .= $this->defaultValue;
} else {
$output .= $this->defaultValue;
}
$this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE);
$output .= $this->defaultValue;
}

return $output;
Expand Down