Skip to content

Commit a388d35

Browse files
Fix Image Parsing Between Object And Array
The default value for Image::labels is an array, according to the API, an object is returned, however.
1 parent e57cf1f commit a388d35

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/Models/Images/Image.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Image extends Model implements Resource
135135
public $protection;
136136

137137
/**
138-
* @var array
138+
* @var \stdClass|null
139139
*/
140140
public $labels;
141141

@@ -158,24 +158,24 @@ class Image extends Model implements Resource
158158
* Image constructor.
159159
*
160160
* @param int $id
161-
* @param string $type
162-
* @param string $status
163-
* @param string $name
164-
* @param string $description
165-
* @param float $imageSize
166-
* @param int $diskSize
167-
* @param string $created
168-
* @param \LKDev\HetznerCloud\Models\Servers\Server $createdFrom
169-
* @param int $boundTo
170-
* @param string $osFlavor
171-
* @param string $osVersion
161+
* @param string|null $type
162+
* @param string|null $status
163+
* @param string|null $name
164+
* @param string|null $description
165+
* @param float|null $imageSize
166+
* @param int|null $diskSize
167+
* @param string|null $created
168+
* @param null $createdFrom
169+
* @param int|null $boundTo
170+
* @param string|null $osFlavor
171+
* @param string|null $osVersion
172172
* @param bool $rapidDeploy
173-
* @param Protection $protection
174-
* @param string $architecture
175-
* @param array $labels
173+
* @param Protection|null $protection
174+
* @param string|null $architecture
175+
* @param \stdClass $labels
176176
* @param string|null $deleted
177177
* @param string|null $deprecated
178-
*/
178+
*/
179179
public function __construct(
180180
int $id,
181181
?string $type = null,
@@ -192,7 +192,7 @@ public function __construct(
192192
?bool $rapidDeploy = null,
193193
?Protection $protection = null,
194194
?string $architecture = null,
195-
array $labels = [],
195+
\stdClass $labels = new \stdClass(),
196196
?string $deleted = null,
197197
?string $deprecated = null
198198
) {
@@ -293,15 +293,15 @@ public function delete(): bool
293293

294294
/**
295295
* @param $input
296-
* @return \LKDev\HetznerCloud\Models\Images\Image|static
296+
* @return \LKDev\HetznerCloud\Models\Images\Image|static|null
297297
*/
298298
public static function parse($input): ?Image
299299
{
300300
if ($input == null) {
301301
return null;
302302
}
303303

304-
return new self($input->id, $input->type, $input->status, $input->name, $input->description, $input->image_size, $input->disk_size, $input->created, $input->created_from, $input->bound_to, $input->os_flavor, $input->os_version, $input->rapid_deploy, Protection::parse($input->protection), $input->architecture ?? null, get_object_vars($input->labels), $input->deleted ?? null, $input->deprecated ?? null);
304+
return new self($input->id, $input->type, $input->status, $input->name, $input->description, $input->image_size, $input->disk_size, $input->created, $input->created_from, $input->bound_to, $input->os_flavor, $input->os_version, $input->rapid_deploy, Protection::parse($input->protection), $input->architecture ?? null, $input->labels, $input->deleted ?? null, $input->deprecated ?? null);
305305
}
306306

307307
public function reload()

0 commit comments

Comments
 (0)