[php-symfony] Support for default scalar value of properties in model (#16605)

* Add support for default scalar value of properties in php-symfony models. Default values now returns in getter-functions

* Revert nullable type-hinting. Move default values from getter to property initialize.
Made changes in __construct:
Now value of properties rewrites only if key exist in $data array.
This commit is contained in:
Artem
2023-10-01 15:32:32 +02:00
committed by GitHub
parent 03781d3a93
commit 039c1698b0
9 changed files with 47 additions and 33 deletions

View File

@@ -74,9 +74,11 @@ class ApiResponse
*/
public function __construct(array $data = null)
{
$this->code = $data['code'] ?? null;
$this->type = $data['type'] ?? null;
$this->message = $data['message'] ?? null;
if (is_array($data)) {
$this->code = array_key_exists('code', $data) ? $data['code'] : $this->code;
$this->type = array_key_exists('type', $data) ? $data['type'] : $this->type;
$this->message = array_key_exists('message', $data) ? $data['message'] : $this->message;
}
}
/**