Skip to content

Commit

Permalink
Merge pull request #60 from Pittiplatsch/#58-get-class-on-dynamic-cla…
Browse files Browse the repository at this point in the history
…ss-names

Keep BC compat to PHP 7: Don't use "::class" on dynamic class names
  • Loading branch information
jrbasso authored Oct 18, 2023
2 parents 9378616 + 42956b6 commit c869bcb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ClosureSerializerManager {
*/
public function addSerializer(ClosureSerializer $closureSerializer)
{
$classname = $closureSerializer::class;
// Keep BC compat to PHP 7: Don't use "::class" on dynamic class names
$classname = get_class($closureSerializer);
$this->closureSerializer[$classname] = $closureSerializer;
return $this;
}
Expand Down
3 changes: 2 additions & 1 deletion src/JsonSerializer/JsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ protected function serializeData($value)
}
return [
static::CLOSURE_IDENTIFIER_KEY => true,
'serializer' => $closureSerializer::class,
// Keep BC compat to PHP 7: Don't use "::class" on dynamic class names
'serializer' => get_class($closureSerializer),
'value' => $closureSerializer->serialize($value)
];
}
Expand Down

0 comments on commit c869bcb

Please sign in to comment.