Skip to content

Commit

Permalink
Solve Cannot declare class SerializationException (#159)
Browse files Browse the repository at this point in the history
Fixes #157.
  • Loading branch information
MikeiLL authored Mar 23, 2023
1 parent ec5e326 commit 3aac213
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Sync/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
use Amp\Serialization\SerializationException as SerializerException;

if (!\class_exists(SerializationException::class)) {
// Alias must be defined in an always-loaded file as catch blocks do not trigger the autoloader.
\class_alias(SerializerException::class, SerializationException::class);
// Wrap definition in error handler to avoid apparently PHP bug with preloading, see amphp/parallel#159
set_error_handler(function (): bool { return true; });
try {
// Alias must be defined in an always-loaded file as catch blocks do not trigger the autoloader.
\class_alias(SerializerException::class, SerializationException::class);
} finally {
restore_error_handler();
}
}

/**
Expand Down

0 comments on commit 3aac213

Please sign in to comment.