[PHP] Made coding standard more consistent across template files

This commit is contained in:
Kim Sondrup
2016-05-13 01:47:59 +02:00
parent 6bb953d0aa
commit b2f5d8c060
9 changed files with 59 additions and 22 deletions

View File

@@ -55,18 +55,21 @@ class ApiClient
/** /**
* Configuration * Configuration
*
* @var Configuration * @var Configuration
*/ */
protected $config; protected $config;
/** /**
* Object Serializer * Object Serializer
*
* @var ObjectSerializer * @var ObjectSerializer
*/ */
protected $serializer; protected $serializer;
/** /**
* Constructor of the class * Constructor of the class
*
* @param Configuration $config config for this ApiClient * @param Configuration $config config for this ApiClient
*/ */
public function __construct(\{{invokerPackage}}\Configuration $config = null) public function __construct(\{{invokerPackage}}\Configuration $config = null)
@@ -81,6 +84,7 @@ class ApiClient
/** /**
* Get the config * Get the config
*
* @return Configuration * @return Configuration
*/ */
public function getConfig() public function getConfig()
@@ -90,6 +94,7 @@ class ApiClient
/** /**
* Get the serializer * Get the serializer
*
* @return ObjectSerializer * @return ObjectSerializer
*/ */
public function getSerializer() public function getSerializer()
@@ -99,7 +104,9 @@ class ApiClient
/** /**
* Get API key (with prefix if set) * Get API key (with prefix if set)
*
* @param string $apiKeyIdentifier name of apikey * @param string $apiKeyIdentifier name of apikey
*
* @return string API key with the prefix * @return string API key with the prefix
*/ */
public function getApiKeyWithPrefix($apiKeyIdentifier) public function getApiKeyWithPrefix($apiKeyIdentifier)
@@ -122,12 +129,14 @@ class ApiClient
/** /**
* Make the HTTP call (Sync) * Make the HTTP call (Sync)
*
* @param string $resourcePath path to method endpoint * @param string $resourcePath path to method endpoint
* @param string $method method to call * @param string $method method to call
* @param array $queryParams parameters to be place in query URL * @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body * @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header * @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint * @param string $responseType expected response type of the endpoint
*
* @throws \{{invokerPackage}}\ApiException on a non 2xx response * @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed * @return mixed
*/ */
@@ -171,7 +180,7 @@ class ApiClient
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
} }
if (! empty($queryParams)) { if (!empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams)); $url = ($url . '?' . http_build_query($queryParams));
} }
@@ -216,7 +225,7 @@ class ApiClient
// Make the request // Make the request
$response = curl_exec($curl); $response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size)); $http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size); $http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl); $response_info = curl_getinfo($curl);
@@ -295,7 +304,7 @@ class ApiClient
* *
* @return string[] Array of HTTP response heaers * @return string[] Array of HTTP response heaers
*/ */
protected function http_parse_headers($raw_headers) protected function httpParseHeaders($raw_headers)
{ {
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array(); $headers = array();

View File

@@ -48,24 +48,28 @@ class ApiException extends Exception
/** /**
* The HTTP body of the server response either as Json or string. * The HTTP body of the server response either as Json or string.
*
* @var mixed * @var mixed
*/ */
protected $responseBody; protected $responseBody;
/** /**
* The HTTP header of the server response. * The HTTP header of the server response.
*
* @var string[] * @var string[]
*/ */
protected $responseHeaders; protected $responseHeaders;
/** /**
* The deserialized response object * The deserialized response object
*
* @var $responseObject; * @var $responseObject;
*/ */
protected $responseObject; protected $responseObject;
/** /**
* Constructor * Constructor
*
* @param string $message Error message * @param string $message Error message
* @param int $code HTTP status code * @param int $code HTTP status code
* @param string $responseHeaders HTTP response header * @param string $responseHeaders HTTP response header
@@ -100,7 +104,9 @@ class ApiException extends Exception
/** /**
* Sets the deseralized response object (during deserialization) * Sets the deseralized response object (during deserialization)
*
* @param mixed $obj Deserialized response object * @param mixed $obj Deserialized response object
*
* @return void * @return void
*/ */
public function setResponseObject($obj) public function setResponseObject($obj)

View File

@@ -52,12 +52,14 @@ use \{{invokerPackage}}\ObjectSerializer;
/** /**
* API Client * API Client
*
* @var \{{invokerPackage}}\ApiClient instance of the ApiClient * @var \{{invokerPackage}}\ApiClient instance of the ApiClient
*/ */
protected $apiClient; protected $apiClient;
/** /**
* Constructor * Constructor
*
* @param \{{invokerPackage}}\ApiClient|null $apiClient The api client to use * @param \{{invokerPackage}}\ApiClient|null $apiClient The api client to use
*/ */
function __construct(\{{invokerPackage}}\ApiClient $apiClient = null) function __construct(\{{invokerPackage}}\ApiClient $apiClient = null)
@@ -72,6 +74,7 @@ use \{{invokerPackage}}\ObjectSerializer;
/** /**
* Get API client * Get API client
*
* @return \{{invokerPackage}}\ApiClient get the API client * @return \{{invokerPackage}}\ApiClient get the API client
*/ */
public function getApiClient() public function getApiClient()
@@ -81,7 +84,9 @@ use \{{invokerPackage}}\ObjectSerializer;
/** /**
* Set the API client * Set the API client
*
* @param \{{invokerPackage}}\ApiClient $apiClient set the API client * @param \{{invokerPackage}}\ApiClient $apiClient set the API client
*
* @return {{classname}} * @return {{classname}}
*/ */
public function setApiClient(\{{invokerPackage}}\ApiClient $apiClient) public function setApiClient(\{{invokerPackage}}\ApiClient $apiClient)
@@ -92,28 +97,30 @@ use \{{invokerPackage}}\ObjectSerializer;
{{#operation}} {{#operation}}
/** /**
* {{{operationId}}} * Operation {{{operationId}}}
* *
* {{{summary}}} * {{{summary}}}
* *
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{/allParams}} *
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \{{invokerPackage}}\ApiException on non-2xx response
*/ */
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{ {
list($response) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); list($response) = $this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
return $response; return $response;
} }
/** /**
* {{{operationId}}}WithHttpInfo * Operation {{{operationId}}}WithHttpInfo
* *
* {{{summary}}} * {{{summary}}}
* *
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) {{/allParams}} *
* @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \{{invokerPackage}}\ApiException on non-2xx response
*/ */
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})

View File

@@ -53,14 +53,16 @@ use \{{invokerPackage}}\ObjectSerializer;
/** /**
* Setup before running each test case * Setup before running each test case
*/ */
public static function setUpBeforeClass() { public static function setUpBeforeClass()
{
} }
/** /**
* Clean up after running each test case * Clean up after running each test case
*/ */
public static function tearDownAfterClass() { public static function tearDownAfterClass()
{
} }
@@ -71,7 +73,8 @@ use \{{invokerPackage}}\ObjectSerializer;
* {{{summary}}} * {{{summary}}}
* *
*/ */
public function test_{{operationId}}() { public function test_{{operationId}}()
{
} }
{{/operation}} {{/operation}}

View File

@@ -9,6 +9,7 @@
* new \{{invokerPackage}}\Baz\Qux; * new \{{invokerPackage}}\Baz\Qux;
* *
* @param string $class The fully-qualified class name. * @param string $class The fully-qualified class name.
*
* @return void * @return void
*/ */
spl_autoload_register(function ($class) { spl_autoload_register(function ($class) {

View File

@@ -103,7 +103,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
); );
static function getters() { static function getters()
{
return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters; return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
} }
@@ -115,7 +116,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
* Gets allowable values of the enum * Gets allowable values of the enum
* @return string[] * @return string[]
*/ */
public function {{getter}}AllowableValues() { public function {{getter}}AllowableValues()
{
return [ return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}} {{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}} {{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -7,7 +7,8 @@ class {{classname}} {
* Gets allowable values of the enum * Gets allowable values of the enum
* @return string[] * @return string[]
*/ */
public function {{getter}}AllowableValues() { public function {{getter}}AllowableValues()
{
return [ return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}} {{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}} {{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -9,7 +9,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
); );
static function swaggerTypes() { static function swaggerTypes()
{
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}}; return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
} }
@@ -22,7 +23,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
); );
static function attributeMap() { static function attributeMap()
{
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap; return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
} }
@@ -35,7 +37,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
); );
static function setters() { static function setters()
{
return {{#parent}}parent::setters() + {{/parent}}self::$setters; return {{#parent}}parent::setters() + {{/parent}}self::$setters;
} }
@@ -48,7 +51,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}} {{/hasMore}}{{/vars}}
); );
static function getters() { static function getters()
{
return {{#parent}}parent::getters() + {{/parent}}self::$getters; return {{#parent}}parent::getters() + {{/parent}}self::$getters;
} }
@@ -60,7 +64,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
* Gets allowable values of the enum * Gets allowable values of the enum
* @return string[] * @return string[]
*/ */
public function {{getter}}AllowableValues() { public function {{getter}}AllowableValues()
{
return [ return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}} {{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}} {{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -51,21 +51,24 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
/** /**
* Setup before running each test case * Setup before running each test case
*/ */
public static function setUpBeforeClass() { public static function setUpBeforeClass()
{
} }
/** /**
* Clean up after running each test case * Clean up after running each test case
*/ */
public static function tearDownAfterClass() { public static function tearDownAfterClass()
{
} }
/** /**
* Test {{classname}} * Test {{classname}}
*/ */
public function test{{classname}}() { public function test{{classname}}()
{
} }