From cffaaa027adb2ddb32ed7e29dda3f1f777dff3b3 Mon Sep 17 00:00:00 2001 From: baartosz Date: Thu, 9 Mar 2017 09:28:19 +0000 Subject: [PATCH] minor improvements to Configuration php template (#4989) --- .../main/resources/php/configuration.mustache | 51 ++++++++++--------- .../SwaggerClient-php/lib/Configuration.php | 51 ++++++++++--------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/configuration.mustache b/modules/swagger-codegen/src/main/resources/php/configuration.mustache index d409c625cda..bc3548a5019 100644 --- a/modules/swagger-codegen/src/main/resources/php/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/php/configuration.mustache @@ -29,7 +29,7 @@ namespace {{invokerPackage}}; */ class Configuration { - private static $defaultConfiguration = null; + private static $defaultConfiguration; /** * Associate array to store API key(s) @@ -99,7 +99,7 @@ class Configuration * * @var string */ - protected $userAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{#artifactVersion}}{{{.}}}{{/artifactVersion}}{{^artifactVersion}}1.0.0{{/artifactVersion}}/php{{/httpUserAgent}}"; + protected $userAgent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{#artifactVersion}}{{{.}}}{{/artifactVersion}}{{^artifactVersion}}1.0.0{{/artifactVersion}}/php{{/httpUserAgent}}'; /** * Debug switch (default set to false) @@ -181,7 +181,7 @@ class Configuration * @param string $apiKeyIdentifier API key identifier (authentication scheme) * @param string $key API key or token * - * @return Configuration + * @return $this */ public function setApiKey($apiKeyIdentifier, $key) { @@ -207,7 +207,7 @@ class Configuration * @param string $apiKeyIdentifier API key identifier (authentication scheme) * @param string $prefix API key prefix, e.g. Bearer * - * @return Configuration + * @return $this */ public function setApiKeyPrefix($apiKeyIdentifier, $prefix) { @@ -232,7 +232,7 @@ class Configuration * * @param string $accessToken Token for OAuth * - * @return Configuration + * @return $this */ public function setAccessToken($accessToken) { @@ -255,7 +255,7 @@ class Configuration * * @param string $username Username for HTTP basic authentication * - * @return Configuration + * @return $this */ public function setUsername($username) { @@ -278,7 +278,7 @@ class Configuration * * @param string $password Password for HTTP basic authentication * - * @return Configuration + * @return $this */ public function setPassword($password) { @@ -302,7 +302,8 @@ class Configuration * @param string $headerName header name (e.g. Token) * @param string $headerValue header value (e.g. 1z8wp3) * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function addDefaultHeader($headerName, $headerValue) { @@ -329,11 +330,12 @@ class Configuration * * @param string $headerName the header to delete * - * @return Configuration + * @return $this */ public function deleteDefaultHeader($headerName) { unset($this->defaultHeaders[$headerName]); + return $this; } /** @@ -341,7 +343,7 @@ class Configuration * * @param string $host Host * - * @return Configuration + * @return $this */ public function setHost($host) { @@ -364,7 +366,8 @@ class Configuration * * @param string $userAgent the user agent of the api client * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setUserAgent($userAgent) { @@ -391,7 +394,8 @@ class Configuration * * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setCurlTimeout($seconds) { @@ -418,7 +422,8 @@ class Configuration * * @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout] * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setCurlConnectTimeout($seconds) { @@ -446,7 +451,7 @@ class Configuration * * @param string $proxyHost HTTP Proxy URL * - * @return ApiClient + * @return $this */ public function setCurlProxyHost($proxyHost) { @@ -469,7 +474,7 @@ class Configuration * * @param integer $proxyPort HTTP Proxy Port * - * @return ApiClient + * @return $this */ public function setCurlProxyPort($proxyPort) { @@ -492,7 +497,7 @@ class Configuration * * @param integer $proxyType HTTP Proxy Type * - * @return ApiClient + * @return $this */ public function setCurlProxyType($proxyType) { @@ -515,7 +520,7 @@ class Configuration * * @param string $proxyUser HTTP Proxy User * - * @return ApiClient + * @return $this */ public function setCurlProxyUser($proxyUser) { @@ -538,7 +543,7 @@ class Configuration * * @param string $proxyPassword HTTP Proxy Password * - * @return ApiClient + * @return $this */ public function setCurlProxyPassword($proxyPassword) { @@ -561,7 +566,7 @@ class Configuration * * @param bool $debug Debug flag * - * @return Configuration + * @return $this */ public function setDebug($debug) { @@ -584,7 +589,7 @@ class Configuration * * @param string $debugFile Debug file * - * @return Configuration + * @return $this */ public function setDebugFile($debugFile) { @@ -607,7 +612,7 @@ class Configuration * * @param string $tempFolderPath Temp folder path * - * @return Configuration + * @return $this */ public function setTempFolderPath($tempFolderPath) { @@ -630,7 +635,7 @@ class Configuration * * @param boolean $sslVerification True if the certificate should be validated, false otherwise * - * @return Configuration + * @return $this */ public function setSSLVerification($sslVerification) { @@ -683,7 +688,7 @@ class Configuration { $report = 'PHP SDK ({{invokerPackage}}) Debug Report:' . PHP_EOL; $report .= ' OS: ' . php_uname() . PHP_EOL; - $report .= ' PHP Version: ' . phpversion() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' OpenAPI Spec Version: {{version}}' . PHP_EOL; {{#artifactVersion}} $report .= ' SDK Package Version: {{artifactVersion}}' . PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php index cc6875156cf..4bd9a69cdd8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php @@ -39,7 +39,7 @@ */ class Configuration { - private static $defaultConfiguration = null; + private static $defaultConfiguration; /** * Associate array to store API key(s) @@ -109,7 +109,7 @@ class Configuration * * @var string */ - protected $userAgent = "Swagger-Codegen/1.0.0/php"; + protected $userAgent = 'Swagger-Codegen/1.0.0/php'; /** * Debug switch (default set to false) @@ -191,7 +191,7 @@ public function __construct() * @param string $apiKeyIdentifier API key identifier (authentication scheme) * @param string $key API key or token * - * @return Configuration + * @return $this */ public function setApiKey($apiKeyIdentifier, $key) { @@ -217,7 +217,7 @@ public function getApiKey($apiKeyIdentifier) * @param string $apiKeyIdentifier API key identifier (authentication scheme) * @param string $prefix API key prefix, e.g. Bearer * - * @return Configuration + * @return $this */ public function setApiKeyPrefix($apiKeyIdentifier, $prefix) { @@ -242,7 +242,7 @@ public function getApiKeyPrefix($apiKeyIdentifier) * * @param string $accessToken Token for OAuth * - * @return Configuration + * @return $this */ public function setAccessToken($accessToken) { @@ -265,7 +265,7 @@ public function getAccessToken() * * @param string $username Username for HTTP basic authentication * - * @return Configuration + * @return $this */ public function setUsername($username) { @@ -288,7 +288,7 @@ public function getUsername() * * @param string $password Password for HTTP basic authentication * - * @return Configuration + * @return $this */ public function setPassword($password) { @@ -312,7 +312,8 @@ public function getPassword() * @param string $headerName header name (e.g. Token) * @param string $headerValue header value (e.g. 1z8wp3) * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function addDefaultHeader($headerName, $headerValue) { @@ -339,11 +340,12 @@ public function getDefaultHeaders() * * @param string $headerName the header to delete * - * @return Configuration + * @return $this */ public function deleteDefaultHeader($headerName) { unset($this->defaultHeaders[$headerName]); + return $this; } /** @@ -351,7 +353,7 @@ public function deleteDefaultHeader($headerName) * * @param string $host Host * - * @return Configuration + * @return $this */ public function setHost($host) { @@ -374,7 +376,8 @@ public function getHost() * * @param string $userAgent the user agent of the api client * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setUserAgent($userAgent) { @@ -401,7 +404,8 @@ public function getUserAgent() * * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setCurlTimeout($seconds) { @@ -428,7 +432,8 @@ public function getCurlTimeout() * * @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout] * - * @return Configuration + * @throws \InvalidArgumentException + * @return $this */ public function setCurlConnectTimeout($seconds) { @@ -456,7 +461,7 @@ public function getCurlConnectTimeout() * * @param string $proxyHost HTTP Proxy URL * - * @return ApiClient + * @return $this */ public function setCurlProxyHost($proxyHost) { @@ -479,7 +484,7 @@ public function getCurlProxyHost() * * @param integer $proxyPort HTTP Proxy Port * - * @return ApiClient + * @return $this */ public function setCurlProxyPort($proxyPort) { @@ -502,7 +507,7 @@ public function getCurlProxyPort() * * @param integer $proxyType HTTP Proxy Type * - * @return ApiClient + * @return $this */ public function setCurlProxyType($proxyType) { @@ -525,7 +530,7 @@ public function getCurlProxyType() * * @param string $proxyUser HTTP Proxy User * - * @return ApiClient + * @return $this */ public function setCurlProxyUser($proxyUser) { @@ -548,7 +553,7 @@ public function getCurlProxyUser() * * @param string $proxyPassword HTTP Proxy Password * - * @return ApiClient + * @return $this */ public function setCurlProxyPassword($proxyPassword) { @@ -571,7 +576,7 @@ public function getCurlProxyPassword() * * @param bool $debug Debug flag * - * @return Configuration + * @return $this */ public function setDebug($debug) { @@ -594,7 +599,7 @@ public function getDebug() * * @param string $debugFile Debug file * - * @return Configuration + * @return $this */ public function setDebugFile($debugFile) { @@ -617,7 +622,7 @@ public function getDebugFile() * * @param string $tempFolderPath Temp folder path * - * @return Configuration + * @return $this */ public function setTempFolderPath($tempFolderPath) { @@ -640,7 +645,7 @@ public function getTempFolderPath() * * @param boolean $sslVerification True if the certificate should be validated, false otherwise * - * @return Configuration + * @return $this */ public function setSSLVerification($sslVerification) { @@ -693,7 +698,7 @@ public static function toDebugReport() { $report = 'PHP SDK (Swagger\Client) Debug Report:' . PHP_EOL; $report .= ' OS: ' . php_uname() . PHP_EOL; - $report .= ' PHP Version: ' . phpversion() . PHP_EOL; + $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; $report .= ' OpenAPI Spec Version: 1.0.0' . PHP_EOL; $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;