[PHP-SYMFONY] Debug Symfony version 7, enums ref, array of enums $ref and date assert (#19008)

* [PHP-SYMFONY] Debug for Symfony 7 support & debug enum ref & debug array enum ref & debug date assert

* [PHP-SYMFONY] Debug for Symfony 7 support & debug enum ref & debug array enum ref & debug date assert

* [PHP-SYMFONY] Debug for Symfony 7 support & debug enum ref & debug array enum ref & debug date assert
This commit is contained in:
loicconan 2024-06-30 04:11:26 +02:00 committed by GitHub
parent fa2b5750ce
commit fb17e5699d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 428 additions and 343 deletions

View File

@ -28,6 +28,7 @@
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"doctrine/annotations": "^2.0",
"symfony/validator": "^6.4|^7.0", "symfony/validator": "^6.4|^7.0",
"jms/serializer-bundle": "^5.4", "jms/serializer-bundle": "^5.4",
"symfony/framework-bundle": "^6.4|^7.0" "symfony/framework-bundle": "^6.4|^7.0"

View File

@ -30,6 +30,20 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
return $this->{{name}}; return $this->{{name}};
} }
/**
* Sets {{name}}.
*
* @param {{{vendorExtensions.x-comment-type}}} ${{name}}{{#description}} {{{.}}}{{/description}}
*
* @return $this
*/
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}}): self
{
$this->{{name}} = ${{name}};
return $this;
}
{{#isEnumRef}} {{#isEnumRef}}
/** /**
* Gets {{name}} for serialization. * Gets {{name}} for serialization.
@ -40,6 +54,24 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
{ {
return $this->{{name}}?->value ? (string) $this->{{name}}->value : null; return $this->{{name}}?->value ? (string) $this->{{name}}->value : null;
} }
/**
* Sets {{name}}.
*
* @param string|{{{vendorExtensions.x-comment-type}}} ${{name}}{{#description}} {{{.}}}{{/description}}
*
* @return $this
*/
public function setDeserialized{{nameInPascalCase}}(string|{{#vendorExtensions.x-comment-type}}{{vendorExtensions.x-comment-type}} {{/vendorExtensions.x-comment-type}}${{name}}{{^required}} = null{{/required}}): self
{
if (is_string(${{name}})) {
${{name}} = {{baseType}}::tryFrom(${{name}});
}
$this->{{name}} = ${{name}};
return $this;
}
{{/isEnumRef}} {{/isEnumRef}}
{{#isContainer}} {{#isContainer}}
@ -53,26 +85,36 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
public function getSerialized{{nameInPascalCase}}(): array public function getSerialized{{nameInPascalCase}}(): array
{ {
return array_map( return array_map(
static fn ($value) => (string) $value->value, static fn ($value) => $value?->value ? (string) $value->value : null,
$this->test ?? [] $this->{{name}} ?? []
); );
} }
/**
* Sets {{name}}.
*
* @param {{^required}}?{{/required}}array ${{name}}{{#description}} {{{.}}}{{/description}}
*
* @return $this
*/
public function setDeserialized{{nameInPascalCase}}({{^required}}?{{/required}}array ${{name}}{{^required}} = []{{/required}}): self
{
$this->{{name}} = array_map(
static function ($value) {
if (is_string($value)) {
$value = {{baseType}}::tryFrom($value);
}
return $value;
},
${{name}} ?? []
);
return $this;
}
{{/isEnumRef}} {{/isEnumRef}}
{{/items}} {{/items}}
{{/isContainer}} {{/isContainer}}
/**
* Sets {{name}}.
*
* @param {{{vendorExtensions.x-comment-type}}} ${{name}}{{#description}} {{{.}}}{{/description}}
*
* @return $this
*/
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}}): self
{
$this->{{name}} = ${{name}};
return $this;
}
{{/vars}} {{/vars}}
} }

View File

@ -5,30 +5,7 @@
{{/description}} {{/description}}
* @var {{{vendorExtensions.x-comment-type}}} * @var {{{vendorExtensions.x-comment-type}}}
* @SerializedName("{{baseName}}") * @SerializedName("{{baseName}}")
{{#required}}
* @Assert\NotNull()
{{^isPrimitiveType}}
* @Assert\Valid()
{{/isPrimitiveType}}
{{/required}}
{{#isEnum}}
{{#isContainer}} {{#isContainer}}
* @Assert\All({
{{#items}}
* @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} })
{{/items}}
* })
{{/isContainer}}
{{^isContainer}}
* @Assert\Choice({ {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}} })
{{/isContainer}}
{{/isEnum}}
{{#isContainer}}
* @Assert\All({
{{#items}}
* @Assert\Type("{{dataType}}")
{{/items}}
* })
{{#isMap}} {{#isMap}}
{{#items}} {{#items}}
* @Type("array<string, {{dataType}}>") * @Type("array<string, {{dataType}}>")
@ -37,7 +14,7 @@
{{^isMap}} {{^isMap}}
{{#items}} {{#items}}
{{#isEnumRef}} {{#isEnumRef}}
* @Accessor(getter="getSerialized{{nameInPascalCase}}") * @Accessor(getter="getSerialized{{nameInPascalCase}}", setter="setDeserialized{{nameInPascalCase}}")
* @Type("array<string>") * @Type("array<string>")
{{/isEnumRef}} {{/isEnumRef}}
{{^isEnumRef}} {{^isEnumRef}}
@ -48,66 +25,95 @@
{{/isContainer}} {{/isContainer}}
{{^isContainer}} {{^isContainer}}
{{#isDate}} {{#isDate}}
* @Assert\Type("\Date")
* @Type("DateTime<'Y-m-d'>") * @Type("DateTime<'Y-m-d'>")
{{/isDate}} {{/isDate}}
{{#isDateTime}} {{#isDateTime}}
* @Assert\Type("\DateTime"))
* @Type("DateTime") * @Type("DateTime")
{{/isDateTime}} {{/isDateTime}}
{{#isEnumRef}} {{#isEnumRef}}
* @Accessor(getter="getSerialized{{nameInPascalCase}}") * @Accessor(getter="getSerialized{{nameInPascalCase}}", setter="setDeserialized{{nameInPascalCase}}")
* @Type("string") * @Type("string")
{{/isEnumRef}} {{/isEnumRef}}
{{^isDate}} {{^isDate}}
{{^isDateTime}} {{^isDateTime}}
{{^isEnumRef}} {{^isEnumRef}}
* @Assert\Type("{{dataType}}")
* @Type("{{dataType}}") * @Type("{{dataType}}")
{{/isEnumRef}} {{/isEnumRef}}
{{/isDateTime}} {{/isDateTime}}
{{/isDate}} {{/isDate}}
{{/isContainer}}
*/
{{#required}}
#[Assert\NotNull]
{{^isPrimitiveType}}
#[Assert\Valid]
{{/isPrimitiveType}}
{{/required}}
{{#isEnum}}
{{#isContainer}}
#[Assert\All([
{{#items}}
new Assert\Choice([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]),
{{/items}}
])]
{{/isContainer}}
{{^isContainer}}
#[Assert\Choice([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])]
{{/isContainer}}
{{/isEnum}}
{{#isContainer}}
#[Assert\All([
{{#items}}
new Assert\Type("{{dataType}}"),
{{/items}}
])]
{{/isContainer}}
{{^isContainer}}
{{#isDate}}
#[Assert\Type("\DateTime")]
{{/isDate}}
{{#isDateTime}}
#[Assert\Type("\DateTime")]
{{/isDateTime}}
{{^isDate}}
{{^isDateTime}}
{{^isEnumRef}}
#[Assert\Type("{{dataType}}")]
{{/isEnumRef}}
{{/isDateTime}}
{{/isDate}}
{{/isContainer}} {{/isContainer}}
{{#hasValidation}} {{#hasValidation}}
{{#maxLength}} {{#maxLength}}
* @Assert\Length( #[Assert\Length(max: {{.}})]
* max = {{.}}
* )
{{/maxLength}} {{/maxLength}}
{{#minLength}} {{#minLength}}
* @Assert\Length( #[Assert\Length(min: {{.}})]
* min = {{.}}
* )
{{/minLength}} {{/minLength}}
{{#minimum}} {{#minimum}}
{{#exclusiveMinimum}} {{#exclusiveMinimum}}
* @Assert\GreaterThan({{minimum}}) #[Assert\GreaterThan({{minimum}})]
{{/exclusiveMinimum}} {{/exclusiveMinimum}}
{{^exclusiveMinimum}} {{^exclusiveMinimum}}
* @Assert\GreaterThanOrEqual({{minimum}}) #[Assert\GreaterThanOrEqual({{minimum}})]
{{/exclusiveMinimum}} {{/exclusiveMinimum}}
{{/minimum}} {{/minimum}}
{{#maximum}} {{#maximum}}
{{#exclusiveMaximum}} {{#exclusiveMaximum}}
* @Assert\LessThan({{maximum}}) #[Assert\LessThan({{maximum}})]
{{/exclusiveMaximum}} {{/exclusiveMaximum}}
{{^exclusiveMaximum}} {{^exclusiveMaximum}}
* @Assert\LessThanOrEqual({{maximum}}) #[Assert\LessThanOrEqual({{maximum}})]
{{/exclusiveMaximum}} {{/exclusiveMaximum}}
{{/maximum}} {{/maximum}}
{{#pattern}} {{#pattern}}
* @Assert\Regex("/{{.}}/") #[Assert\Regex("/{{.}}/")]
{{/pattern}} {{/pattern}}
{{#maxItems}} {{#maxItems}}
* @Assert\Count( #[Assert\Count(max: {{.}})]
* max = {{.}}
* )
{{/maxItems}} {{/maxItems}}
{{#minItems}} {{#minItems}}
* @Assert\Count( #[Assert\Count(min: {{.}})]
* min = {{.}}
* )
{{/minItems}} {{/minItems}}
{{/hasValidation}} {{/hasValidation}}
*/
protected {{{vendorExtensions.x-parameter-type}}} ${{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}; protected {{{vendorExtensions.x-parameter-type}}} ${{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}};

View File

@ -101,12 +101,16 @@ class JmsSerializer implements SerializerInterface
case '\DateTime': case '\DateTime':
return is_null($data) ? null :new DateTime($data); return is_null($data) ? null :new DateTime($data);
default: default:
if (is_null($data)) {
return null;
}
if (!class_exists($type)) { if (!class_exists($type)) {
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }
$reflectionClass = new \ReflectionClass($type); $reflectionClass = new \ReflectionClass($type);
if (!$reflectionClass->implementsInterface('\BackedENum')) { if (!$reflectionClass->implementsInterface('\BackedEnum')) {
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }

View File

@ -48,25 +48,25 @@ class ApiResponse
/** /**
* @var int|null * @var int|null
* @SerializedName("code") * @SerializedName("code")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $code = null; protected ?int $code = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("type") * @SerializedName("type")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $type = null; protected ?string $type = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("message") * @SerializedName("message")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $message = null; protected ?string $message = null;
/** /**
@ -92,8 +92,6 @@ class ApiResponse
return $this->code; return $this->code;
} }
/** /**
* Sets code. * Sets code.
* *
@ -108,6 +106,9 @@ class ApiResponse
return $this; return $this;
} }
/** /**
* Gets type. * Gets type.
* *
@ -118,8 +119,6 @@ class ApiResponse
return $this->type; return $this->type;
} }
/** /**
* Sets type. * Sets type.
* *
@ -134,6 +133,9 @@ class ApiResponse
return $this; return $this;
} }
/** /**
* Gets message. * Gets message.
* *
@ -144,8 +146,6 @@ class ApiResponse
return $this->message; return $this->message;
} }
/** /**
* Sets message. * Sets message.
* *
@ -159,6 +159,9 @@ class ApiResponse
return $this; return $this;
} }
} }

View File

@ -48,18 +48,18 @@ class Category
/** /**
* @var int|null * @var int|null
* @SerializedName("id") * @SerializedName("id")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $id = null; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("name") * @SerializedName("name")
* @Assert\Type("string")
* @Type("string") * @Type("string")
* @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")
*/ */
#[Assert\Type("string")]
#[Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")]
protected ?string $name = null; protected ?string $name = null;
/** /**
@ -84,8 +84,6 @@ class Category
return $this->id; return $this->id;
} }
/** /**
* Sets id. * Sets id.
* *
@ -100,6 +98,9 @@ class Category
return $this; return $this;
} }
/** /**
* Gets name. * Gets name.
* *
@ -110,8 +111,6 @@ class Category
return $this->name; return $this->name;
} }
/** /**
* Sets name. * Sets name.
* *
@ -125,6 +124,9 @@ class Category
return $this; return $this;
} }
} }

View File

@ -48,33 +48,33 @@ class Order
/** /**
* @var int|null * @var int|null
* @SerializedName("id") * @SerializedName("id")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $id = null; protected ?int $id = null;
/** /**
* @var int|null * @var int|null
* @SerializedName("petId") * @SerializedName("petId")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $petId = null; protected ?int $petId = null;
/** /**
* @var int|null * @var int|null
* @SerializedName("quantity") * @SerializedName("quantity")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $quantity = null; protected ?int $quantity = null;
/** /**
* @var \DateTime|null * @var \DateTime|null
* @SerializedName("shipDate") * @SerializedName("shipDate")
* @Assert\Type("\DateTime"))
* @Type("DateTime") * @Type("DateTime")
*/ */
#[Assert\Type("\DateTime")]
protected ?\DateTime $shipDate = null; protected ?\DateTime $shipDate = null;
/** /**
@ -82,18 +82,18 @@ class Order
* *
* @var string|null * @var string|null
* @SerializedName("status") * @SerializedName("status")
* @Assert\Choice({ "placed", "approved", "delivered" })
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Choice(["placed", "approved", "delivered"])]
#[Assert\Type("string")]
protected ?string $status = null; protected ?string $status = null;
/** /**
* @var bool|null * @var bool|null
* @SerializedName("complete") * @SerializedName("complete")
* @Assert\Type("bool")
* @Type("bool") * @Type("bool")
*/ */
#[Assert\Type("bool")]
protected ?bool $complete = false; protected ?bool $complete = false;
/** /**
@ -122,8 +122,6 @@ class Order
return $this->id; return $this->id;
} }
/** /**
* Sets id. * Sets id.
* *
@ -138,6 +136,9 @@ class Order
return $this; return $this;
} }
/** /**
* Gets petId. * Gets petId.
* *
@ -148,8 +149,6 @@ class Order
return $this->petId; return $this->petId;
} }
/** /**
* Sets petId. * Sets petId.
* *
@ -164,6 +163,9 @@ class Order
return $this; return $this;
} }
/** /**
* Gets quantity. * Gets quantity.
* *
@ -174,8 +176,6 @@ class Order
return $this->quantity; return $this->quantity;
} }
/** /**
* Sets quantity. * Sets quantity.
* *
@ -190,6 +190,9 @@ class Order
return $this; return $this;
} }
/** /**
* Gets shipDate. * Gets shipDate.
* *
@ -200,8 +203,6 @@ class Order
return $this->shipDate; return $this->shipDate;
} }
/** /**
* Sets shipDate. * Sets shipDate.
* *
@ -216,6 +217,9 @@ class Order
return $this; return $this;
} }
/** /**
* Gets status. * Gets status.
* *
@ -226,8 +230,6 @@ class Order
return $this->status; return $this->status;
} }
/** /**
* Sets status. * Sets status.
* *
@ -242,6 +244,9 @@ class Order
return $this; return $this;
} }
/** /**
* Gets complete. * Gets complete.
* *
@ -252,8 +257,6 @@ class Order
return $this->complete; return $this->complete;
} }
/** /**
* Sets complete. * Sets complete.
* *
@ -267,6 +270,9 @@ class Order
return $this; return $this;
} }
} }

View File

@ -48,47 +48,47 @@ class Pet
/** /**
* @var int|null * @var int|null
* @SerializedName("id") * @SerializedName("id")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $id = null; protected ?int $id = null;
/** /**
* @var Category|null * @var Category|null
* @SerializedName("category") * @SerializedName("category")
* @Assert\Type("OpenAPI\Server\Model\Category")
* @Type("OpenAPI\Server\Model\Category") * @Type("OpenAPI\Server\Model\Category")
*/ */
#[Assert\Type("OpenAPI\Server\Model\Category")]
protected ?Category $category = null; protected ?Category $category = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("name") * @SerializedName("name")
* @Assert\NotNull()
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\NotNull]
#[Assert\Type("string")]
protected ?string $name = null; protected ?string $name = null;
/** /**
* @var string[]|null * @var string[]|null
* @SerializedName("photoUrls") * @SerializedName("photoUrls")
* @Assert\NotNull()
* @Assert\All({
* @Assert\Type("string")
* })
* @Type("array<string>") * @Type("array<string>")
*/ */
#[Assert\NotNull]
#[Assert\All([
new Assert\Type("string"),
])]
protected ?array $photoUrls = null; protected ?array $photoUrls = null;
/** /**
* @var Tag[]|null * @var Tag[]|null
* @SerializedName("tags") * @SerializedName("tags")
* @Assert\All({
* @Assert\Type("OpenAPI\Server\Model\Tag")
* })
* @Type("array<OpenAPI\Server\Model\Tag>") * @Type("array<OpenAPI\Server\Model\Tag>")
*/ */
#[Assert\All([
new Assert\Type("OpenAPI\Server\Model\Tag"),
])]
protected ?array $tags = null; protected ?array $tags = null;
/** /**
@ -96,10 +96,10 @@ class Pet
* *
* @var string|null * @var string|null
* @SerializedName("status") * @SerializedName("status")
* @Assert\Choice({ "available", "pending", "sold" })
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Choice(["available", "pending", "sold"])]
#[Assert\Type("string")]
protected ?string $status = null; protected ?string $status = null;
/** /**
@ -128,8 +128,6 @@ class Pet
return $this->id; return $this->id;
} }
/** /**
* Sets id. * Sets id.
* *
@ -144,6 +142,9 @@ class Pet
return $this; return $this;
} }
/** /**
* Gets category. * Gets category.
* *
@ -154,8 +155,6 @@ class Pet
return $this->category; return $this->category;
} }
/** /**
* Sets category. * Sets category.
* *
@ -170,6 +169,9 @@ class Pet
return $this; return $this;
} }
/** /**
* Gets name. * Gets name.
* *
@ -180,8 +182,6 @@ class Pet
return $this->name; return $this->name;
} }
/** /**
* Sets name. * Sets name.
* *
@ -196,6 +196,9 @@ class Pet
return $this; return $this;
} }
/** /**
* Gets photoUrls. * Gets photoUrls.
* *
@ -206,8 +209,6 @@ class Pet
return $this->photoUrls; return $this->photoUrls;
} }
/** /**
* Sets photoUrls. * Sets photoUrls.
* *
@ -222,6 +223,9 @@ class Pet
return $this; return $this;
} }
/** /**
* Gets tags. * Gets tags.
* *
@ -232,8 +236,6 @@ class Pet
return $this->tags; return $this->tags;
} }
/** /**
* Sets tags. * Sets tags.
* *
@ -248,6 +250,9 @@ class Pet
return $this; return $this;
} }
/** /**
* Gets status. * Gets status.
* *
@ -258,8 +263,6 @@ class Pet
return $this->status; return $this->status;
} }
/** /**
* Sets status. * Sets status.
* *
@ -273,6 +276,9 @@ class Pet
return $this; return $this;
} }
} }

View File

@ -48,17 +48,17 @@ class Tag
/** /**
* @var int|null * @var int|null
* @SerializedName("id") * @SerializedName("id")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $id = null; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("name") * @SerializedName("name")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $name = null; protected ?string $name = null;
/** /**
@ -83,8 +83,6 @@ class Tag
return $this->id; return $this->id;
} }
/** /**
* Sets id. * Sets id.
* *
@ -99,6 +97,9 @@ class Tag
return $this; return $this;
} }
/** /**
* Gets name. * Gets name.
* *
@ -109,8 +110,6 @@ class Tag
return $this->name; return $this->name;
} }
/** /**
* Sets name. * Sets name.
* *
@ -124,6 +123,9 @@ class Tag
return $this; return $this;
} }
} }

View File

@ -48,57 +48,57 @@ class User
/** /**
* @var int|null * @var int|null
* @SerializedName("id") * @SerializedName("id")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $id = null; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("username") * @SerializedName("username")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $username = null; protected ?string $username = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("firstName") * @SerializedName("firstName")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $firstName = null; protected ?string $firstName = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("lastName") * @SerializedName("lastName")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $lastName = null; protected ?string $lastName = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("email") * @SerializedName("email")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $email = null; protected ?string $email = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("password") * @SerializedName("password")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $password = null; protected ?string $password = null;
/** /**
* @var string|null * @var string|null
* @SerializedName("phone") * @SerializedName("phone")
* @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
#[Assert\Type("string")]
protected ?string $phone = null; protected ?string $phone = null;
/** /**
@ -106,9 +106,9 @@ class User
* *
* @var int|null * @var int|null
* @SerializedName("userStatus") * @SerializedName("userStatus")
* @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
#[Assert\Type("int")]
protected ?int $userStatus = null; protected ?int $userStatus = null;
/** /**
@ -139,8 +139,6 @@ class User
return $this->id; return $this->id;
} }
/** /**
* Sets id. * Sets id.
* *
@ -155,6 +153,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets username. * Gets username.
* *
@ -165,8 +166,6 @@ class User
return $this->username; return $this->username;
} }
/** /**
* Sets username. * Sets username.
* *
@ -181,6 +180,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets firstName. * Gets firstName.
* *
@ -191,8 +193,6 @@ class User
return $this->firstName; return $this->firstName;
} }
/** /**
* Sets firstName. * Sets firstName.
* *
@ -207,6 +207,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets lastName. * Gets lastName.
* *
@ -217,8 +220,6 @@ class User
return $this->lastName; return $this->lastName;
} }
/** /**
* Sets lastName. * Sets lastName.
* *
@ -233,6 +234,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets email. * Gets email.
* *
@ -243,8 +247,6 @@ class User
return $this->email; return $this->email;
} }
/** /**
* Sets email. * Sets email.
* *
@ -259,6 +261,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets password. * Gets password.
* *
@ -269,8 +274,6 @@ class User
return $this->password; return $this->password;
} }
/** /**
* Sets password. * Sets password.
* *
@ -285,6 +288,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets phone. * Gets phone.
* *
@ -295,8 +301,6 @@ class User
return $this->phone; return $this->phone;
} }
/** /**
* Sets phone. * Sets phone.
* *
@ -311,6 +315,9 @@ class User
return $this; return $this;
} }
/** /**
* Gets userStatus. * Gets userStatus.
* *
@ -321,8 +328,6 @@ class User
return $this->userStatus; return $this->userStatus;
} }
/** /**
* Sets userStatus. * Sets userStatus.
* *
@ -336,6 +341,9 @@ class User
return $this; return $this;
} }
} }

View File

@ -101,12 +101,16 @@ class JmsSerializer implements SerializerInterface
case '\DateTime': case '\DateTime':
return is_null($data) ? null :new DateTime($data); return is_null($data) ? null :new DateTime($data);
default: default:
if (is_null($data)) {
return null;
}
if (!class_exists($type)) { if (!class_exists($type)) {
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }
$reflectionClass = new \ReflectionClass($type); $reflectionClass = new \ReflectionClass($type);
if (!$reflectionClass->implementsInterface('\BackedENum')) { if (!$reflectionClass->implementsInterface('\BackedEnum')) {
throw new RuntimeException(sprintf("Type %s is unsupported", $type)); throw new RuntimeException(sprintf("Type %s is unsupported", $type));
} }

View File

@ -20,6 +20,7 @@
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"doctrine/annotations": "^2.0",
"symfony/validator": "^6.4|^7.0", "symfony/validator": "^6.4|^7.0",
"jms/serializer-bundle": "^5.4", "jms/serializer-bundle": "^5.4",
"symfony/framework-bundle": "^6.4|^7.0" "symfony/framework-bundle": "^6.4|^7.0"