Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deprecation notice when trying to serialize a callable (#1732)
- Loading branch information
1 parent
b595385
commit 8ee5a89
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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-- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry\Tests; | ||
|
||
use Exception; | ||
use Sentry\ClientBuilder; | ||
use Sentry\Event; | ||
use Sentry\Options; | ||
use Sentry\SentrySdk; | ||
use Sentry\Transport\Result; | ||
use Sentry\Transport\ResultStatus; | ||
use Sentry\Transport\TransportInterface; | ||
|
||
$vendor = __DIR__; | ||
|
||
while (!file_exists($vendor . '/vendor')) { | ||
$vendor = \dirname($vendor); | ||
} | ||
|
||
require $vendor . '/vendor/autoload.php'; | ||
|
||
$transport = new class implements TransportInterface { | ||
public function send(Event $event): Result | ||
{ | ||
echo 'Transport called' . PHP_EOL; | ||
|
||
return new Result(ResultStatus::success()); | ||
} | ||
|
||
public function close(?int $timeout = null): Result | ||
{ | ||
return new Result(ResultStatus::success()); | ||
} | ||
}; | ||
|
||
$options = [ | ||
'dsn' => '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 |