Merge pull request #3493 from arnested/php/Client_properties_validation-3480

[PHP] Fix invalid PHP syntax
This commit is contained in:
wing328 2016-08-01 18:06:56 +08:00 committed by GitHub
commit f5e20b4e88
4 changed files with 16 additions and 16 deletions

View File

@ -128,27 +128,27 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
{{/isEnum}} {{/isEnum}}
{{#hasValidation}} {{#hasValidation}}
{{#maxLength}} {{#maxLength}}
if ({{^required}}!is_null(${{$this->container['{{name}}']}}) && {{/required}}(strlen($this->container['{{name}}']) > {{maxLength}})) { if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) > {{maxLength}})) {
$invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}."; $invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
} }
{{/maxLength}} {{/maxLength}}
{{#minLength}} {{#minLength}}
if ({{^required}}!is_null(${{$this->container['{{name}}']}}) && {{/required}}(strlen($this->container['{{name}}']) < {{minLength}})) { if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) < {{minLength}})) {
$invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}."; $invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
} }
{{/minLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if ({{^required}}!is_null(${{$this->container['{{name}}']}}) && {{/required}}($this->container['{{name}}'] > {{maximum}})) { if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] > {{maximum}})) {
$invalid_properties[] = "invalid value for '{{name}}', must be smaller than or equal to {{maximum}}."; $invalid_properties[] = "invalid value for '{{name}}', must be smaller than or equal to {{maximum}}.";
} }
{{/maximum}} {{/maximum}}
{{#minimum}} {{#minimum}}
if ({{^required}}!is_null(${{$this->container['{{name}}']}}) && {{/required}}($this->container['{{name}}'] < {{minimum}})) { if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] < {{minimum}})) {
$invalid_properties[] = "invalid value for '{{name}}', must be bigger than or equal to {{minimum}}."; $invalid_properties[] = "invalid value for '{{name}}', must be bigger than or equal to {{minimum}}.";
} }
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if ({{^required}}!is_null(${{$this->container['{{name}}']}}) && {{/required}}!preg_match("{{pattern}}", $this->container['{{name}}'])) { if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}!preg_match("{{pattern}}", $this->container['{{name}}'])) {
$invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{pattern}}."; $invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{pattern}}.";
} }
{{/pattern}} {{/pattern}}

View File

@ -4,7 +4,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r - API version: 1.0.0 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
- Build date: 2016-07-29T14:59:34.783+02:00 - Build date: 2016-08-01T11:48:23.775+02:00
- Build package: class io.swagger.codegen.languages.PhpClientCodegen - Build package: class io.swagger.codegen.languages.PhpClientCodegen
## Requirements ## Requirements

View File

@ -4,7 +4,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 - API version: 1.0.0
- Build date: 2016-07-29T14:59:28.041+02:00 - Build date: 2016-08-01T11:48:17.791+02:00
- Build package: class io.swagger.codegen.languages.PhpClientCodegen - Build package: class io.swagger.codegen.languages.PhpClientCodegen
## Requirements ## Requirements

View File

@ -200,16 +200,16 @@ class FormatTest implements ArrayAccess
public function listInvalidProperties() public function listInvalidProperties()
{ {
$invalid_properties = array(); $invalid_properties = array();
if (!is_null(${{$this->container['integer']}}) && ($this->container['integer'] > 100.0)) { if (!is_null($this->container['integer']) && ($this->container['integer'] > 100.0)) {
$invalid_properties[] = "invalid value for 'integer', must be smaller than or equal to 100.0."; $invalid_properties[] = "invalid value for 'integer', must be smaller than or equal to 100.0.";
} }
if (!is_null(${{$this->container['integer']}}) && ($this->container['integer'] < 10.0)) { if (!is_null($this->container['integer']) && ($this->container['integer'] < 10.0)) {
$invalid_properties[] = "invalid value for 'integer', must be bigger than or equal to 10.0."; $invalid_properties[] = "invalid value for 'integer', must be bigger than or equal to 10.0.";
} }
if (!is_null(${{$this->container['int32']}}) && ($this->container['int32'] > 200.0)) { if (!is_null($this->container['int32']) && ($this->container['int32'] > 200.0)) {
$invalid_properties[] = "invalid value for 'int32', must be smaller than or equal to 200.0."; $invalid_properties[] = "invalid value for 'int32', must be smaller than or equal to 200.0.";
} }
if (!is_null(${{$this->container['int32']}}) && ($this->container['int32'] < 20.0)) { if (!is_null($this->container['int32']) && ($this->container['int32'] < 20.0)) {
$invalid_properties[] = "invalid value for 'int32', must be bigger than or equal to 20.0."; $invalid_properties[] = "invalid value for 'int32', must be bigger than or equal to 20.0.";
} }
if ($this->container['number'] === null) { if ($this->container['number'] === null) {
@ -221,19 +221,19 @@ class FormatTest implements ArrayAccess
if (($this->container['number'] < 32.1)) { if (($this->container['number'] < 32.1)) {
$invalid_properties[] = "invalid value for 'number', must be bigger than or equal to 32.1."; $invalid_properties[] = "invalid value for 'number', must be bigger than or equal to 32.1.";
} }
if (!is_null(${{$this->container['float']}}) && ($this->container['float'] > 987.6)) { if (!is_null($this->container['float']) && ($this->container['float'] > 987.6)) {
$invalid_properties[] = "invalid value for 'float', must be smaller than or equal to 987.6."; $invalid_properties[] = "invalid value for 'float', must be smaller than or equal to 987.6.";
} }
if (!is_null(${{$this->container['float']}}) && ($this->container['float'] < 54.3)) { if (!is_null($this->container['float']) && ($this->container['float'] < 54.3)) {
$invalid_properties[] = "invalid value for 'float', must be bigger than or equal to 54.3."; $invalid_properties[] = "invalid value for 'float', must be bigger than or equal to 54.3.";
} }
if (!is_null(${{$this->container['double']}}) && ($this->container['double'] > 123.4)) { if (!is_null($this->container['double']) && ($this->container['double'] > 123.4)) {
$invalid_properties[] = "invalid value for 'double', must be smaller than or equal to 123.4."; $invalid_properties[] = "invalid value for 'double', must be smaller than or equal to 123.4.";
} }
if (!is_null(${{$this->container['double']}}) && ($this->container['double'] < 67.8)) { if (!is_null($this->container['double']) && ($this->container['double'] < 67.8)) {
$invalid_properties[] = "invalid value for 'double', must be bigger than or equal to 67.8."; $invalid_properties[] = "invalid value for 'double', must be bigger than or equal to 67.8.";
} }
if (!is_null(${{$this->container['string']}}) && !preg_match("/[a-z]/i", $this->container['string'])) { if (!is_null($this->container['string']) && !preg_match("/[a-z]/i", $this->container['string'])) {
$invalid_properties[] = "invalid value for 'string', must be conform to the pattern /[a-z]/i."; $invalid_properties[] = "invalid value for 'string', must be conform to the pattern /[a-z]/i.";
} }
if ($this->container['byte'] === null) { if ($this->container['byte'] === null) {