Skip to content

Commit 6358546

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent 0dd4f98 commit 6358546

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

Caster/ClassStub.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ public function __construct(string $identifier, callable|array|string $callable
5656
}
5757

5858
if (str_contains($identifier, "@anonymous\0")) {
59-
$this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
60-
return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
61-
}, $identifier);
59+
$this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $identifier);
6260
}
6361

6462
if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) {

Caster/ExceptionCaster.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ private static function filterExceptionArray(string $xClass, array $a, string $x
288288
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
289289

290290
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) {
291-
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) {
292-
return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
293-
}, $a[Caster::PREFIX_PROTECTED.'message']);
291+
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $a[Caster::PREFIX_PROTECTED.'message']);
294292
}
295293

296294
if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) {

Tests/Cloner/VarClonerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ public function testJsonCast()
399399
public function testCaster()
400400
{
401401
$cloner = new VarCloner([
402-
'*' => function ($obj, $array) {
403-
return ['foo' => 123];
404-
},
402+
'*' => fn ($obj, $array) => ['foo' => 123],
405403
__CLASS__ => function ($obj, $array) {
406404
++$array['foo'];
407405

Tests/Command/Descriptor/CliDescriptorTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public function testDescribe(array $context, string $expectedOutput, bool $decor
4545
{
4646
$output = new BufferedOutput();
4747
$output->setDecorated($decorated);
48-
$descriptor = new CliDescriptor(new CliDumper(function ($s) {
49-
return $s;
50-
}));
48+
$descriptor = new CliDescriptor(new CliDumper(fn ($s) => $s));
5149

5250
$descriptor->describe($output, new Data([[123]]), $context + ['timestamp' => 1544804268.3668], 1);
5351

0 commit comments

Comments
 (0)