From 2c59f1dc8cda32e173694d650d9498f047eb0180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Karlovi=C4=87?= Date: Sun, 27 Sep 2020 11:42:51 +0200 Subject: [PATCH] [php] Small tweaks for php generator (#7376) --- .../main/resources/php/ApiException.mustache | 14 ++-- .../main/resources/php/Configuration.mustache | 17 +++-- .../resources/php/HeaderSelector.mustache | 2 +- .../resources/php/ObjectSerializer.mustache | 38 +++++++--- .../src/main/resources/php/api.mustache | 8 +- .../src/main/resources/php/api_test.mustache | 4 +- .../src/main/resources/php/composer.mustache | 2 +- .../src/main/resources/php/model.mustache | 5 ++ .../main/resources/php/model_generic.mustache | 16 ++-- .../main/resources/php/model_test.mustache | 6 +- .../php/OpenAPIClient-php/composer.json | 2 +- .../lib/Api/AnotherFakeApi.php | 8 +- .../OpenAPIClient-php/lib/Api/DefaultApi.php | 8 +- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 8 +- .../lib/Api/FakeClassnameTags123Api.php | 8 +- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 8 +- .../OpenAPIClient-php/lib/Api/StoreApi.php | 8 +- .../php/OpenAPIClient-php/lib/Api/UserApi.php | 8 +- .../OpenAPIClient-php/lib/ApiException.php | 14 ++-- .../OpenAPIClient-php/lib/Configuration.php | 17 +++-- .../OpenAPIClient-php/lib/HeaderSelector.php | 2 +- .../lib/Model/AdditionalPropertiesClass.php | 23 +++--- .../OpenAPIClient-php/lib/Model/Animal.php | 23 +++--- .../lib/Model/ApiResponse.php | 27 ++++--- .../lib/Model/ArrayOfArrayOfNumberOnly.php | 19 +++-- .../lib/Model/ArrayOfNumberOnly.php | 19 +++-- .../OpenAPIClient-php/lib/Model/ArrayTest.php | 27 ++++--- .../lib/Model/Capitalization.php | 39 +++++----- .../php/OpenAPIClient-php/lib/Model/Cat.php | 19 +++-- .../OpenAPIClient-php/lib/Model/CatAllOf.php | 19 +++-- .../OpenAPIClient-php/lib/Model/Category.php | 23 +++--- .../lib/Model/ClassModel.php | 19 +++-- .../OpenAPIClient-php/lib/Model/Client.php | 19 +++-- .../php/OpenAPIClient-php/lib/Model/Dog.php | 19 +++-- .../OpenAPIClient-php/lib/Model/DogAllOf.php | 19 +++-- .../lib/Model/EnumArrays.php | 23 +++--- .../OpenAPIClient-php/lib/Model/EnumTest.php | 47 ++++++------ .../php/OpenAPIClient-php/lib/Model/File.php | 19 +++-- .../lib/Model/FileSchemaTestClass.php | 23 +++--- .../php/OpenAPIClient-php/lib/Model/Foo.php | 19 +++-- .../lib/Model/FormatTest.php | 75 ++++++++++--------- .../lib/Model/HasOnlyReadOnly.php | 23 +++--- .../lib/Model/HealthCheckResult.php | 19 +++-- .../lib/Model/InlineObject.php | 23 +++--- .../lib/Model/InlineObject1.php | 23 +++--- .../lib/Model/InlineObject2.php | 23 +++--- .../lib/Model/InlineObject3.php | 71 ++++++++++-------- .../lib/Model/InlineObject4.php | 23 +++--- .../lib/Model/InlineObject5.php | 23 +++--- .../lib/Model/InlineResponseDefault.php | 19 +++-- .../OpenAPIClient-php/lib/Model/MapTest.php | 31 ++++---- ...PropertiesAndAdditionalPropertiesClass.php | 27 ++++--- .../lib/Model/Model200Response.php | 23 +++--- .../OpenAPIClient-php/lib/Model/ModelList.php | 19 +++-- .../lib/Model/ModelReturn.php | 19 +++-- .../php/OpenAPIClient-php/lib/Model/Name.php | 31 ++++---- .../lib/Model/NullableClass.php | 63 +++++++++------- .../lib/Model/NumberOnly.php | 19 +++-- .../php/OpenAPIClient-php/lib/Model/Order.php | 39 +++++----- .../lib/Model/OuterComposite.php | 27 ++++--- .../php/OpenAPIClient-php/lib/Model/Pet.php | 39 +++++----- .../lib/Model/ReadOnlyFirst.php | 23 +++--- .../lib/Model/SpecialModelName.php | 19 +++-- .../php/OpenAPIClient-php/lib/Model/Tag.php | 23 +++--- .../php/OpenAPIClient-php/lib/Model/User.php | 47 ++++++------ .../lib/ObjectSerializer.php | 38 +++++++--- 66 files changed, 866 insertions(+), 591 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php/ApiException.mustache b/modules/openapi-generator/src/main/resources/php/ApiException.mustache index 185be1a0a0a..dcba96b0e43 100644 --- a/modules/openapi-generator/src/main/resources/php/ApiException.mustache +++ b/modules/openapi-generator/src/main/resources/php/ApiException.mustache @@ -34,7 +34,7 @@ class ApiException extends Exception /** * The HTTP body of the server response either as Json or string. * - * @var mixed + * @var \stdClass|string|null */ protected $responseBody; @@ -48,17 +48,17 @@ class ApiException extends Exception /** * The deserialized response object * - * @var $responseObject; + * @var \stdClass|string|null */ protected $responseObject; /** * Constructor * - * @param string $message Error message - * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header - * @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string + * @param string $message Error message + * @param int $code HTTP status code + * @param string[]|null $responseHeaders HTTP response header + * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) { @@ -80,7 +80,7 @@ class ApiException extends Exception /** * Gets the HTTP body of the server response either as Json or string * - * @return mixed HTTP body of the server response either as \stdClass or string + * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string */ public function getResponseBody() { diff --git a/modules/openapi-generator/src/main/resources/php/Configuration.mustache b/modules/openapi-generator/src/main/resources/php/Configuration.mustache index 6415657dfdb..fa4f1ebecee 100644 --- a/modules/openapi-generator/src/main/resources/php/Configuration.mustache +++ b/modules/openapi-generator/src/main/resources/php/Configuration.mustache @@ -29,6 +29,9 @@ namespace {{invokerPackage}}; */ class Configuration { + /** + * @var Configuration + */ private static $defaultConfiguration; /** @@ -128,7 +131,7 @@ class Configuration * * @param string $apiKeyIdentifier API key identifier (authentication scheme) * - * @return string API key or token + * @return null|string API key or token */ public function getApiKey($apiKeyIdentifier) { @@ -154,7 +157,7 @@ class Configuration * * @param string $apiKeyIdentifier API key identifier (authentication scheme) * - * @return string + * @return null|string */ public function getApiKeyPrefix($apiKeyIdentifier) { @@ -400,7 +403,7 @@ class Configuration * * @param string $apiKeyIdentifier name of apikey * - * @return string API key with the prefix + * @return null|string API key with the prefix */ public function getApiKeyWithPrefix($apiKeyIdentifier) { @@ -423,7 +426,7 @@ class Configuration /** * Returns an array of host settings * - * @return an array of host settings + * @return array an array of host settings */ public function getHostSettings() { @@ -461,9 +464,9 @@ class Configuration /** * Returns URL based on the index and variables * - * @param index array index of the host settings - * @param variables hash of variable and the corresponding value (optional) - * @return URL based on host settings + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings */ public function getHostFromSettings($index, $variables = null) { diff --git a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache index 2fdc0ab204f..5f8e6558727 100644 --- a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache +++ b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache @@ -66,7 +66,7 @@ class HeaderSelector * * @param string[] $accept Array of header * - * @return string Accept (e.g. application/json) + * @return null|string Accept (e.g. application/json) */ private function selectAcceptHeader($accept) { diff --git a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache index 2694de44fe7..31dd9fc3376 100644 --- a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache @@ -51,20 +51,26 @@ class ObjectSerializer * @param string $type the OpenAPIToolsType of the data * @param string $format the format of the OpenAPITools type of the data * - * @return string|object serialized form of $data + * @return scalar|object|array|null serialized form of $data */ public static function sanitizeForSerialization($data, $type = null, $format = null) { if (is_scalar($data) || null === $data) { return $data; - } elseif ($data instanceof \DateTime) { + } + + if ($data instanceof \DateTime) { return ($format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat); - } elseif (is_array($data)) { + } + + if (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } return $data; - } elseif (is_object($data)) { + } + + if (is_object($data)) { $values = []; if ($data instanceof ModelInterface) { $formats = $data::openAPIFormats(); @@ -250,7 +256,9 @@ class ObjectSerializer { if (null === $data) { return null; - } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + } + + if (strcasecmp(substr($class, -2), '[]') === 0) { $data = is_string($data) ? json_decode($data) : $data; if (!is_array($data)) { @@ -263,7 +271,9 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass, null); } return $values; - } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + } + + if (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] $data = is_string($data) ? json_decode($data) : $data; settype($data, 'array'); $inner = substr($class, 4, -1); @@ -276,10 +286,14 @@ class ObjectSerializer } } return $deserialized; - } elseif ($class === 'object') { + } + + if ($class === 'object') { settype($data, 'array'); return $data; - } elseif ($class === '\DateTime') { + } + + if ($class === '\DateTime') { // Some API's return an invalid, empty string as a // date-time property. DateTime::__construct() will return // the current time for empty input which is probably not @@ -291,10 +305,14 @@ class ObjectSerializer } else { return null; } - } elseif (in_array($class, [{{&primitives}}], true)) { + } + + if (in_array($class, [{{&primitives}}], true)) { settype($data, $class); return $data; - } elseif ($class === '\SplFileObject') { + } + + if ($class === '\SplFileObject') { /** @var \Psr\Http\Message\StreamInterface $data */ // determine file name diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 9ec54edeb0d..a80d08486bd 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -80,17 +80,17 @@ use {{invokerPackage}}\ObjectSerializer; /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/modules/openapi-generator/src/main/resources/php/api_test.mustache b/modules/openapi-generator/src/main/resources/php/api_test.mustache index e8c8905c961..f46fdbac144 100644 --- a/modules/openapi-generator/src/main/resources/php/api_test.mustache +++ b/modules/openapi-generator/src/main/resources/php/api_test.mustache @@ -16,7 +16,7 @@ * Please update the test case below to test the endpoint. */ -namespace {{invokerPackage}}; +namespace {{invokerPackage}}\Test\Api; use \{{invokerPackage}}\Configuration; use \{{invokerPackage}}\ApiException; @@ -71,6 +71,8 @@ use PHPUnit\Framework\TestCase; */ public function test{{vendorExtensions.x-test-operation-id}}() { + // TODO: implement + $this->markTestIncomplete('Not implemented'); } {{/operation}} } diff --git a/modules/openapi-generator/src/main/resources/php/composer.mustache b/modules/openapi-generator/src/main/resources/php/composer.mustache index fdfd0e2438a..265bd713d52 100644 --- a/modules/openapi-generator/src/main/resources/php/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php/composer.mustache @@ -36,6 +36,6 @@ "psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" } }, "autoload-dev": { - "psr-4": { "{{escapedInvokerPackage}}\\" : "{{testBasePath}}/" } + "psr-4": { "{{escapedInvokerPackage}}\\Test\\" : "{{testBasePath}}/" } } } diff --git a/modules/openapi-generator/src/main/resources/php/model.mustache b/modules/openapi-generator/src/main/resources/php/model.mustache index 45157dd0520..3c0b819822c 100644 --- a/modules/openapi-generator/src/main/resources/php/model.mustache +++ b/modules/openapi-generator/src/main/resources/php/model.mustache @@ -38,6 +38,11 @@ use \{{invokerPackage}}\ObjectSerializer; * @package {{invokerPackage}} * @author OpenAPI Generator team * @link https://openapi-generator.tech +{{^isEnum}} + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null +{{/isEnum}} */ {{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}} {{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/php/model_generic.mustache b/modules/openapi-generator/src/main/resources/php/model_generic.mustache index adc72e54879..40802715829 100644 --- a/modules/openapi-generator/src/main/resources/php/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/php/model_generic.mustache @@ -1,6 +1,6 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess{{/parentSchema}} { - const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}}; + public const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}}; /** * The original name of the model. @@ -23,6 +23,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ {{#vars}}'{{name}}' => {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}{{#hasMore}}, @@ -161,7 +163,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa {{/parentSchema}} {{#vars}} - $this->container['{{name}}'] = isset($data['{{name}}']) ? $data['{{name}}'] : {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}; + $this->container['{{name}}'] = $data['{{name}}'] ?? {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}; {{/vars}} {{#discriminator}} @@ -278,7 +280,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @param {{dataType}}{{^required}}|null{{/required}} ${{name}}{{#description}} {{{description}}}{{/description}}{{^description}} {{{name}}}{{/description}} * - * @return $this + * @return self */ public function {{setter}}(${{name}}) { @@ -362,18 +364,18 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/modules/openapi-generator/src/main/resources/php/model_test.mustache b/modules/openapi-generator/src/main/resources/php/model_test.mustache index 848a24b5492..af9df8ae19b 100644 --- a/modules/openapi-generator/src/main/resources/php/model_test.mustache +++ b/modules/openapi-generator/src/main/resources/php/model_test.mustache @@ -19,7 +19,7 @@ * Please update the test case below to test the model. */ -namespace {{invokerPackage}}; +namespace {{invokerPackage}}\Test\Model; use PHPUnit\Framework\TestCase; @@ -68,6 +68,8 @@ class {{classname}}Test extends TestCase */ public function test{{classname}}() { + // TODO: implement + $this->markTestIncomplete('Not implemented'); } {{#vars}} @@ -76,6 +78,8 @@ class {{classname}}Test extends TestCase */ public function testProperty{{nameInCamelCase}}() { + // TODO: implement + $this->markTestIncomplete('Not implemented'); } {{/vars}} } diff --git a/samples/client/petstore/php/OpenAPIClient-php/composer.json b/samples/client/petstore/php/OpenAPIClient-php/composer.json index 823e9f92a7b..08efaa27b92 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/composer.json +++ b/samples/client/petstore/php/OpenAPIClient-php/composer.json @@ -33,6 +33,6 @@ "psr-4": { "OpenAPI\\Client\\" : "lib/" } }, "autoload-dev": { - "psr-4": { "OpenAPI\\Client\\" : "test/" } + "psr-4": { "OpenAPI\\Client\\Test\\" : "test/" } } } diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php index dd8f5426398..b328c2627c4 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -90,17 +90,17 @@ class AnotherFakeApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php index 033120cc557..00c5f27ccee 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -90,17 +90,17 @@ class DefaultApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 026ce251fce..0b99c8e9aab 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -90,17 +90,17 @@ class FakeApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php index a17dc5fd672..094e5e91498 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -90,17 +90,17 @@ class FakeClassnameTags123Api /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 6d8554cce90..e92065f162b 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -90,17 +90,17 @@ class PetApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php index d05718f7494..d4e853de9c3 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -90,17 +90,17 @@ class StoreApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index a9fede94b86..5e26aa165b3 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -90,17 +90,17 @@ class UserApi /** * Set the host index * - * @param int Host index (required) + * @param int $hostIndex Host index (required) */ - public function setHostIndex($host_index) + public function setHostIndex($hostIndex) { - $this->hostIndex = $host_index; + $this->hostIndex = $hostIndex; } /** * Get the host index * - * @return Host index + * @return int Host index */ public function getHostIndex() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php index f041f3e7723..db8899ae4e7 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php @@ -44,7 +44,7 @@ class ApiException extends Exception /** * The HTTP body of the server response either as Json or string. * - * @var mixed + * @var \stdClass|string|null */ protected $responseBody; @@ -58,17 +58,17 @@ class ApiException extends Exception /** * The deserialized response object * - * @var $responseObject; + * @var \stdClass|string|null */ protected $responseObject; /** * Constructor * - * @param string $message Error message - * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header - * @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string + * @param string $message Error message + * @param int $code HTTP status code + * @param string[]|null $responseHeaders HTTP response header + * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) { @@ -90,7 +90,7 @@ class ApiException extends Exception /** * Gets the HTTP body of the server response either as Json or string * - * @return mixed HTTP body of the server response either as \stdClass or string + * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string */ public function getResponseBody() { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php index 874da6a02b0..1163536b36e 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php @@ -39,6 +39,9 @@ namespace OpenAPI\Client; */ class Configuration { + /** + * @var Configuration + */ private static $defaultConfiguration; /** @@ -138,7 +141,7 @@ class Configuration * * @param string $apiKeyIdentifier API key identifier (authentication scheme) * - * @return string API key or token + * @return null|string API key or token */ public function getApiKey($apiKeyIdentifier) { @@ -164,7 +167,7 @@ class Configuration * * @param string $apiKeyIdentifier API key identifier (authentication scheme) * - * @return string + * @return null|string */ public function getApiKeyPrefix($apiKeyIdentifier) { @@ -407,7 +410,7 @@ class Configuration * * @param string $apiKeyIdentifier name of apikey * - * @return string API key with the prefix + * @return null|string API key with the prefix */ public function getApiKeyWithPrefix($apiKeyIdentifier) { @@ -430,7 +433,7 @@ class Configuration /** * Returns an array of host settings * - * @return an array of host settings + * @return array an array of host settings */ public function getHostSettings() { @@ -478,9 +481,9 @@ class Configuration /** * Returns URL based on the index and variables * - * @param index array index of the host settings - * @param variables hash of variable and the corresponding value (optional) - * @return URL based on host settings + * @param int $index index of the host settings + * @param array|null $variables hash of variable and the corresponding value (optional) + * @return string URL based on host settings */ public function getHostFromSettings($index, $variables = null) { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php index 25a92414028..eca0ee2693f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -76,7 +76,7 @@ class HeaderSelector * * @param string[] $accept Array of header * - * @return string Accept (e.g. application/json) + * @return null|string Accept (e.g. application/json) */ private function selectAcceptHeader($accept) { diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php index 2811e834099..023ecf32ec2 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'map_property' => null, @@ -182,8 +187,8 @@ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['map_property'] = isset($data['map_property']) ? $data['map_property'] : null; - $this->container['map_of_map_property'] = isset($data['map_of_map_property']) ? $data['map_of_map_property'] : null; + $this->container['map_property'] = $data['map_property'] ?? null; + $this->container['map_of_map_property'] = $data['map_of_map_property'] ?? null; } /** @@ -225,7 +230,7 @@ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess * * @param map[string,string]|null $map_property map_property * - * @return $this + * @return self */ public function setMapProperty($map_property) { @@ -249,7 +254,7 @@ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess * * @param map[string,map[string,string]]|null $map_of_map_property map_of_map_property * - * @return $this + * @return self */ public function setMapOfMapProperty($map_of_map_property) { @@ -274,18 +279,18 @@ class AdditionalPropertiesClass implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php index 145ecc65ac0..aad9487cc94 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Animal implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = 'class_name'; + public const DISCRIMINATOR = 'class_name'; /** * The original name of the model. @@ -65,6 +68,8 @@ class Animal implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'class_name' => null, @@ -182,8 +187,8 @@ class Animal implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['class_name'] = isset($data['class_name']) ? $data['class_name'] : null; - $this->container['color'] = isset($data['color']) ? $data['color'] : 'red'; + $this->container['class_name'] = $data['class_name'] ?? null; + $this->container['color'] = $data['color'] ?? 'red'; // Initialize discriminator property with the model name. $this->container['class_name'] = static::$openAPIModelName; @@ -231,7 +236,7 @@ class Animal implements ModelInterface, ArrayAccess * * @param string $class_name class_name * - * @return $this + * @return self */ public function setClassName($class_name) { @@ -255,7 +260,7 @@ class Animal implements ModelInterface, ArrayAccess * * @param string|null $color color * - * @return $this + * @return self */ public function setColor($color) { @@ -280,18 +285,18 @@ class Animal implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php index 43244c474ee..d21fa35621f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ApiResponse implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -66,6 +69,8 @@ class ApiResponse implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'code' => 'int32', @@ -187,9 +192,9 @@ class ApiResponse implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['code'] = isset($data['code']) ? $data['code'] : null; - $this->container['type'] = isset($data['type']) ? $data['type'] : null; - $this->container['message'] = isset($data['message']) ? $data['message'] : null; + $this->container['code'] = $data['code'] ?? null; + $this->container['type'] = $data['type'] ?? null; + $this->container['message'] = $data['message'] ?? null; } /** @@ -231,7 +236,7 @@ class ApiResponse implements ModelInterface, ArrayAccess * * @param int|null $code code * - * @return $this + * @return self */ public function setCode($code) { @@ -255,7 +260,7 @@ class ApiResponse implements ModelInterface, ArrayAccess * * @param string|null $type type * - * @return $this + * @return self */ public function setType($type) { @@ -279,7 +284,7 @@ class ApiResponse implements ModelInterface, ArrayAccess * * @param string|null $message message * - * @return $this + * @return self */ public function setMessage($message) { @@ -304,18 +309,18 @@ class ApiResponse implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php index a0f5ccfd05a..4deeb067f68 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'array_array_number' => null @@ -177,7 +182,7 @@ class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['array_array_number'] = isset($data['array_array_number']) ? $data['array_array_number'] : null; + $this->container['array_array_number'] = $data['array_array_number'] ?? null; } /** @@ -219,7 +224,7 @@ class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess * * @param float[][]|null $array_array_number array_array_number * - * @return $this + * @return self */ public function setArrayArrayNumber($array_array_number) { @@ -244,18 +249,18 @@ class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php index 483ea4fbd9e..cf6fe89d16e 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ArrayOfNumberOnly implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class ArrayOfNumberOnly implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'array_number' => null @@ -177,7 +182,7 @@ class ArrayOfNumberOnly implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['array_number'] = isset($data['array_number']) ? $data['array_number'] : null; + $this->container['array_number'] = $data['array_number'] ?? null; } /** @@ -219,7 +224,7 @@ class ArrayOfNumberOnly implements ModelInterface, ArrayAccess * * @param float[]|null $array_number array_number * - * @return $this + * @return self */ public function setArrayNumber($array_number) { @@ -244,18 +249,18 @@ class ArrayOfNumberOnly implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php index bad6739097d..7f598ae04fa 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ArrayTest implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -66,6 +69,8 @@ class ArrayTest implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'array_of_string' => null, @@ -187,9 +192,9 @@ class ArrayTest implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['array_of_string'] = isset($data['array_of_string']) ? $data['array_of_string'] : null; - $this->container['array_array_of_integer'] = isset($data['array_array_of_integer']) ? $data['array_array_of_integer'] : null; - $this->container['array_array_of_model'] = isset($data['array_array_of_model']) ? $data['array_array_of_model'] : null; + $this->container['array_of_string'] = $data['array_of_string'] ?? null; + $this->container['array_array_of_integer'] = $data['array_array_of_integer'] ?? null; + $this->container['array_array_of_model'] = $data['array_array_of_model'] ?? null; } /** @@ -231,7 +236,7 @@ class ArrayTest implements ModelInterface, ArrayAccess * * @param string[]|null $array_of_string array_of_string * - * @return $this + * @return self */ public function setArrayOfString($array_of_string) { @@ -255,7 +260,7 @@ class ArrayTest implements ModelInterface, ArrayAccess * * @param int[][]|null $array_array_of_integer array_array_of_integer * - * @return $this + * @return self */ public function setArrayArrayOfInteger($array_array_of_integer) { @@ -279,7 +284,7 @@ class ArrayTest implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\ReadOnlyFirst[][]|null $array_array_of_model array_array_of_model * - * @return $this + * @return self */ public function setArrayArrayOfModel($array_array_of_model) { @@ -304,18 +309,18 @@ class ArrayTest implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php index 973de7be8fc..5fa154bee4a 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Capitalization implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -69,6 +72,8 @@ class Capitalization implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'small_camel' => null, @@ -202,12 +207,12 @@ class Capitalization implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['small_camel'] = isset($data['small_camel']) ? $data['small_camel'] : null; - $this->container['capital_camel'] = isset($data['capital_camel']) ? $data['capital_camel'] : null; - $this->container['small_snake'] = isset($data['small_snake']) ? $data['small_snake'] : null; - $this->container['capital_snake'] = isset($data['capital_snake']) ? $data['capital_snake'] : null; - $this->container['sca_eth_flow_points'] = isset($data['sca_eth_flow_points']) ? $data['sca_eth_flow_points'] : null; - $this->container['att_name'] = isset($data['att_name']) ? $data['att_name'] : null; + $this->container['small_camel'] = $data['small_camel'] ?? null; + $this->container['capital_camel'] = $data['capital_camel'] ?? null; + $this->container['small_snake'] = $data['small_snake'] ?? null; + $this->container['capital_snake'] = $data['capital_snake'] ?? null; + $this->container['sca_eth_flow_points'] = $data['sca_eth_flow_points'] ?? null; + $this->container['att_name'] = $data['att_name'] ?? null; } /** @@ -249,7 +254,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $small_camel small_camel * - * @return $this + * @return self */ public function setSmallCamel($small_camel) { @@ -273,7 +278,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $capital_camel capital_camel * - * @return $this + * @return self */ public function setCapitalCamel($capital_camel) { @@ -297,7 +302,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $small_snake small_snake * - * @return $this + * @return self */ public function setSmallSnake($small_snake) { @@ -321,7 +326,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $capital_snake capital_snake * - * @return $this + * @return self */ public function setCapitalSnake($capital_snake) { @@ -345,7 +350,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $sca_eth_flow_points sca_eth_flow_points * - * @return $this + * @return self */ public function setScaEthFlowPoints($sca_eth_flow_points) { @@ -369,7 +374,7 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param string|null $att_name Name of the pet * - * @return $this + * @return self */ public function setAttName($att_name) { @@ -394,18 +399,18 @@ class Capitalization implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php index 5603aab4c7d..75e10661e9f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php @@ -37,10 +37,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Cat extends Animal { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -62,6 +65,8 @@ class Cat extends Animal * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'declawed' => null @@ -171,7 +176,7 @@ class Cat extends Animal { parent::__construct($data); - $this->container['declawed'] = isset($data['declawed']) ? $data['declawed'] : null; + $this->container['declawed'] = $data['declawed'] ?? null; } /** @@ -213,7 +218,7 @@ class Cat extends Animal * * @param bool|null $declawed declawed * - * @return $this + * @return self */ public function setDeclawed($declawed) { @@ -238,18 +243,18 @@ class Cat extends Animal * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/CatAllOf.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/CatAllOf.php index 8d31dffa0f5..d40c515390f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/CatAllOf.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/CatAllOf.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class CatAllOf implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class CatAllOf implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'declawed' => null @@ -177,7 +182,7 @@ class CatAllOf implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['declawed'] = isset($data['declawed']) ? $data['declawed'] : null; + $this->container['declawed'] = $data['declawed'] ?? null; } /** @@ -219,7 +224,7 @@ class CatAllOf implements ModelInterface, ArrayAccess * * @param bool|null $declawed declawed * - * @return $this + * @return self */ public function setDeclawed($declawed) { @@ -244,18 +249,18 @@ class CatAllOf implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php index 174fdd9b84f..6137a324600 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Category implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class Category implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'id' => 'int64', @@ -182,8 +187,8 @@ class Category implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['name'] = isset($data['name']) ? $data['name'] : 'default-name'; + $this->container['id'] = $data['id'] ?? null; + $this->container['name'] = $data['name'] ?? 'default-name'; } /** @@ -228,7 +233,7 @@ class Category implements ModelInterface, ArrayAccess * * @param int|null $id id * - * @return $this + * @return self */ public function setId($id) { @@ -252,7 +257,7 @@ class Category implements ModelInterface, ArrayAccess * * @param string $name name * - * @return $this + * @return self */ public function setName($name) { @@ -277,18 +282,18 @@ class Category implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php index f833dea74f3..9754dc5466c 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ClassModel implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class ClassModel implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ '_class' => null @@ -178,7 +183,7 @@ class ClassModel implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['_class'] = isset($data['_class']) ? $data['_class'] : null; + $this->container['_class'] = $data['_class'] ?? null; } /** @@ -220,7 +225,7 @@ class ClassModel implements ModelInterface, ArrayAccess * * @param string|null $_class _class * - * @return $this + * @return self */ public function setClass($_class) { @@ -245,18 +250,18 @@ class ClassModel implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php index 564b89cec44..8099e47db03 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Client implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class Client implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'client' => null @@ -177,7 +182,7 @@ class Client implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['client'] = isset($data['client']) ? $data['client'] : null; + $this->container['client'] = $data['client'] ?? null; } /** @@ -219,7 +224,7 @@ class Client implements ModelInterface, ArrayAccess * * @param string|null $client client * - * @return $this + * @return self */ public function setClient($client) { @@ -244,18 +249,18 @@ class Client implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php index 4a205e6a0ac..8e60b41c02c 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php @@ -37,10 +37,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Dog extends Animal { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -62,6 +65,8 @@ class Dog extends Animal * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'breed' => null @@ -171,7 +176,7 @@ class Dog extends Animal { parent::__construct($data); - $this->container['breed'] = isset($data['breed']) ? $data['breed'] : null; + $this->container['breed'] = $data['breed'] ?? null; } /** @@ -213,7 +218,7 @@ class Dog extends Animal * * @param string|null $breed breed * - * @return $this + * @return self */ public function setBreed($breed) { @@ -238,18 +243,18 @@ class Dog extends Animal * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/DogAllOf.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/DogAllOf.php index dc8ac5fefe7..d6edf67ccee 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/DogAllOf.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/DogAllOf.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class DogAllOf implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class DogAllOf implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'breed' => null @@ -177,7 +182,7 @@ class DogAllOf implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['breed'] = isset($data['breed']) ? $data['breed'] : null; + $this->container['breed'] = $data['breed'] ?? null; } /** @@ -219,7 +224,7 @@ class DogAllOf implements ModelInterface, ArrayAccess * * @param string|null $breed breed * - * @return $this + * @return self */ public function setBreed($breed) { @@ -244,18 +249,18 @@ class DogAllOf implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php index b26906a75cc..ed05ebfacf7 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class EnumArrays implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class EnumArrays implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'just_symbol' => null, @@ -212,8 +217,8 @@ class EnumArrays implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['just_symbol'] = isset($data['just_symbol']) ? $data['just_symbol'] : null; - $this->container['array_enum'] = isset($data['array_enum']) ? $data['array_enum'] : null; + $this->container['just_symbol'] = $data['just_symbol'] ?? null; + $this->container['array_enum'] = $data['array_enum'] ?? null; } /** @@ -263,7 +268,7 @@ class EnumArrays implements ModelInterface, ArrayAccess * * @param string|null $just_symbol just_symbol * - * @return $this + * @return self */ public function setJustSymbol($just_symbol) { @@ -296,7 +301,7 @@ class EnumArrays implements ModelInterface, ArrayAccess * * @param string[]|null $array_enum array_enum * - * @return $this + * @return self */ public function setArrayEnum($array_enum) { @@ -330,18 +335,18 @@ class EnumArrays implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumTest.php index 005a3fea0b3..8d4bd318cee 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumTest.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class EnumTest implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -71,6 +74,8 @@ class EnumTest implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'enum_string' => null, @@ -276,14 +281,14 @@ class EnumTest implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['enum_string'] = isset($data['enum_string']) ? $data['enum_string'] : null; - $this->container['enum_string_required'] = isset($data['enum_string_required']) ? $data['enum_string_required'] : null; - $this->container['enum_integer'] = isset($data['enum_integer']) ? $data['enum_integer'] : null; - $this->container['enum_number'] = isset($data['enum_number']) ? $data['enum_number'] : null; - $this->container['outer_enum'] = isset($data['outer_enum']) ? $data['outer_enum'] : null; - $this->container['outer_enum_integer'] = isset($data['outer_enum_integer']) ? $data['outer_enum_integer'] : null; - $this->container['outer_enum_default_value'] = isset($data['outer_enum_default_value']) ? $data['outer_enum_default_value'] : null; - $this->container['outer_enum_integer_default_value'] = isset($data['outer_enum_integer_default_value']) ? $data['outer_enum_integer_default_value'] : null; + $this->container['enum_string'] = $data['enum_string'] ?? null; + $this->container['enum_string_required'] = $data['enum_string_required'] ?? null; + $this->container['enum_integer'] = $data['enum_integer'] ?? null; + $this->container['enum_number'] = $data['enum_number'] ?? null; + $this->container['outer_enum'] = $data['outer_enum'] ?? null; + $this->container['outer_enum_integer'] = $data['outer_enum_integer'] ?? null; + $this->container['outer_enum_default_value'] = $data['outer_enum_default_value'] ?? null; + $this->container['outer_enum_integer_default_value'] = $data['outer_enum_integer_default_value'] ?? null; } /** @@ -360,7 +365,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param string|null $enum_string enum_string * - * @return $this + * @return self */ public function setEnumString($enum_string) { @@ -393,7 +398,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param string $enum_string_required enum_string_required * - * @return $this + * @return self */ public function setEnumStringRequired($enum_string_required) { @@ -426,7 +431,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param int|null $enum_integer enum_integer * - * @return $this + * @return self */ public function setEnumInteger($enum_integer) { @@ -459,7 +464,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param double|null $enum_number enum_number * - * @return $this + * @return self */ public function setEnumNumber($enum_number) { @@ -492,7 +497,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\OuterEnum|null $outer_enum outer_enum * - * @return $this + * @return self */ public function setOuterEnum($outer_enum) { @@ -516,7 +521,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\OuterEnumInteger|null $outer_enum_integer outer_enum_integer * - * @return $this + * @return self */ public function setOuterEnumInteger($outer_enum_integer) { @@ -540,7 +545,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\OuterEnumDefaultValue|null $outer_enum_default_value outer_enum_default_value * - * @return $this + * @return self */ public function setOuterEnumDefaultValue($outer_enum_default_value) { @@ -564,7 +569,7 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\OuterEnumIntegerDefaultValue|null $outer_enum_integer_default_value outer_enum_integer_default_value * - * @return $this + * @return self */ public function setOuterEnumIntegerDefaultValue($outer_enum_integer_default_value) { @@ -589,18 +594,18 @@ class EnumTest implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/File.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/File.php index 03a15d5b802..cb0a923af33 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/File.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/File.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class File implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class File implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'source_uri' => null @@ -178,7 +183,7 @@ class File implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['source_uri'] = isset($data['source_uri']) ? $data['source_uri'] : null; + $this->container['source_uri'] = $data['source_uri'] ?? null; } /** @@ -220,7 +225,7 @@ class File implements ModelInterface, ArrayAccess * * @param string|null $source_uri Test capitalization * - * @return $this + * @return self */ public function setSourceUri($source_uri) { @@ -245,18 +250,18 @@ class File implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php index 4f8ffd8d9de..165c679fdc3 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class FileSchemaTestClass implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class FileSchemaTestClass implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'file' => null, @@ -182,8 +187,8 @@ class FileSchemaTestClass implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['file'] = isset($data['file']) ? $data['file'] : null; - $this->container['files'] = isset($data['files']) ? $data['files'] : null; + $this->container['file'] = $data['file'] ?? null; + $this->container['files'] = $data['files'] ?? null; } /** @@ -225,7 +230,7 @@ class FileSchemaTestClass implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\File|null $file file * - * @return $this + * @return self */ public function setFile($file) { @@ -249,7 +254,7 @@ class FileSchemaTestClass implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\File[]|null $files files * - * @return $this + * @return self */ public function setFiles($files) { @@ -274,18 +279,18 @@ class FileSchemaTestClass implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php index 8213f1d0e34..b7562e15700 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Foo implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class Foo implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'bar' => null @@ -177,7 +182,7 @@ class Foo implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['bar'] = isset($data['bar']) ? $data['bar'] : 'bar'; + $this->container['bar'] = $data['bar'] ?? 'bar'; } /** @@ -219,7 +224,7 @@ class Foo implements ModelInterface, ArrayAccess * * @param string|null $bar bar * - * @return $this + * @return self */ public function setBar($bar) { @@ -244,18 +249,18 @@ class Foo implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php index 0394d187aca..49b33571f0c 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class FormatTest implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -78,6 +81,8 @@ class FormatTest implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'integer' => null, @@ -247,21 +252,21 @@ class FormatTest implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['integer'] = isset($data['integer']) ? $data['integer'] : null; - $this->container['int32'] = isset($data['int32']) ? $data['int32'] : null; - $this->container['int64'] = isset($data['int64']) ? $data['int64'] : null; - $this->container['number'] = isset($data['number']) ? $data['number'] : null; - $this->container['float'] = isset($data['float']) ? $data['float'] : null; - $this->container['double'] = isset($data['double']) ? $data['double'] : null; - $this->container['string'] = isset($data['string']) ? $data['string'] : null; - $this->container['byte'] = isset($data['byte']) ? $data['byte'] : null; - $this->container['binary'] = isset($data['binary']) ? $data['binary'] : null; - $this->container['date'] = isset($data['date']) ? $data['date'] : null; - $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; - $this->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; - $this->container['password'] = isset($data['password']) ? $data['password'] : null; - $this->container['pattern_with_digits'] = isset($data['pattern_with_digits']) ? $data['pattern_with_digits'] : null; - $this->container['pattern_with_digits_and_delimiter'] = isset($data['pattern_with_digits_and_delimiter']) ? $data['pattern_with_digits_and_delimiter'] : null; + $this->container['integer'] = $data['integer'] ?? null; + $this->container['int32'] = $data['int32'] ?? null; + $this->container['int64'] = $data['int64'] ?? null; + $this->container['number'] = $data['number'] ?? null; + $this->container['float'] = $data['float'] ?? null; + $this->container['double'] = $data['double'] ?? null; + $this->container['string'] = $data['string'] ?? null; + $this->container['byte'] = $data['byte'] ?? null; + $this->container['binary'] = $data['binary'] ?? null; + $this->container['date'] = $data['date'] ?? null; + $this->container['date_time'] = $data['date_time'] ?? null; + $this->container['uuid'] = $data['uuid'] ?? null; + $this->container['password'] = $data['password'] ?? null; + $this->container['pattern_with_digits'] = $data['pattern_with_digits'] ?? null; + $this->container['pattern_with_digits_and_delimiter'] = $data['pattern_with_digits_and_delimiter'] ?? null; } /** @@ -375,7 +380,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param int|null $integer integer * - * @return $this + * @return self */ public function setInteger($integer) { @@ -407,7 +412,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param int|null $int32 int32 * - * @return $this + * @return self */ public function setInt32($int32) { @@ -439,7 +444,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param int|null $int64 int64 * - * @return $this + * @return self */ public function setInt64($int64) { @@ -463,7 +468,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param float $number number * - * @return $this + * @return self */ public function setNumber($number) { @@ -495,7 +500,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param float|null $float float * - * @return $this + * @return self */ public function setFloat($float) { @@ -527,7 +532,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param double|null $double double * - * @return $this + * @return self */ public function setDouble($double) { @@ -559,7 +564,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string|null $string string * - * @return $this + * @return self */ public function setString($string) { @@ -588,7 +593,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string $byte byte * - * @return $this + * @return self */ public function setByte($byte) { @@ -612,7 +617,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param \SplFileObject|null $binary binary * - * @return $this + * @return self */ public function setBinary($binary) { @@ -636,7 +641,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param \DateTime $date date * - * @return $this + * @return self */ public function setDate($date) { @@ -660,7 +665,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param \DateTime|null $date_time date_time * - * @return $this + * @return self */ public function setDateTime($date_time) { @@ -684,7 +689,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string|null $uuid uuid * - * @return $this + * @return self */ public function setUuid($uuid) { @@ -708,7 +713,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string $password password * - * @return $this + * @return self */ public function setPassword($password) { @@ -739,7 +744,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string|null $pattern_with_digits A string that is a 10 digit number. Can have leading zeros. * - * @return $this + * @return self */ public function setPatternWithDigits($pattern_with_digits) { @@ -768,7 +773,7 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param string|null $pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. * - * @return $this + * @return self */ public function setPatternWithDigitsAndDelimiter($pattern_with_digits_and_delimiter) { @@ -798,18 +803,18 @@ class FormatTest implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php index 40a8e5584fc..eb7571b2651 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class HasOnlyReadOnly implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class HasOnlyReadOnly implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'bar' => null, @@ -182,8 +187,8 @@ class HasOnlyReadOnly implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['bar'] = isset($data['bar']) ? $data['bar'] : null; - $this->container['foo'] = isset($data['foo']) ? $data['foo'] : null; + $this->container['bar'] = $data['bar'] ?? null; + $this->container['foo'] = $data['foo'] ?? null; } /** @@ -225,7 +230,7 @@ class HasOnlyReadOnly implements ModelInterface, ArrayAccess * * @param string|null $bar bar * - * @return $this + * @return self */ public function setBar($bar) { @@ -249,7 +254,7 @@ class HasOnlyReadOnly implements ModelInterface, ArrayAccess * * @param string|null $foo foo * - * @return $this + * @return self */ public function setFoo($foo) { @@ -274,18 +279,18 @@ class HasOnlyReadOnly implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HealthCheckResult.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HealthCheckResult.php index 1f959f71635..ec6b27724c8 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HealthCheckResult.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HealthCheckResult.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class HealthCheckResult implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class HealthCheckResult implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'nullable_message' => null @@ -178,7 +183,7 @@ class HealthCheckResult implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['nullable_message'] = isset($data['nullable_message']) ? $data['nullable_message'] : null; + $this->container['nullable_message'] = $data['nullable_message'] ?? null; } /** @@ -220,7 +225,7 @@ class HealthCheckResult implements ModelInterface, ArrayAccess * * @param string|null $nullable_message nullable_message * - * @return $this + * @return self */ public function setNullableMessage($nullable_message) { @@ -245,18 +250,18 @@ class HealthCheckResult implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php index 17808cab18e..05aed891fbb 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class InlineObject implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'name' => null, @@ -182,8 +187,8 @@ class InlineObject implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['name'] = isset($data['name']) ? $data['name'] : null; - $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['name'] = $data['name'] ?? null; + $this->container['status'] = $data['status'] ?? null; } /** @@ -225,7 +230,7 @@ class InlineObject implements ModelInterface, ArrayAccess * * @param string|null $name Updated name of the pet * - * @return $this + * @return self */ public function setName($name) { @@ -249,7 +254,7 @@ class InlineObject implements ModelInterface, ArrayAccess * * @param string|null $status Updated status of the pet * - * @return $this + * @return self */ public function setStatus($status) { @@ -274,18 +279,18 @@ class InlineObject implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php index 7c16738bc07..a1dbbb404ab 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject1 implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class InlineObject1 implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'additional_metadata' => null, @@ -182,8 +187,8 @@ class InlineObject1 implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; - $this->container['file'] = isset($data['file']) ? $data['file'] : null; + $this->container['additional_metadata'] = $data['additional_metadata'] ?? null; + $this->container['file'] = $data['file'] ?? null; } /** @@ -225,7 +230,7 @@ class InlineObject1 implements ModelInterface, ArrayAccess * * @param string|null $additional_metadata Additional data to pass to server * - * @return $this + * @return self */ public function setAdditionalMetadata($additional_metadata) { @@ -249,7 +254,7 @@ class InlineObject1 implements ModelInterface, ArrayAccess * * @param \SplFileObject|null $file file to upload * - * @return $this + * @return self */ public function setFile($file) { @@ -274,18 +279,18 @@ class InlineObject1 implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php index 5459e3475bc..d5849b23744 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject2 implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class InlineObject2 implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'enum_form_string_array' => null, @@ -214,8 +219,8 @@ class InlineObject2 implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['enum_form_string_array'] = isset($data['enum_form_string_array']) ? $data['enum_form_string_array'] : null; - $this->container['enum_form_string'] = isset($data['enum_form_string']) ? $data['enum_form_string'] : '-efg'; + $this->container['enum_form_string_array'] = $data['enum_form_string_array'] ?? null; + $this->container['enum_form_string'] = $data['enum_form_string'] ?? '-efg'; } /** @@ -265,7 +270,7 @@ class InlineObject2 implements ModelInterface, ArrayAccess * * @param string[]|null $enum_form_string_array Form parameter enum test (string array) * - * @return $this + * @return self */ public function setEnumFormStringArray($enum_form_string_array) { @@ -298,7 +303,7 @@ class InlineObject2 implements ModelInterface, ArrayAccess * * @param string|null $enum_form_string Form parameter enum test (string) * - * @return $this + * @return self */ public function setEnumFormString($enum_form_string) { @@ -332,18 +337,18 @@ class InlineObject2 implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php index c1383f80803..4fa7ba14dd7 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject3 implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -77,6 +80,8 @@ class InlineObject3 implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'integer' => null, @@ -242,20 +247,20 @@ class InlineObject3 implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['integer'] = isset($data['integer']) ? $data['integer'] : null; - $this->container['int32'] = isset($data['int32']) ? $data['int32'] : null; - $this->container['int64'] = isset($data['int64']) ? $data['int64'] : null; - $this->container['number'] = isset($data['number']) ? $data['number'] : null; - $this->container['float'] = isset($data['float']) ? $data['float'] : null; - $this->container['double'] = isset($data['double']) ? $data['double'] : null; - $this->container['string'] = isset($data['string']) ? $data['string'] : null; - $this->container['pattern_without_delimiter'] = isset($data['pattern_without_delimiter']) ? $data['pattern_without_delimiter'] : null; - $this->container['byte'] = isset($data['byte']) ? $data['byte'] : null; - $this->container['binary'] = isset($data['binary']) ? $data['binary'] : null; - $this->container['date'] = isset($data['date']) ? $data['date'] : null; - $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; - $this->container['password'] = isset($data['password']) ? $data['password'] : null; - $this->container['callback'] = isset($data['callback']) ? $data['callback'] : null; + $this->container['integer'] = $data['integer'] ?? null; + $this->container['int32'] = $data['int32'] ?? null; + $this->container['int64'] = $data['int64'] ?? null; + $this->container['number'] = $data['number'] ?? null; + $this->container['float'] = $data['float'] ?? null; + $this->container['double'] = $data['double'] ?? null; + $this->container['string'] = $data['string'] ?? null; + $this->container['pattern_without_delimiter'] = $data['pattern_without_delimiter'] ?? null; + $this->container['byte'] = $data['byte'] ?? null; + $this->container['binary'] = $data['binary'] ?? null; + $this->container['date'] = $data['date'] ?? null; + $this->container['date_time'] = $data['date_time'] ?? null; + $this->container['password'] = $data['password'] ?? null; + $this->container['callback'] = $data['callback'] ?? null; } /** @@ -361,7 +366,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param int|null $integer None * - * @return $this + * @return self */ public function setInteger($integer) { @@ -393,7 +398,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param int|null $int32 None * - * @return $this + * @return self */ public function setInt32($int32) { @@ -425,7 +430,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param int|null $int64 None * - * @return $this + * @return self */ public function setInt64($int64) { @@ -449,7 +454,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param float $number None * - * @return $this + * @return self */ public function setNumber($number) { @@ -481,7 +486,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param float|null $float None * - * @return $this + * @return self */ public function setFloat($float) { @@ -510,7 +515,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param double $double None * - * @return $this + * @return self */ public function setDouble($double) { @@ -542,7 +547,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param string|null $string None * - * @return $this + * @return self */ public function setString($string) { @@ -571,7 +576,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param string $pattern_without_delimiter None * - * @return $this + * @return self */ public function setPatternWithoutDelimiter($pattern_without_delimiter) { @@ -600,7 +605,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param string $byte None * - * @return $this + * @return self */ public function setByte($byte) { @@ -624,7 +629,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param \SplFileObject|null $binary None * - * @return $this + * @return self */ public function setBinary($binary) { @@ -648,7 +653,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param \DateTime|null $date None * - * @return $this + * @return self */ public function setDate($date) { @@ -672,7 +677,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param \DateTime|null $date_time None * - * @return $this + * @return self */ public function setDateTime($date_time) { @@ -696,7 +701,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param string|null $password None * - * @return $this + * @return self */ public function setPassword($password) { @@ -727,7 +732,7 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param string|null $callback None * - * @return $this + * @return self */ public function setCallback($callback) { @@ -752,18 +757,18 @@ class InlineObject3 implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php index 67120fcf6a4..04a9d074343 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject4 implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class InlineObject4 implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'param' => null, @@ -182,8 +187,8 @@ class InlineObject4 implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['param'] = isset($data['param']) ? $data['param'] : null; - $this->container['param2'] = isset($data['param2']) ? $data['param2'] : null; + $this->container['param'] = $data['param'] ?? null; + $this->container['param2'] = $data['param2'] ?? null; } /** @@ -231,7 +236,7 @@ class InlineObject4 implements ModelInterface, ArrayAccess * * @param string $param field1 * - * @return $this + * @return self */ public function setParam($param) { @@ -255,7 +260,7 @@ class InlineObject4 implements ModelInterface, ArrayAccess * * @param string $param2 field2 * - * @return $this + * @return self */ public function setParam2($param2) { @@ -280,18 +285,18 @@ class InlineObject4 implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php index fe0456b3a83..fba00cddf6a 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineObject5 implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class InlineObject5 implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'additional_metadata' => null, @@ -182,8 +187,8 @@ class InlineObject5 implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; - $this->container['required_file'] = isset($data['required_file']) ? $data['required_file'] : null; + $this->container['additional_metadata'] = $data['additional_metadata'] ?? null; + $this->container['required_file'] = $data['required_file'] ?? null; } /** @@ -228,7 +233,7 @@ class InlineObject5 implements ModelInterface, ArrayAccess * * @param string|null $additional_metadata Additional data to pass to server * - * @return $this + * @return self */ public function setAdditionalMetadata($additional_metadata) { @@ -252,7 +257,7 @@ class InlineObject5 implements ModelInterface, ArrayAccess * * @param \SplFileObject $required_file file to upload * - * @return $this + * @return self */ public function setRequiredFile($required_file) { @@ -277,18 +282,18 @@ class InlineObject5 implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php index 53146c15e45..b2ff1f1b8f1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class InlineResponseDefault implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class InlineResponseDefault implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'string' => null @@ -177,7 +182,7 @@ class InlineResponseDefault implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['string'] = isset($data['string']) ? $data['string'] : null; + $this->container['string'] = $data['string'] ?? null; } /** @@ -219,7 +224,7 @@ class InlineResponseDefault implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\Foo|null $string string * - * @return $this + * @return self */ public function setString($string) { @@ -244,18 +249,18 @@ class InlineResponseDefault implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php index be76b2439b9..e6f4a129455 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class MapTest implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -67,6 +70,8 @@ class MapTest implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'map_map_of_string' => null, @@ -207,10 +212,10 @@ class MapTest implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['map_map_of_string'] = isset($data['map_map_of_string']) ? $data['map_map_of_string'] : null; - $this->container['map_of_enum_string'] = isset($data['map_of_enum_string']) ? $data['map_of_enum_string'] : null; - $this->container['direct_map'] = isset($data['direct_map']) ? $data['direct_map'] : null; - $this->container['indirect_map'] = isset($data['indirect_map']) ? $data['indirect_map'] : null; + $this->container['map_map_of_string'] = $data['map_map_of_string'] ?? null; + $this->container['map_of_enum_string'] = $data['map_of_enum_string'] ?? null; + $this->container['direct_map'] = $data['direct_map'] ?? null; + $this->container['indirect_map'] = $data['indirect_map'] ?? null; } /** @@ -252,7 +257,7 @@ class MapTest implements ModelInterface, ArrayAccess * * @param map[string,map[string,string]]|null $map_map_of_string map_map_of_string * - * @return $this + * @return self */ public function setMapMapOfString($map_map_of_string) { @@ -276,7 +281,7 @@ class MapTest implements ModelInterface, ArrayAccess * * @param map[string,string]|null $map_of_enum_string map_of_enum_string * - * @return $this + * @return self */ public function setMapOfEnumString($map_of_enum_string) { @@ -309,7 +314,7 @@ class MapTest implements ModelInterface, ArrayAccess * * @param map[string,bool]|null $direct_map direct_map * - * @return $this + * @return self */ public function setDirectMap($direct_map) { @@ -333,7 +338,7 @@ class MapTest implements ModelInterface, ArrayAccess * * @param map[string,bool]|null $indirect_map indirect_map * - * @return $this + * @return self */ public function setIndirectMap($indirect_map) { @@ -358,18 +363,18 @@ class MapTest implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php index 2522e4d5d52..31bcc81816d 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -66,6 +69,8 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'uuid' => 'uuid', @@ -187,9 +192,9 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr */ public function __construct(array $data = null) { - $this->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; - $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; - $this->container['map'] = isset($data['map']) ? $data['map'] : null; + $this->container['uuid'] = $data['uuid'] ?? null; + $this->container['date_time'] = $data['date_time'] ?? null; + $this->container['map'] = $data['map'] ?? null; } /** @@ -231,7 +236,7 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr * * @param string|null $uuid uuid * - * @return $this + * @return self */ public function setUuid($uuid) { @@ -255,7 +260,7 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr * * @param \DateTime|null $date_time date_time * - * @return $this + * @return self */ public function setDateTime($date_time) { @@ -279,7 +284,7 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr * * @param map[string,\OpenAPI\Client\Model\Animal]|null $map map * - * @return $this + * @return self */ public function setMap($map) { @@ -304,18 +309,18 @@ class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, Arr * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php index 5be747eb525..92b79ab9c60 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Model200Response implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -66,6 +69,8 @@ class Model200Response implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'name' => 'int32', @@ -183,8 +188,8 @@ class Model200Response implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['name'] = isset($data['name']) ? $data['name'] : null; - $this->container['class'] = isset($data['class']) ? $data['class'] : null; + $this->container['name'] = $data['name'] ?? null; + $this->container['class'] = $data['class'] ?? null; } /** @@ -226,7 +231,7 @@ class Model200Response implements ModelInterface, ArrayAccess * * @param int|null $name name * - * @return $this + * @return self */ public function setName($name) { @@ -250,7 +255,7 @@ class Model200Response implements ModelInterface, ArrayAccess * * @param string|null $class class * - * @return $this + * @return self */ public function setClass($class) { @@ -275,18 +280,18 @@ class Model200Response implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelList.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelList.php index 85335938efd..dacecc851ab 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelList.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelList.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ModelList implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class ModelList implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ '_123_list' => null @@ -177,7 +182,7 @@ class ModelList implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['_123_list'] = isset($data['_123_list']) ? $data['_123_list'] : null; + $this->container['_123_list'] = $data['_123_list'] ?? null; } /** @@ -219,7 +224,7 @@ class ModelList implements ModelInterface, ArrayAccess * * @param string|null $_123_list _123_list * - * @return $this + * @return self */ public function set123List($_123_list) { @@ -244,18 +249,18 @@ class ModelList implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php index 7de6909e70b..26f905224a0 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ModelReturn implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class ModelReturn implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'return' => 'int32' @@ -178,7 +183,7 @@ class ModelReturn implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['return'] = isset($data['return']) ? $data['return'] : null; + $this->container['return'] = $data['return'] ?? null; } /** @@ -220,7 +225,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * * @param int|null $return return * - * @return $this + * @return self */ public function setReturn($return) { @@ -245,18 +250,18 @@ class ModelReturn implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php index a3eddb49986..9f4fe7734c2 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php @@ -40,10 +40,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Name implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -68,6 +71,8 @@ class Name implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'name' => 'int32', @@ -193,10 +198,10 @@ class Name implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['name'] = isset($data['name']) ? $data['name'] : null; - $this->container['snake_case'] = isset($data['snake_case']) ? $data['snake_case'] : null; - $this->container['property'] = isset($data['property']) ? $data['property'] : null; - $this->container['_123_number'] = isset($data['_123_number']) ? $data['_123_number'] : null; + $this->container['name'] = $data['name'] ?? null; + $this->container['snake_case'] = $data['snake_case'] ?? null; + $this->container['property'] = $data['property'] ?? null; + $this->container['_123_number'] = $data['_123_number'] ?? null; } /** @@ -241,7 +246,7 @@ class Name implements ModelInterface, ArrayAccess * * @param int $name name * - * @return $this + * @return self */ public function setName($name) { @@ -265,7 +270,7 @@ class Name implements ModelInterface, ArrayAccess * * @param int|null $snake_case snake_case * - * @return $this + * @return self */ public function setSnakeCase($snake_case) { @@ -289,7 +294,7 @@ class Name implements ModelInterface, ArrayAccess * * @param string|null $property property * - * @return $this + * @return self */ public function setProperty($property) { @@ -313,7 +318,7 @@ class Name implements ModelInterface, ArrayAccess * * @param int|null $_123_number _123_number * - * @return $this + * @return self */ public function set123Number($_123_number) { @@ -338,18 +343,18 @@ class Name implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php index 170f6a256fc..f00792ef364 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NullableClass.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class NullableClass implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -75,6 +78,8 @@ class NullableClass implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'integer_prop' => null, @@ -232,18 +237,18 @@ class NullableClass implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['integer_prop'] = isset($data['integer_prop']) ? $data['integer_prop'] : null; - $this->container['number_prop'] = isset($data['number_prop']) ? $data['number_prop'] : null; - $this->container['boolean_prop'] = isset($data['boolean_prop']) ? $data['boolean_prop'] : null; - $this->container['string_prop'] = isset($data['string_prop']) ? $data['string_prop'] : null; - $this->container['date_prop'] = isset($data['date_prop']) ? $data['date_prop'] : null; - $this->container['datetime_prop'] = isset($data['datetime_prop']) ? $data['datetime_prop'] : null; - $this->container['array_nullable_prop'] = isset($data['array_nullable_prop']) ? $data['array_nullable_prop'] : null; - $this->container['array_and_items_nullable_prop'] = isset($data['array_and_items_nullable_prop']) ? $data['array_and_items_nullable_prop'] : null; - $this->container['array_items_nullable'] = isset($data['array_items_nullable']) ? $data['array_items_nullable'] : null; - $this->container['object_nullable_prop'] = isset($data['object_nullable_prop']) ? $data['object_nullable_prop'] : null; - $this->container['object_and_items_nullable_prop'] = isset($data['object_and_items_nullable_prop']) ? $data['object_and_items_nullable_prop'] : null; - $this->container['object_items_nullable'] = isset($data['object_items_nullable']) ? $data['object_items_nullable'] : null; + $this->container['integer_prop'] = $data['integer_prop'] ?? null; + $this->container['number_prop'] = $data['number_prop'] ?? null; + $this->container['boolean_prop'] = $data['boolean_prop'] ?? null; + $this->container['string_prop'] = $data['string_prop'] ?? null; + $this->container['date_prop'] = $data['date_prop'] ?? null; + $this->container['datetime_prop'] = $data['datetime_prop'] ?? null; + $this->container['array_nullable_prop'] = $data['array_nullable_prop'] ?? null; + $this->container['array_and_items_nullable_prop'] = $data['array_and_items_nullable_prop'] ?? null; + $this->container['array_items_nullable'] = $data['array_items_nullable'] ?? null; + $this->container['object_nullable_prop'] = $data['object_nullable_prop'] ?? null; + $this->container['object_and_items_nullable_prop'] = $data['object_and_items_nullable_prop'] ?? null; + $this->container['object_items_nullable'] = $data['object_items_nullable'] ?? null; } /** @@ -285,7 +290,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param int|null $integer_prop integer_prop * - * @return $this + * @return self */ public function setIntegerProp($integer_prop) { @@ -309,7 +314,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param float|null $number_prop number_prop * - * @return $this + * @return self */ public function setNumberProp($number_prop) { @@ -333,7 +338,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param bool|null $boolean_prop boolean_prop * - * @return $this + * @return self */ public function setBooleanProp($boolean_prop) { @@ -357,7 +362,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param string|null $string_prop string_prop * - * @return $this + * @return self */ public function setStringProp($string_prop) { @@ -381,7 +386,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param \DateTime|null $date_prop date_prop * - * @return $this + * @return self */ public function setDateProp($date_prop) { @@ -405,7 +410,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param \DateTime|null $datetime_prop datetime_prop * - * @return $this + * @return self */ public function setDatetimeProp($datetime_prop) { @@ -429,7 +434,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param object[]|null $array_nullable_prop array_nullable_prop * - * @return $this + * @return self */ public function setArrayNullableProp($array_nullable_prop) { @@ -453,7 +458,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param object[]|null $array_and_items_nullable_prop array_and_items_nullable_prop * - * @return $this + * @return self */ public function setArrayAndItemsNullableProp($array_and_items_nullable_prop) { @@ -477,7 +482,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param object[]|null $array_items_nullable array_items_nullable * - * @return $this + * @return self */ public function setArrayItemsNullable($array_items_nullable) { @@ -501,7 +506,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param map[string,object]|null $object_nullable_prop object_nullable_prop * - * @return $this + * @return self */ public function setObjectNullableProp($object_nullable_prop) { @@ -525,7 +530,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param map[string,object]|null $object_and_items_nullable_prop object_and_items_nullable_prop * - * @return $this + * @return self */ public function setObjectAndItemsNullableProp($object_and_items_nullable_prop) { @@ -549,7 +554,7 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param map[string,object]|null $object_items_nullable object_items_nullable * - * @return $this + * @return self */ public function setObjectItemsNullable($object_items_nullable) { @@ -574,18 +579,18 @@ class NullableClass implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php index 17b092299c1..0f4af94c9ff 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class NumberOnly implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class NumberOnly implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'just_number' => null @@ -177,7 +182,7 @@ class NumberOnly implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['just_number'] = isset($data['just_number']) ? $data['just_number'] : null; + $this->container['just_number'] = $data['just_number'] ?? null; } /** @@ -219,7 +224,7 @@ class NumberOnly implements ModelInterface, ArrayAccess * * @param float|null $just_number just_number * - * @return $this + * @return self */ public function setJustNumber($just_number) { @@ -244,18 +249,18 @@ class NumberOnly implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php index 0fce0df270c..34084f1ea23 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Order implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -69,6 +72,8 @@ class Order implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'id' => 'int64', @@ -219,12 +224,12 @@ class Order implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['pet_id'] = isset($data['pet_id']) ? $data['pet_id'] : null; - $this->container['quantity'] = isset($data['quantity']) ? $data['quantity'] : null; - $this->container['ship_date'] = isset($data['ship_date']) ? $data['ship_date'] : null; - $this->container['status'] = isset($data['status']) ? $data['status'] : null; - $this->container['complete'] = isset($data['complete']) ? $data['complete'] : false; + $this->container['id'] = $data['id'] ?? null; + $this->container['pet_id'] = $data['pet_id'] ?? null; + $this->container['quantity'] = $data['quantity'] ?? null; + $this->container['ship_date'] = $data['ship_date'] ?? null; + $this->container['status'] = $data['status'] ?? null; + $this->container['complete'] = $data['complete'] ?? false; } /** @@ -274,7 +279,7 @@ class Order implements ModelInterface, ArrayAccess * * @param int|null $id id * - * @return $this + * @return self */ public function setId($id) { @@ -298,7 +303,7 @@ class Order implements ModelInterface, ArrayAccess * * @param int|null $pet_id pet_id * - * @return $this + * @return self */ public function setPetId($pet_id) { @@ -322,7 +327,7 @@ class Order implements ModelInterface, ArrayAccess * * @param int|null $quantity quantity * - * @return $this + * @return self */ public function setQuantity($quantity) { @@ -346,7 +351,7 @@ class Order implements ModelInterface, ArrayAccess * * @param \DateTime|null $ship_date ship_date * - * @return $this + * @return self */ public function setShipDate($ship_date) { @@ -370,7 +375,7 @@ class Order implements ModelInterface, ArrayAccess * * @param string|null $status Order Status * - * @return $this + * @return self */ public function setStatus($status) { @@ -403,7 +408,7 @@ class Order implements ModelInterface, ArrayAccess * * @param bool|null $complete complete * - * @return $this + * @return self */ public function setComplete($complete) { @@ -428,18 +433,18 @@ class Order implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php index cab3e72a8c4..f2558176b29 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class OuterComposite implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -66,6 +69,8 @@ class OuterComposite implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'my_number' => null, @@ -187,9 +192,9 @@ class OuterComposite implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['my_number'] = isset($data['my_number']) ? $data['my_number'] : null; - $this->container['my_string'] = isset($data['my_string']) ? $data['my_string'] : null; - $this->container['my_boolean'] = isset($data['my_boolean']) ? $data['my_boolean'] : null; + $this->container['my_number'] = $data['my_number'] ?? null; + $this->container['my_string'] = $data['my_string'] ?? null; + $this->container['my_boolean'] = $data['my_boolean'] ?? null; } /** @@ -231,7 +236,7 @@ class OuterComposite implements ModelInterface, ArrayAccess * * @param float|null $my_number my_number * - * @return $this + * @return self */ public function setMyNumber($my_number) { @@ -255,7 +260,7 @@ class OuterComposite implements ModelInterface, ArrayAccess * * @param string|null $my_string my_string * - * @return $this + * @return self */ public function setMyString($my_string) { @@ -279,7 +284,7 @@ class OuterComposite implements ModelInterface, ArrayAccess * * @param bool|null $my_boolean my_boolean * - * @return $this + * @return self */ public function setMyBoolean($my_boolean) { @@ -304,18 +309,18 @@ class OuterComposite implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Pet.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Pet.php index 4e341c3f60e..7bbdafe0966 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Pet.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Pet implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -69,6 +72,8 @@ class Pet implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'id' => 'int64', @@ -219,12 +224,12 @@ class Pet implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['category'] = isset($data['category']) ? $data['category'] : null; - $this->container['name'] = isset($data['name']) ? $data['name'] : null; - $this->container['photo_urls'] = isset($data['photo_urls']) ? $data['photo_urls'] : null; - $this->container['tags'] = isset($data['tags']) ? $data['tags'] : null; - $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['id'] = $data['id'] ?? null; + $this->container['category'] = $data['category'] ?? null; + $this->container['name'] = $data['name'] ?? null; + $this->container['photo_urls'] = $data['photo_urls'] ?? null; + $this->container['tags'] = $data['tags'] ?? null; + $this->container['status'] = $data['status'] ?? null; } /** @@ -280,7 +285,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param int|null $id id * - * @return $this + * @return self */ public function setId($id) { @@ -304,7 +309,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\Category|null $category category * - * @return $this + * @return self */ public function setCategory($category) { @@ -328,7 +333,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param string $name name * - * @return $this + * @return self */ public function setName($name) { @@ -352,7 +357,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param string[] $photo_urls photo_urls * - * @return $this + * @return self */ public function setPhotoUrls($photo_urls) { @@ -376,7 +381,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param \OpenAPI\Client\Model\Tag[]|null $tags tags * - * @return $this + * @return self */ public function setTags($tags) { @@ -400,7 +405,7 @@ class Pet implements ModelInterface, ArrayAccess * * @param string|null $status pet status in the store * - * @return $this + * @return self */ public function setStatus($status) { @@ -434,18 +439,18 @@ class Pet implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php index 1cdb5ac74da..d859ef1b611 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class ReadOnlyFirst implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class ReadOnlyFirst implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'bar' => null, @@ -182,8 +187,8 @@ class ReadOnlyFirst implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['bar'] = isset($data['bar']) ? $data['bar'] : null; - $this->container['baz'] = isset($data['baz']) ? $data['baz'] : null; + $this->container['bar'] = $data['bar'] ?? null; + $this->container['baz'] = $data['baz'] ?? null; } /** @@ -225,7 +230,7 @@ class ReadOnlyFirst implements ModelInterface, ArrayAccess * * @param string|null $bar bar * - * @return $this + * @return self */ public function setBar($bar) { @@ -249,7 +254,7 @@ class ReadOnlyFirst implements ModelInterface, ArrayAccess * * @param string|null $baz baz * - * @return $this + * @return self */ public function setBaz($baz) { @@ -274,18 +279,18 @@ class ReadOnlyFirst implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php index b58e8fcff1e..4ea1a0f26de 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class SpecialModelName implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -64,6 +67,8 @@ class SpecialModelName implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'special_property_name' => 'int64' @@ -177,7 +182,7 @@ class SpecialModelName implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['special_property_name'] = isset($data['special_property_name']) ? $data['special_property_name'] : null; + $this->container['special_property_name'] = $data['special_property_name'] ?? null; } /** @@ -219,7 +224,7 @@ class SpecialModelName implements ModelInterface, ArrayAccess * * @param int|null $special_property_name special_property_name * - * @return $this + * @return self */ public function setSpecialPropertyName($special_property_name) { @@ -244,18 +249,18 @@ class SpecialModelName implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php index 1c3dd48126d..3eb455e0f7c 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class Tag implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -65,6 +68,8 @@ class Tag implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'id' => 'int64', @@ -182,8 +187,8 @@ class Tag implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['id'] = $data['id'] ?? null; + $this->container['name'] = $data['name'] ?? null; } /** @@ -225,7 +230,7 @@ class Tag implements ModelInterface, ArrayAccess * * @param int|null $id id * - * @return $this + * @return self */ public function setId($id) { @@ -249,7 +254,7 @@ class Tag implements ModelInterface, ArrayAccess * * @param string|null $name name * - * @return $this + * @return self */ public function setName($name) { @@ -274,18 +279,18 @@ class Tag implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php index 859a2025249..4e40a57fd78 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php @@ -39,10 +39,13 @@ use \OpenAPI\Client\ObjectSerializer; * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech + * @implements \ArrayAccess + * @template TKey int|null + * @template TValue mixed|null */ class User implements ModelInterface, ArrayAccess { - const DISCRIMINATOR = null; + public const DISCRIMINATOR = null; /** * The original name of the model. @@ -71,6 +74,8 @@ class User implements ModelInterface, ArrayAccess * Array of property to format mappings. Used for (de)serialization * * @var string[] + * @phpstan-var array + * @psalm-var array */ protected static $openAPIFormats = [ 'id' => 'int64', @@ -212,14 +217,14 @@ class User implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['id'] = isset($data['id']) ? $data['id'] : null; - $this->container['username'] = isset($data['username']) ? $data['username'] : null; - $this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null; - $this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null; - $this->container['email'] = isset($data['email']) ? $data['email'] : null; - $this->container['password'] = isset($data['password']) ? $data['password'] : null; - $this->container['phone'] = isset($data['phone']) ? $data['phone'] : null; - $this->container['user_status'] = isset($data['user_status']) ? $data['user_status'] : null; + $this->container['id'] = $data['id'] ?? null; + $this->container['username'] = $data['username'] ?? null; + $this->container['first_name'] = $data['first_name'] ?? null; + $this->container['last_name'] = $data['last_name'] ?? null; + $this->container['email'] = $data['email'] ?? null; + $this->container['password'] = $data['password'] ?? null; + $this->container['phone'] = $data['phone'] ?? null; + $this->container['user_status'] = $data['user_status'] ?? null; } /** @@ -261,7 +266,7 @@ class User implements ModelInterface, ArrayAccess * * @param int|null $id id * - * @return $this + * @return self */ public function setId($id) { @@ -285,7 +290,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $username username * - * @return $this + * @return self */ public function setUsername($username) { @@ -309,7 +314,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $first_name first_name * - * @return $this + * @return self */ public function setFirstName($first_name) { @@ -333,7 +338,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $last_name last_name * - * @return $this + * @return self */ public function setLastName($last_name) { @@ -357,7 +362,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $email email * - * @return $this + * @return self */ public function setEmail($email) { @@ -381,7 +386,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $password password * - * @return $this + * @return self */ public function setPassword($password) { @@ -405,7 +410,7 @@ class User implements ModelInterface, ArrayAccess * * @param string|null $phone phone * - * @return $this + * @return self */ public function setPhone($phone) { @@ -429,7 +434,7 @@ class User implements ModelInterface, ArrayAccess * * @param int|null $user_status User Status * - * @return $this + * @return self */ public function setUserStatus($user_status) { @@ -454,18 +459,18 @@ class User implements ModelInterface, ArrayAccess * * @param integer $offset Offset * - * @return mixed + * @return mixed|null */ public function offsetGet($offset) { - return isset($this->container[$offset]) ? $this->container[$offset] : null; + return isset($this->container[$offset]) ?? null; } /** * Sets value based on offset. * - * @param integer $offset Offset - * @param mixed $value Value to be set + * @param int|null $offset Offset + * @param mixed $value Value to be set * * @return void */ diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php index 4c7108c94b6..8ca97b47c84 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -61,20 +61,26 @@ class ObjectSerializer * @param string $type the OpenAPIToolsType of the data * @param string $format the format of the OpenAPITools type of the data * - * @return string|object serialized form of $data + * @return scalar|object|array|null serialized form of $data */ public static function sanitizeForSerialization($data, $type = null, $format = null) { if (is_scalar($data) || null === $data) { return $data; - } elseif ($data instanceof \DateTime) { + } + + if ($data instanceof \DateTime) { return ($format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat); - } elseif (is_array($data)) { + } + + if (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } return $data; - } elseif (is_object($data)) { + } + + if (is_object($data)) { $values = []; if ($data instanceof ModelInterface) { $formats = $data::openAPIFormats(); @@ -260,7 +266,9 @@ class ObjectSerializer { if (null === $data) { return null; - } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + } + + if (strcasecmp(substr($class, -2), '[]') === 0) { $data = is_string($data) ? json_decode($data) : $data; if (!is_array($data)) { @@ -273,7 +281,9 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass, null); } return $values; - } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + } + + if (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] $data = is_string($data) ? json_decode($data) : $data; settype($data, 'array'); $inner = substr($class, 4, -1); @@ -286,10 +296,14 @@ class ObjectSerializer } } return $deserialized; - } elseif ($class === 'object') { + } + + if ($class === 'object') { settype($data, 'array'); return $data; - } elseif ($class === '\DateTime') { + } + + if ($class === '\DateTime') { // Some API's return an invalid, empty string as a // date-time property. DateTime::__construct() will return // the current time for empty input which is probably not @@ -301,10 +315,14 @@ class ObjectSerializer } else { return null; } - } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + } + + if (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { settype($data, $class); return $data; - } elseif ($class === '\SplFileObject') { + } + + if ($class === '\SplFileObject') { /** @var \Psr\Http\Message\StreamInterface $data */ // determine file name