forked from loafle/openapi-generator-original
update php samples
This commit is contained in:
@@ -29,8 +29,11 @@
|
||||
|
||||
namespace OpenAPI\Client\Model;
|
||||
|
||||
use \ArrayAccess;
|
||||
use \OpenAPI\Client\ObjectSerializer;
|
||||
use ArrayAccess;
|
||||
use JsonSerializable;
|
||||
use InvalidArgumentException;
|
||||
use ReturnTypeWillChange;
|
||||
use OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Query Class Doc Comment
|
||||
@@ -39,9 +42,9 @@ use \OpenAPI\Client\ObjectSerializer;
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
* @implements ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
class Query implements ModelInterface, ArrayAccess, JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
@@ -50,14 +53,14 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Query';
|
||||
protected static string $openAPIModelName = 'Query';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
protected static array $openAPITypes = [
|
||||
'id' => 'int',
|
||||
'outcomes' => 'string[]'
|
||||
];
|
||||
@@ -65,11 +68,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
* @var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
protected static array $openAPIFormats = [
|
||||
'id' => 'int64',
|
||||
'outcomes' => null
|
||||
];
|
||||
@@ -77,7 +78,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'id' => false,
|
||||
@@ -87,16 +88,16 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
public static function openAPITypes(): array
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
@@ -104,9 +105,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
public static function openAPIFormats(): array
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
@@ -114,7 +115,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
@@ -124,7 +125,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
@@ -134,7 +135,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $openAPINullablesSetToNull
|
||||
* @param array<string, bool> $openAPINullablesSetToNull
|
||||
*/
|
||||
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
|
||||
{
|
||||
@@ -167,9 +168,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @var string[]
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
protected static array $attributeMap = [
|
||||
'id' => 'id',
|
||||
'outcomes' => 'outcomes'
|
||||
];
|
||||
@@ -177,9 +178,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected static $setters = [
|
||||
protected static array $setters = [
|
||||
'id' => 'setId',
|
||||
'outcomes' => 'setOutcomes'
|
||||
];
|
||||
@@ -187,9 +188,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected static $getters = [
|
||||
protected static array $getters = [
|
||||
'id' => 'getId',
|
||||
'outcomes' => 'getOutcomes'
|
||||
];
|
||||
@@ -198,9 +199,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function attributeMap()
|
||||
public static function attributeMap(): array
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
@@ -208,9 +209,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function setters()
|
||||
public static function setters(): array
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
@@ -218,9 +219,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getters()
|
||||
public static function getters(): array
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
@@ -230,7 +231,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
public function getModelName(): string
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
@@ -256,20 +257,19 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
* @var array
|
||||
*/
|
||||
protected $container = [];
|
||||
protected array $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
* @param array $data Associated array of property values initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('id', $data ?? [], null);
|
||||
$this->setIfExists('outcomes', $data ?? [], null);
|
||||
$this->setIfExists('outcomes', $data ?? [], [["SUCCESS","FAILURE"]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +281,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
* @param array $fields
|
||||
* @param mixed $defaultValue
|
||||
*/
|
||||
private function setIfExists(string $variableName, array $fields, $defaultValue): void
|
||||
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
|
||||
{
|
||||
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
|
||||
$this->openAPINullablesSetToNull[] = $variableName;
|
||||
@@ -293,9 +293,9 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
/**
|
||||
* Show all the invalid properties with reasons.
|
||||
*
|
||||
* @return array invalid properties with reasons
|
||||
* @return string[] invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
public function listInvalidProperties(): array
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
@@ -308,7 +308,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
public function valid(): bool
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId()
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->container['id'];
|
||||
}
|
||||
@@ -329,12 +329,12 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @param int|null $id Query
|
||||
*
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(?int $id): static
|
||||
{
|
||||
if (is_null($id)) {
|
||||
throw new \InvalidArgumentException('non-nullable id cannot be null');
|
||||
throw new InvalidArgumentException('non-nullable id cannot be null');
|
||||
}
|
||||
$this->container['id'] = $id;
|
||||
|
||||
@@ -346,7 +346,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getOutcomes()
|
||||
public function getOutcomes(): ?array
|
||||
{
|
||||
return $this->container['outcomes'];
|
||||
}
|
||||
@@ -356,16 +356,16 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @param string[]|null $outcomes outcomes
|
||||
*
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
public function setOutcomes($outcomes)
|
||||
public function setOutcomes(?array $outcomes): static
|
||||
{
|
||||
if (is_null($outcomes)) {
|
||||
throw new \InvalidArgumentException('non-nullable outcomes cannot be null');
|
||||
throw new InvalidArgumentException('non-nullable outcomes cannot be null');
|
||||
}
|
||||
$allowedValues = $this->getOutcomesAllowableValues();
|
||||
if (array_diff($outcomes, $allowedValues)) {
|
||||
throw new \InvalidArgumentException(
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
"Invalid value for 'outcomes', must be one of '%s'",
|
||||
implode("', '", $allowedValues)
|
||||
@@ -383,7 +383,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
@@ -395,8 +395,8 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet(mixed $offset): mixed
|
||||
{
|
||||
return $this->container[$offset] ?? null;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value): void
|
||||
public function offsetSet(mixed $offset, mixed $value): void
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
$this->container[] = $value;
|
||||
@@ -425,7 +425,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset): void
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
unset($this->container[$offset]);
|
||||
}
|
||||
@@ -437,8 +437,8 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
* @return mixed Returns data which can be serialized by json_encode(), which is a value
|
||||
* of any type other than a resource.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
#[ReturnTypeWillChange]
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
@@ -448,7 +448,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
@@ -461,7 +461,7 @@ class Query implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
public function toHeaderValue(): string
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user