Skip to content

Commit a4e63a4

Browse files
committed
find&replace: prepend static to Closures not using $this
(^[\t ]++)(.*)(?<!static |_)\b(function\s*\(([^$\n]++|\n|\$(?!this))+?^\1}) by $1$2static $3
1 parent ce7e8dd commit a4e63a4

39 files changed

+290
-290
lines changed

src/DDTrace/Integrations/AMQP/AMQPIntegration.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static function($This) {
6969
"PhpAmqpLib\Channel\AMQPChannel",
7070
"basic_deliver",
7171
[
72-
'prehook' => function (SpanData $span, $args) use (&$newTrace) {
72+
'prehook' => static function (SpanData $span, $args) use (&$newTrace) {
7373
/** @var AMQPMessage $message */
7474
$message = $args[1];
7575
if (AMQPIntegration::hasDistributedHeaders($message)) {
@@ -79,7 +79,7 @@ static function($This) {
7979
$newTrace->links[] = $span->getLink();
8080
}
8181
},
82-
'posthook' => function (SpanData $span, $args) use (&$newTrace) {
82+
'posthook' => static function (SpanData $span, $args) use (&$newTrace) {
8383
/** @var AMQPMessage $message */
8484
$message = $args[1];
8585

@@ -126,14 +126,14 @@ static function($This) {
126126
"PhpAmqpLib\Channel\AMQPChannel",
127127
"basic_publish",
128128
[
129-
'prehook' => function (SpanData $span, $args) {
129+
'prehook' => static function (SpanData $span, $args) {
130130
/** @var AMQPMessage $message */
131131
$message = $args[0];
132132
if (!is_null($message)) {
133133
AMQPIntegration::injectContext($message);
134134
}
135135
},
136-
'posthook' => function (SpanData $span, $args, $exception) {
136+
'posthook' => static function (SpanData $span, $args, $exception) {
137137
/** @var AMQPMessage $message */
138138
$message = $args[0];
139139
/** @var string $exchange */
@@ -168,14 +168,14 @@ static function($This) {
168168
"PhpAmqpLib\Channel\AMQPChannel",
169169
"batch_basic_publish",
170170
[
171-
'prehook' => function (SpanData $span, $args) {
171+
'prehook' => static function (SpanData $span, $args) {
172172
/** @var AMQPMessage $message */
173173
$message = $args[0];
174174
if (!is_null($message)) {
175175
AMQPIntegration::injectContext($message);
176176
}
177177
},
178-
'posthook' => function (SpanData $span, $args, $exception) {
178+
'posthook' => static function (SpanData $span, $args, $exception) {
179179
/** @var AMQPMessage $message */
180180
$message = $args[0];
181181
/** @var string $exchange */
@@ -208,7 +208,7 @@ static function($This) {
208208
trace_method(
209209
"PhpAmqpLib\Channel\AMQPChannel",
210210
"publish_batch",
211-
function (SpanData $span, $args, $exception) {
211+
static function (SpanData $span, $args, $exception) {
212212
AMQPIntegration::setGenericTags(
213213
$span,
214214
'publish_batch',
@@ -223,7 +223,7 @@ function (SpanData $span, $args, $exception) {
223223
trace_method(
224224
"PhpAmqpLib\Channel\AMQPChannel",
225225
"basic_consume",
226-
function (SpanData $span, $args, $retval, $exception) {
226+
static function (SpanData $span, $args, $retval, $exception) {
227227
/** @var string $queue */
228228
$queue = $args[0];
229229
/** @var string $consumer_tag */
@@ -247,7 +247,7 @@ function (SpanData $span, $args, $retval, $exception) {
247247
trace_method(
248248
'PhpAmqpLib\Channel\AMQPChannel',
249249
'exchange_declare',
250-
function (SpanData $span, $args, $retval, $exception) {
250+
static function (SpanData $span, $args, $retval, $exception) {
251251
/** @var string $exchange */
252252
$exchange = $args[0];
253253

@@ -267,7 +267,7 @@ function (SpanData $span, $args, $retval, $exception) {
267267
trace_method(
268268
'PhpAmqpLib\Channel\AMQPChannel',
269269
'queue_declare',
270-
function (SpanData $span, $args, $retval, $exception) {
270+
static function (SpanData $span, $args, $retval, $exception) {
271271
/** @var string $queue */
272272
$queue = $args[0];
273273
if (empty($queue) && is_array($retval)) {
@@ -290,7 +290,7 @@ function (SpanData $span, $args, $retval, $exception) {
290290
trace_method(
291291
'PhpAmqpLib\Channel\AMQPChannel',
292292
'queue_bind',
293-
function (SpanData $span, $args, $retval, $exception) {
293+
static function (SpanData $span, $args, $retval, $exception) {
294294

295295
/** @var string $queue */
296296
$queue = $args[0];
@@ -320,7 +320,7 @@ function (SpanData $span, $args, $retval, $exception) {
320320
trace_method(
321321
'PhpAmqpLib\Channel\AMQPChannel',
322322
'basic_consume_ok',
323-
function (SpanData $span) {
323+
static function (SpanData $span) {
324324
AMQPIntegration::setGenericTags($span, 'basic.consume_ok', 'server');
325325

326326
$span->meta[Tag::MQ_OPERATION] = 'process';
@@ -330,7 +330,7 @@ function (SpanData $span) {
330330
trace_method(
331331
'PhpAmqpLib\Channel\AMQPChannel',
332332
'basic_cancel',
333-
function (SpanData $span, $args, $retval, $exception) {
333+
static function (SpanData $span, $args, $retval, $exception) {
334334
/** @var string $consumerTag */
335335
$consumerTag = $args[0];
336336

@@ -348,31 +348,31 @@ function (SpanData $span, $args, $retval, $exception) {
348348
trace_method(
349349
'PhpAmqpLib\Channel\AMQPChannel',
350350
'basic_cancel_ok',
351-
function (SpanData $span, $args, $retval, $exception) {
351+
static function (SpanData $span, $args, $retval, $exception) {
352352
AMQPIntegration::setGenericTags($span, 'basic.cancel_ok', 'server', null, $exception);
353353
}
354354
);
355355

356356
trace_method(
357357
'PhpAmqpLib\Connection\AbstractConnection',
358358
'connect',
359-
function (SpanData $span, $args, $retval, $exception) {
359+
static function (SpanData $span, $args, $retval, $exception) {
360360
AMQPIntegration::setGenericTags($span, 'connect', 'client', null, $exception);
361361
}
362362
);
363363

364364
trace_method(
365365
'PhpAmqpLib\Connection\AbstractConnection',
366366
'reconnect',
367-
function (SpanData $span, $args, $retval, $exception) {
367+
static function (SpanData $span, $args, $retval, $exception) {
368368
AMQPIntegration::setGenericTags($span, 'reconnect', 'client', null, $exception);
369369
}
370370
);
371371

372372
trace_method(
373373
'PhpAmqpLib\Channel\AMQPChannel',
374374
'basic_ack',
375-
function (SpanData $span, $args, $retval, $exception) {
375+
static function (SpanData $span, $args, $retval, $exception) {
376376
/** @var int $deliveryTag */
377377
$deliveryTag = $args[0];
378378

@@ -383,7 +383,7 @@ function (SpanData $span, $args, $retval, $exception) {
383383
trace_method(
384384
'PhpAmqpLib\Channel\AMQPChannel',
385385
'basic_nack',
386-
function (SpanData $span, $args, $retval, $exception) {
386+
static function (SpanData $span, $args, $retval, $exception) {
387387
/** @var int $deliveryTag */
388388
$deliveryTag = $args[0];
389389

@@ -394,7 +394,7 @@ function (SpanData $span, $args, $retval, $exception) {
394394
trace_method(
395395
'PhpAmqpLib\Channel\AMQPChannel',
396396
'basic_get',
397-
function (SpanData $span, $args, $message, $exception) {
397+
static function (SpanData $span, $args, $message, $exception) {
398398
/** @var string $queue */
399399
$queue = $args[0];
400400

src/DDTrace/Integrations/CakePHP/CakePHPIntegration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function requiresExplicitTraceAnalyticsEnabling(): bool
2828

2929
public static function init(): int
3030
{
31-
self::$setRootSpanInfoFn = function () {
31+
self::$setRootSpanInfoFn = static function () {
3232
$rootSpan = \DDTrace\root_span();
3333
if ($rootSpan === null) {
3434
return;
@@ -63,7 +63,7 @@ public static function init(): int
6363
}
6464
};
6565

66-
self::$parseRouteFn = function ($app, $appClass, $args, $retval) {
66+
self::$parseRouteFn = static function ($app, $appClass, $args, $retval) {
6767
if (!$retval) {
6868
return;
6969
}

src/DDTrace/Integrations/CakePHP/V3/CakePHPIntegrationLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function (SpanData $span) {
7070
// Create a trace span for every template rendered
7171
\DDTrace\install_hook(
7272
'Cake\View\View::render',
73-
function (HookData $renderHook) {
73+
static function (HookData $renderHook) {
7474
$renderHook->span();
7575

7676
// The next Cake\View\View::_getViewFileName (v3) or Cake\View\View::_getTemplateFileName (v4+) call
@@ -81,7 +81,7 @@ function (HookData $renderHook) {
8181
\DDTrace\install_hook(
8282
$methodName,
8383
null,
84-
function (HookData $hook) use ($renderHook) {
84+
static function (HookData $hook) use ($renderHook) {
8585
$renderHook->data['viewFileName'] = $hook->returned;
8686
\DDTrace\remove_hook($hook->id);
8787
}

src/DDTrace/Integrations/CodeIgniter/V2/CodeIgniterIntegration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function (SpanData $span, $args, $retval, $ex) use ($rootSpan, $service) {
107107
\DDTrace\trace_method(
108108
'CI_Loader',
109109
'view',
110-
function (SpanData $span, $args, $retval, $ex) use ($service) {
110+
static function (SpanData $span, $args, $retval, $ex) use ($service) {
111111
$span->name = 'CI_Loader.view';
112112
$span->service = $service;
113113
$span->resource = !$ex && isset($args[0]) ? $args[0] : $span->name;
@@ -144,7 +144,7 @@ function (SpanData $span, $args, $retval, $ex) use ($service) {
144144
\DDTrace\trace_method(
145145
'CI_Cache',
146146
'__get',
147-
function (SpanData $span, $args, $retval, $ex) use ($service, &$registered_cache_adapters) {
147+
static function (SpanData $span, $args, $retval, $ex) use ($service, &$registered_cache_adapters) {
148148
if (!$ex && \is_object($retval)) {
149149
$class = \get_class($retval);
150150
if (!isset($registered_cache_adapters[$class])) {

src/DDTrace/Integrations/Curl/CurlIntegration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function init(): int
3939
\DDTrace\trace_function('curl_exec', [
4040
// the ddtrace extension will handle distributed headers
4141
'instrument_when_limited' => 0,
42-
'posthook' => function (SpanData $span, $args, $retval) {
42+
'posthook' => static function (SpanData $span, $args, $retval) {
4343
CurlIntegration::setup_curl_span($span);
4444

4545
if (!isset($args[0])) {
@@ -57,7 +57,7 @@ public static function init(): int
5757
},
5858
]);
5959

60-
\DDTrace\install_hook('curl_multi_exec', function (HookData $hook) {
60+
\DDTrace\install_hook('curl_multi_exec', static function (HookData $hook) {
6161
if (\count($hook->args) >= 2) {
6262
$data = null;
6363
if (\PHP_MAJOR_VERSION > 7) {
@@ -88,7 +88,7 @@ public static function init(): int
8888
Integration::handleInternalSpanServiceName($span, CurlIntegration::NAME);
8989
$span->meta[Tag::COMPONENT] = CurlIntegration::NAME;
9090
$span->peerServiceSources = HttpClientIntegrationHelper::PEER_SERVICE_SOURCES;
91-
}, function (HookData $hook) {
91+
}, static function (HookData $hook) {
9292
if (empty($hook->data) || $hook->exception) {
9393
return;
9494
}
@@ -168,7 +168,7 @@ public static function init(): int
168168
}
169169
});
170170

171-
\DDTrace\install_hook('curl_multi_info_read', null, function (HookData $hook) {
171+
\DDTrace\install_hook('curl_multi_info_read', null, static function (HookData $hook) {
172172
if (count($hook->args) < 1 || !isset($hook->returned["handle"])) {
173173
return;
174174
}

0 commit comments

Comments
 (0)