/** * @return string */ public function generate() { $output = $this->generateTypeHint(); if (true === $this->passedByReference) { $output .= '&'; } if ($this->variadic) { $output .= '... '; } $output .= '$' . $this->name; if ($this->defaultValue !== null) { $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; } } return $output; }
/** * generate() * * @return string */ public function generate() { $output = ''; if ($this->type && !in_array($this->type, self::$simple)) { $output .= $this->type . ' '; } if ($this->passedByReference === true) { $output .= '&'; } $output .= '$' . $this->name; if ($this->defaultValue !== null) { $output .= ' = '; if (is_string($this->defaultValue)) { $output .= ValueGenerator::escape($this->defaultValue); } else { if ($this->defaultValue instanceof ValueGenerator) { $this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE); $output .= (string) $this->defaultValue; } else { $output .= $this->defaultValue; } } } return $output; }
/** * @return string */ private function generateDefaultValue() { if (null === $this->defaultValue) { return ''; } if (is_string($this->defaultValue)) { return ' = ' . ValueGenerator::escape($this->defaultValue); } if ($this->defaultValue instanceof ValueGenerator) { $this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE); } return ' = ' . $this->defaultValue; }
/** * @group 6023 * * @dataProvider getEscapedParameters */ public function testEscaping($input, $expectedEscapedValue) { $this->assertSame($expectedEscapedValue, ValueGenerator::escape($input, false)); }