diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 965297cd4d3..ebd72704b37 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -358,6 +358,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public String toModelName(String name) { + // remove [ + name = name.replaceAll("\\]", ""); + // Note: backslash ("\\") is allowed for e.g. "\\DateTime" name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php new file mode 100644 index 00000000000..19d05e11f53 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -0,0 +1,238 @@ + 'int', + 'category' => 'object', + 'name' => 'string' + ); + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'id' => 'id', + 'category' => 'category', + 'name' => 'name' + ); + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'id' => 'setId', + 'category' => 'setCategory', + 'name' => 'setName' + ); + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'id' => 'getId', + 'category' => 'getCategory', + 'name' => 'getName' + ); + + + /** + * $id + * @var int + */ + protected $id; + + /** + * $category + * @var object + */ + protected $category; + + /** + * $name + * @var string + */ + protected $name; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + if ($data != null) { + $this->id = $data["id"]; + $this->category = $data["category"]; + $this->name = $data["name"]; + } + } + + /** + * Gets id + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Sets id + * @param int $id + * @return $this + */ + public function setId($id) + { + + $this->id = $id; + return $this; + } + + /** + * Gets category + * @return object + */ + public function getCategory() + { + return $this->category; + } + + /** + * Sets category + * @param object $category + * @return $this + */ + public function setCategory($category) + { + + $this->category = $category; + return $this; + } + + /** + * Gets name + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name + * @param string $name + * @return $this + */ + public function setName($name) + { + + $this->name = $name; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php new file mode 100644 index 00000000000..bb0dd842706 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ObjectReturn.php @@ -0,0 +1,174 @@ + 'int' + ); + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'return' => 'return' + ); + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'return' => 'setReturn' + ); + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'return' => 'getReturn' + ); + + + /** + * $return + * @var int + */ + protected $return; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + if ($data != null) { + $this->return = $data["return"]; + } + } + + /** + * Gets return + * @return int + */ + public function getReturn() + { + return $this->return; + } + + /** + * Sets return + * @param int $return + * @return $this + */ + public function setReturn($return) + { + + $this->return = $return; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php new file mode 100644 index 00000000000..52de7d06863 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -0,0 +1,174 @@ + 'int' + ); + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + static $attributeMap = array( + 'special_property_name' => '$special[property.name]' + ); + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + static $setters = array( + 'special_property_name' => 'setSpecialPropertyName' + ); + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + static $getters = array( + 'special_property_name' => 'getSpecialPropertyName' + ); + + + /** + * $special_property_name + * @var int + */ + protected $special_property_name; + + + /** + * Constructor + * @param mixed[] $data Associated array of property value initalizing the model + */ + public function __construct(array $data = null) + { + if ($data != null) { + $this->special_property_name = $data["special_property_name"]; + } + } + + /** + * Gets special_property_name + * @return int + */ + public function getSpecialPropertyName() + { + return $this->special_property_name; + } + + /** + * Sets special_property_name + * @param int $special_property_name + * @return $this + */ + public function setSpecialPropertyName($special_property_name) + { + + $this->special_property_name = $special_property_name; + return $this; + } + + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } else { + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/InlineResponse200Test.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/InlineResponse200Test.php new file mode 100644 index 00000000000..1bd1c822700 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/InlineResponse200Test.php @@ -0,0 +1,70 @@ +