Skip to content

Commit 4ce720a

Browse files
committed
CS
1 parent 89c972d commit 4ce720a

16 files changed

Lines changed: 51 additions & 51 deletions

src/HttpClient/HttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function sendRequest(Request $request, Options $options): Response
5757
}
5858

5959
$responseHeaders = [];
60-
$responseHeaderCallback = function ($curlHandle, $headerLine) use (&$responseHeaders): int {
60+
$responseHeaderCallback = static function ($curlHandle, $headerLine) use (&$responseHeaders): int {
6161
return Http::parseResponseHeaders($headerLine, $responseHeaders);
6262
};
6363

src/Logs/LogsAggregator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function add(
8383
$log->setAttribute('sentry.sdk.version', $client->getSdkVersion());
8484
}
8585

86-
$hub->configureScope(function (Scope $scope) use ($log) {
86+
$hub->configureScope(static function (Scope $scope) use ($log) {
8787
$user = $scope->getUser();
8888
if ($user !== null) {
8989
if ($user->getId() !== null) {
@@ -186,7 +186,7 @@ private function getTraceId(HubInterface $hub): string
186186

187187
$traceId = '';
188188

189-
$hub->configureScope(function (Scope $scope) use (&$traceId) {
189+
$hub->configureScope(static function (Scope $scope) use (&$traceId) {
190190
$traceId = (string) $scope->getPropagationContext()->getTraceId();
191191
});
192192

src/Metrics/Metrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function timing(
109109
int $stackLevel = 0
110110
) {
111111
return trace(
112-
function () use ($callback) {
112+
static function () use ($callback) {
113113
return $callback();
114114
},
115115
SpanContext::make()

src/Metrics/MetricsAggregator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function add(
7979
];
8080

8181
if ($options->shouldSendDefaultPii()) {
82-
$hub->configureScope(function (Scope $scope) use (&$defaultAttributes) {
82+
$hub->configureScope(static function (Scope $scope) use (&$defaultAttributes) {
8383
$user = $scope->getUser();
8484
if ($user !== null) {
8585
if ($user->getId() !== null) {
@@ -111,7 +111,7 @@ public function add(
111111
$spanId = $span->getSpanId();
112112
$traceId = $span->getTraceId();
113113
} else {
114-
$hub->configureScope(function (Scope $scope) use (&$traceId, &$spanId) {
114+
$hub->configureScope(static function (Scope $scope) use (&$traceId, &$spanId) {
115115
$propagationContext = $scope->getPropagationContext();
116116
$traceId = $propagationContext->getTraceId();
117117
$spanId = $propagationContext->getSpanId();

src/State/HubAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ public function __clone()
206206
/**
207207
* @see https://www.php.net/manual/en/language.oop5.magic.php#object.wakeup
208208
*/
209-
public function __wakeup()
209+
public function __unserialize(array $data)
210210
{
211211
throw new \BadMethodCallException('Unserializing instances of this class is forbidden.');
212212
}
213213

214214
/**
215215
* @see https://www.php.net/manual/en/language.oop5.magic.php#object.sleep
216216
*/
217-
public function __sleep()
217+
public function __serialize()
218218
{
219219
throw new \BadMethodCallException('Serializing instances of this class is forbidden.');
220220
}

src/Tracing/Span.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function setStatus(?SpanStatus $status)
300300
*/
301301
public function setHttpStatus(int $statusCode)
302302
{
303-
SentrySdk::getCurrentHub()->configureScope(function (Scope $scope) use ($statusCode) {
303+
SentrySdk::getCurrentHub()->configureScope(static function (Scope $scope) use ($statusCode) {
304304
$scope->setContext('response', [
305305
'status_code' => $statusCode,
306306
]);

src/functions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function startTransaction(TransactionContext $context, array $customSamplingCont
252252
*/
253253
function trace(callable $trace, SpanContext $context)
254254
{
255-
return SentrySdk::getCurrentHub()->withScope(function (Scope $scope) use ($context, $trace) {
255+
return SentrySdk::getCurrentHub()->withScope(static function (Scope $scope) use ($context, $trace) {
256256
$parentSpan = $scope->getSpan();
257257

258258
// If there is a span set on the scope and it's sampled there is an active transaction.
@@ -299,7 +299,7 @@ function getTraceparent(): string
299299
}
300300

301301
$traceParent = '';
302-
$hub->configureScope(function (Scope $scope) use (&$traceParent) {
302+
$hub->configureScope(static function (Scope $scope) use (&$traceParent) {
303303
$traceParent = $scope->getPropagationContext()->toTraceparent();
304304
});
305305

@@ -342,7 +342,7 @@ function getBaggage(): string
342342
}
343343

344344
$baggage = '';
345-
$hub->configureScope(function (Scope $scope) use (&$baggage) {
345+
$hub->configureScope(static function (Scope $scope) use (&$baggage) {
346346
$baggage = $scope->getPropagationContext()->toBaggage();
347347
});
348348

@@ -358,7 +358,7 @@ function getBaggage(): string
358358
function continueTrace(string $sentryTrace, string $baggage): TransactionContext
359359
{
360360
$hub = SentrySdk::getCurrentHub();
361-
$hub->configureScope(function (Scope $scope) use ($sentryTrace, $baggage) {
361+
$hub->configureScope(static function (Scope $scope) use ($sentryTrace, $baggage) {
362362
$propagationContext = PropagationContext::fromHeaders($sentryTrace, $baggage);
363363
$scope->setPropagationContext($propagationContext);
364364
});
@@ -393,7 +393,7 @@ function trace_metrics(): TraceMetrics
393393
*/
394394
function addFeatureFlag(string $name, bool $result): void
395395
{
396-
SentrySdk::getCurrentHub()->configureScope(function (Scope $scope) use ($name, $result) {
396+
SentrySdk::getCurrentHub()->configureScope(static function (Scope $scope) use ($name, $result) {
397397
$scope->addFeatureFlag($name, $result);
398398
});
399399
}

tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ public function testAttachStacktrace(): void
10331033
$transport = $this->createMock(TransportInterface::class);
10341034
$transport->expects($this->once())
10351035
->method('send')
1036-
->with($this->callback(function (Event $event): bool {
1036+
->with($this->callback(static function (Event $event): bool {
10371037
$result = $event->getStacktrace();
10381038

10391039
return $result !== null;

tests/FrameBuilderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function testGetFunctionArgumentsWithVariadicParameters(): void
290290
$options = new Options([]);
291291
$frameBuilder = new FrameBuilder($options, new RepresentationSerializer($options));
292292

293-
$testFunction = function (string $first, int $second, ...$rest) {
293+
$testFunction = static function (string $first, int $second, ...$rest) {
294294
};
295295

296296
$backtraceFrame = [
@@ -325,7 +325,7 @@ public function testGetFunctionArgumentsWithOnlyVariadicParameters(): void
325325
$options = new Options([]);
326326
$frameBuilder = new FrameBuilder($options, new RepresentationSerializer($options));
327327

328-
$testFunction = function (...$args) {
328+
$testFunction = static function (...$args) {
329329
};
330330

331331
$backtraceFrame = [
@@ -352,7 +352,7 @@ public function testGetFunctionArgumentsWithEmptyVariadicParameters(): void
352352
$options = new Options([]);
353353
$frameBuilder = new FrameBuilder($options, new RepresentationSerializer($options));
354354

355-
$testFunction = function (string $first, ...$rest) {
355+
$testFunction = static function (string $first, ...$rest) {
356356
};
357357

358358
$backtraceFrame = [
@@ -381,7 +381,7 @@ public function testGetFunctionArgumentsWithNullValues(): void
381381
$options = new Options([]);
382382
$frameBuilder = new FrameBuilder($options, new RepresentationSerializer($options));
383383

384-
$testFunction = function (string $first, $second, ...$rest) {
384+
$testFunction = static function (string $first, $second, ...$rest) {
385385
};
386386

387387
$backtraceFrame = [
@@ -411,7 +411,7 @@ public function testGetFunctionArgumentsWithGapsInBacktraceArrayIndices(): void
411411
$options = new Options([]);
412412
$frameBuilder = new FrameBuilder($options, new RepresentationSerializer($options));
413413

414-
$testFunction = function (string $first, int $second, ...$rest) {
414+
$testFunction = static function (string $first, int $second, ...$rest) {
415415
};
416416

417417
$backtraceFrameArgs = [];

tests/FunctionsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ public function testWithMonitor(): void
224224
$hub->expects($this->exactly(2))
225225
->method('captureCheckIn')
226226
->with(
227-
$this->callback(function (string $slug): bool {
227+
$this->callback(static function (string $slug): bool {
228228
return $slug === 'test-crontab';
229229
}),
230-
$this->callback(function (CheckInStatus $checkInStatus): bool {
230+
$this->callback(static function (CheckInStatus $checkInStatus): bool {
231231
// just check for type CheckInStatus
232232
return true;
233233
}),
234234
$this->anything(),
235-
$this->callback(function (MonitorConfig $monitorConfig): bool {
235+
$this->callback(static function (MonitorConfig $monitorConfig): bool {
236236
return $monitorConfig->getSchedule()->getValue() === '*/5 * * * *'
237237
&& $monitorConfig->getSchedule()->getType() === MonitorSchedule::TYPE_CRONTAB
238238
&& $monitorConfig->getCheckinMargin() === 5
@@ -243,7 +243,7 @@ public function testWithMonitor(): void
243243

244244
SentrySdk::setCurrentHub($hub);
245245

246-
withMonitor('test-crontab', function () {
246+
withMonitor('test-crontab', static function () {
247247
// Do something...
248248
}, new MonitorConfig(
249249
new MonitorSchedule(MonitorSchedule::TYPE_CRONTAB, '*/5 * * * *'),
@@ -261,15 +261,15 @@ public function testWithMonitorCallableThrows(): void
261261
$hub->expects($this->exactly(2))
262262
->method('captureCheckIn')
263263
->with(
264-
$this->callback(function (string $slug): bool {
264+
$this->callback(static function (string $slug): bool {
265265
return $slug === 'test-crontab';
266266
}),
267-
$this->callback(function (CheckInStatus $checkInStatus): bool {
267+
$this->callback(static function (CheckInStatus $checkInStatus): bool {
268268
// just check for type CheckInStatus
269269
return true;
270270
}),
271271
$this->anything(),
272-
$this->callback(function (MonitorConfig $monitorConfig): bool {
272+
$this->callback(static function (MonitorConfig $monitorConfig): bool {
273273
return $monitorConfig->getSchedule()->getValue() === '*/5 * * * *'
274274
&& $monitorConfig->getSchedule()->getType() === MonitorSchedule::TYPE_CRONTAB
275275
&& $monitorConfig->getCheckinMargin() === 5
@@ -280,7 +280,7 @@ public function testWithMonitorCallableThrows(): void
280280

281281
SentrySdk::setCurrentHub($hub);
282282

283-
withMonitor('test-crontab', function () {
283+
withMonitor('test-crontab', static function () {
284284
throw new \Exception();
285285
}, new MonitorConfig(
286286
new MonitorSchedule(MonitorSchedule::TYPE_CRONTAB, '*/5 * * * *'),
@@ -352,7 +352,7 @@ public function testTraceReturnsClosureResult(): void
352352
{
353353
$returnValue = 'foo';
354354

355-
$result = trace(function () use ($returnValue) {
355+
$result = trace(static function () use ($returnValue) {
356356
return $returnValue;
357357
}, new SpanContext());
358358

@@ -379,7 +379,7 @@ public function testTraceCorrectlyReplacesAndRestoresCurrentSpan(): void
379379
$this->assertSame($transaction, $hub->getSpan());
380380

381381
try {
382-
trace(function () {
382+
trace(static function () {
383383
throw new \RuntimeException('Throwing should still restore the previous span');
384384
}, new SpanContext());
385385
} catch (\RuntimeException $e) {

0 commit comments

Comments
 (0)