Skip to content

Commit 4224b0e

Browse files
committed
fixed model property issues/mismatches found by new tests
1 parent 68c9548 commit 4224b0e

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

src/Models/Admin/DomainBlockModel.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ class DomainBlockModel extends Model
4646
*/
4747
public bool $reject_reports;
4848

49+
public ?string $private_comment = null;
50+
51+
public ?string $public_comment = null;
52+
4953
/**
5054
* Whether to obfuscate public displays of this domain block.
5155
*/
52-
public ?string $obfuscate = null;
56+
public bool $obfuscate;
5357
}

src/Models/FilterResultModel.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class FilterResultModel extends Model
2727

2828
/**
2929
* The status ID within the filter that was matched.
30+
*
31+
* @var null|array<string>
3032
*/
31-
public ?string $status_matches = null;
33+
public ?array $status_matches = null;
3234
}

src/Models/MediaAttachmentModel.php

+5
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ class MediaAttachmentModel extends Model
5757
* preview thumbnails when media has not been downloaded yet.
5858
*/
5959
public string $blurhash;
60+
61+
/**
62+
* A shorter URL for the attachment.
63+
*/
64+
public string $text_url;
6065
}

src/Models/Model.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ public static function fromArray(array $array): static
2525
$model = new static();
2626

2727
foreach ($array as $property => $value) {
28-
if ($value === null) {
29-
continue;
30-
}
31-
32-
$property = str_replace(':', '_', $property);
28+
$property = static::sanitizePropertyName($property);
3329

3430
if (!property_exists($model, $property)) {
3531
// do not bork on this!
@@ -50,6 +46,11 @@ public function toArray(): array
5046
return get_object_vars($this);
5147
}
5248

49+
public static function sanitizePropertyName(string $property): string
50+
{
51+
return str_replace(':', '_', $property);
52+
}
53+
5354
/**
5455
* @param mixed $value
5556
*
@@ -69,7 +70,7 @@ protected static function resolvePropertyValue(string $property, $value)
6970
return (int) $value;
7071
}
7172

72-
if ($type === 'string' && is_int($value)) {
73+
if ($type === 'string' && (is_int($value) || null === $value)) {
7374
return (string) $value;
7475
}
7576

0 commit comments

Comments
 (0)