diff --git a/Caster/ClassStub.php b/Caster/ClassStub.php index fb8377a0..f27a17ce 100644 --- a/Caster/ClassStub.php +++ b/Caster/ClassStub.php @@ -56,9 +56,7 @@ public function __construct(string $identifier, callable|array|string $callable } if (str_contains($identifier, "@anonymous\0")) { - $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) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; - }, $identifier); + $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); } if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) { diff --git a/Caster/ExceptionCaster.php b/Caster/ExceptionCaster.php index 14caf71f..80a91ead 100644 --- a/Caster/ExceptionCaster.php +++ b/Caster/ExceptionCaster.php @@ -288,9 +288,7 @@ private static function filterExceptionArray(string $xClass, array $a, string $x unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']); if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) { - $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) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; - }, $a[Caster::PREFIX_PROTECTED.'message']); + $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']); } if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) { diff --git a/Tests/Cloner/VarClonerTest.php b/Tests/Cloner/VarClonerTest.php index 36639ca9..ad179699 100644 --- a/Tests/Cloner/VarClonerTest.php +++ b/Tests/Cloner/VarClonerTest.php @@ -399,9 +399,7 @@ public function testJsonCast() public function testCaster() { $cloner = new VarCloner([ - '*' => function ($obj, $array) { - return ['foo' => 123]; - }, + '*' => fn ($obj, $array) => ['foo' => 123], __CLASS__ => function ($obj, $array) { ++$array['foo']; diff --git a/Tests/Command/Descriptor/CliDescriptorTest.php b/Tests/Command/Descriptor/CliDescriptorTest.php index 56fb2187..6b1f5430 100644 --- a/Tests/Command/Descriptor/CliDescriptorTest.php +++ b/Tests/Command/Descriptor/CliDescriptorTest.php @@ -45,9 +45,7 @@ public function testDescribe(array $context, string $expectedOutput, bool $decor { $output = new BufferedOutput(); $output->setDecorated($decorated); - $descriptor = new CliDescriptor(new CliDumper(function ($s) { - return $s; - })); + $descriptor = new CliDescriptor(new CliDumper(fn ($s) => $s)); $descriptor->describe($output, new Data([[123]]), $context + ['timestamp' => 1544804268.3668], 1);