diff --git a/src/Serializer/AbstractSerializer.php b/src/Serializer/AbstractSerializer.php index ac6741a52..ec1389ac8 100644 --- a/src/Serializer/AbstractSerializer.php +++ b/src/Serializer/AbstractSerializer.php @@ -261,7 +261,7 @@ protected function serializeValue($value) } try { - if (\is_callable($value)) { + if (@\is_callable($value)) { return $this->serializeCallable($value); } } catch (\Throwable $exception) { diff --git a/tests/phpt/test_callable_serialization.phpt b/tests/phpt/test_callable_serialization.phpt new file mode 100644 index 000000000..416628c58 --- /dev/null +++ b/tests/phpt/test_callable_serialization.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test that capturing an exception with a callable looking argument does not trigger an deprecation "Deprecated: Use of "static" in callables is deprecated" +--INI-- +error_reporting=E_ALL +zend.exception_ignore_args=0 +--FILE-- + 'http://public@example.com/sentry/1', +]; + +$client = ClientBuilder::create($options) + ->setTransport($transport) + ->getClient(); + +SentrySdk::getCurrentHub()->bindClient($client); + +class Foo { + function __construct(string $bar) { + SentrySdk::getCurrentHub()->captureException(new Exception('doh!')); + } +} + +new Foo('static::sort'); + +echo 'Triggered capture exception' . PHP_EOL; +?> +--EXPECT-- +Transport called +Triggered capture exception