diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index e040c6cc5f2..4fd50fa898b 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -49,20 +49,20 @@ class {{classname}} { $headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}'; {{#queryParams}}// query params - if(${{paramName}} != null) { + if(${{paramName}} !== null) { $queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}}); }{{/queryParams}} {{#headerParams}}// header params - if(${{paramName}} != null) { + if(${{paramName}} !== null) { $headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}}); }{{/headerParams}} {{#pathParams}}// path params - if(${{paramName}} != null) { + if(${{paramName}} !== null) { $resourcePath = str_replace("{" . "{{paramName}}" . "}", $this->apiClient->toPathValue(${{paramName}}), $resourcePath); }{{/pathParams}} {{#formParams}} - if (${{paramName}} != null) { + if (${{paramName}} !== null) { $formParams[{{paramName}}] = {{#isFile}}'@' . {{/isFile}}${{paramName}}; }{{/formParams}} {{#bodyParams}}// body params diff --git a/samples/client/petstore/php/PetApi.php b/samples/client/petstore/php/PetApi.php index 4a577a0c2e3..da31002dcbb 100644 --- a/samples/client/petstore/php/PetApi.php +++ b/samples/client/petstore/php/PetApi.php @@ -138,7 +138,7 @@ public function findPetsByStatus($status) { $headerParams['Content-Type'] = ''; // query params - if($status != null) { + if($status !== null) { $queryParams['status'] = $this->apiClient->toQueryValue($status); } @@ -188,7 +188,7 @@ public function findPetsByTags($tags) { $headerParams['Content-Type'] = ''; // query params - if($tags != null) { + if($tags !== null) { $queryParams['tags'] = $this->apiClient->toQueryValue($tags); } @@ -240,7 +240,7 @@ public function getPetById($petId) { // path params - if($petId != null) { + if($petId !== null) { $resourcePath = str_replace("{" . "petId" . "}", $this->apiClient->toPathValue($petId), $resourcePath); } @@ -293,15 +293,15 @@ public function updatePetWithForm($petId, $name, $status) { // path params - if($petId != null) { + if($petId !== null) { $resourcePath = str_replace("{" . "petId" . "}", $this->apiClient->toPathValue($petId), $resourcePath); } - if ($name != null) { + if ($name !== null) { $formParams[name] = $name; } - if ($status != null) { + if ($status !== null) { $formParams[status] = $status; } @@ -344,11 +344,11 @@ public function deletePet($api_key, $petId) { // header params - if($api_key != null) { + if($api_key !== null) { $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); } // path params - if($petId != null) { + if($petId !== null) { $resourcePath = str_replace("{" . "petId" . "}", $this->apiClient->toPathValue($petId), $resourcePath); } @@ -373,13 +373,14 @@ public function deletePet($api_key, $petId) { * uploadFile * * uploads an image - * additionalMetadata, string: Additional data to pass to server (required) + * petId, int: ID of pet to update (required) + * * additionalMetadata, string: Additional data to pass to server (required) * * file, file: file to upload (required) * * @return */ - public function uploadFile($additionalMetadata, $file) { + public function uploadFile($petId, $additionalMetadata, $file) { // parse inputs $resourcePath = "/pet/{petId}/uploadImage"; @@ -393,12 +394,16 @@ public function uploadFile($additionalMetadata, $file) { + // path params + if($petId !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($petId), $resourcePath); + } - - if ($additionalMetadata != null) { + if ($additionalMetadata !== null) { $formParams[additionalMetadata] = $additionalMetadata; } - if ($file != null) { + if ($file !== null) { $formParams[file] = '@' . $file; } diff --git a/samples/client/petstore/php/StoreApi.php b/samples/client/petstore/php/StoreApi.php index 9c46ea67036..0496c08d2e8 100644 --- a/samples/client/petstore/php/StoreApi.php +++ b/samples/client/petstore/php/StoreApi.php @@ -147,7 +147,7 @@ public function getOrderById($orderId) { // path params - if($orderId != null) { + if($orderId !== null) { $resourcePath = str_replace("{" . "orderId" . "}", $this->apiClient->toPathValue($orderId), $resourcePath); } @@ -198,7 +198,7 @@ public function deleteOrder($orderId) { // path params - if($orderId != null) { + if($orderId !== null) { $resourcePath = str_replace("{" . "orderId" . "}", $this->apiClient->toPathValue($orderId), $resourcePath); } diff --git a/samples/client/petstore/php/UserApi.php b/samples/client/petstore/php/UserApi.php index 23d6b5d117a..697af96328b 100644 --- a/samples/client/petstore/php/UserApi.php +++ b/samples/client/petstore/php/UserApi.php @@ -184,10 +184,10 @@ public function loginUser($username, $password) { $headerParams['Content-Type'] = ''; // query params - if($username != null) { + if($username !== null) { $queryParams['username'] = $this->apiClient->toQueryValue($username); }// query params - if($password != null) { + if($password !== null) { $queryParams['password'] = $this->apiClient->toQueryValue($password); } @@ -279,7 +279,7 @@ public function getUserByName($username) { // path params - if($username != null) { + if($username !== null) { $resourcePath = str_replace("{" . "username" . "}", $this->apiClient->toPathValue($username), $resourcePath); } @@ -331,7 +331,7 @@ public function updateUser($username, $body) { // path params - if($username != null) { + if($username !== null) { $resourcePath = str_replace("{" . "username" . "}", $this->apiClient->toPathValue($username), $resourcePath); } @@ -380,7 +380,7 @@ public function deleteUser($username) { // path params - if($username != null) { + if($username !== null) { $resourcePath = str_replace("{" . "username" . "}", $this->apiClient->toPathValue($username), $resourcePath); }