Skip to content

Commit 3619d82

Browse files
authored
Merge pull request spatie#1115 from stevebauman/fix-nullable-custom-properties-php-80
Fix nullable custom properties in PHP 8.0
2 parents 89aee26 + 5642f39 commit 3619d82

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Actions/ResolveForPropertyValueAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ protected function isValueAnEnum($value): bool
3434

3535
$enumNamespace = is_object($value) ? get_class($value) : $value;
3636

37-
return ! is_array($value) && enum_exists($enumNamespace);
37+
return ! is_array($value) && is_string($enumNamespace) && enum_exists($enumNamespace);
3838
}
3939
}

tests/ActivityLoggerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@
148148
expect($firstActivity->getExtraProperty('property.subProperty'))->toEqual('value');
149149
});
150150

151+
it('can log activity with null properties', function () {
152+
$properties = [
153+
'property' => null,
154+
];
155+
156+
activity()
157+
->withProperties($properties)
158+
->log($this->activityDescription);
159+
160+
$firstActivity = Activity::first();
161+
162+
expect($firstActivity->properties)->toBeInstanceOf(Collection::class);
163+
expect($firstActivity->getExtraProperty('property'))->toBeNull();
164+
});
165+
151166
it('can log activity with a single properties', function () {
152167
activity()
153168
->withProperty('key', 'value')

0 commit comments

Comments
 (0)