Skip to content

Commit

Permalink
Merge pull request #1115 from stevebauman/fix-nullable-custom-propert…
Browse files Browse the repository at this point in the history
…ies-php-80

Fix nullable custom properties in PHP 8.0
  • Loading branch information
Gummibeer authored Nov 11, 2022
2 parents 89aee26 + 5642f39 commit 3619d82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Actions/ResolveForPropertyValueAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ protected function isValueAnEnum($value): bool

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

return ! is_array($value) && enum_exists($enumNamespace);
return ! is_array($value) && is_string($enumNamespace) && enum_exists($enumNamespace);
}
}
15 changes: 15 additions & 0 deletions tests/ActivityLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@
expect($firstActivity->getExtraProperty('property.subProperty'))->toEqual('value');
});

it('can log activity with null properties', function () {
$properties = [
'property' => null,
];

activity()
->withProperties($properties)
->log($this->activityDescription);

$firstActivity = Activity::first();

expect($firstActivity->properties)->toBeInstanceOf(Collection::class);
expect($firstActivity->getExtraProperty('property'))->toBeNull();
});

it('can log activity with a single properties', function () {
activity()
->withProperty('key', 'value')
Expand Down

0 comments on commit 3619d82

Please sign in to comment.