Skip to content

Commit d0d49de

Browse files
committed
Leverage class name literal on object
1 parent cf8df28 commit d0d49de

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Debug/TraceableEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function encode(mixed $data, string $format, array $context = []): string
4444
$time = microtime(true) - $startTime;
4545

4646
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
47-
$this->dataCollector->collectEncoding($traceId, \get_class($this->encoder), $time);
47+
$this->dataCollector->collectEncoding($traceId, $this->encoder::class, $time);
4848
}
4949

5050
return $encoded;
@@ -70,7 +70,7 @@ public function decode(string $data, string $format, array $context = []): mixed
7070
$time = microtime(true) - $startTime;
7171

7272
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
73-
$this->dataCollector->collectDecoding($traceId, \get_class($this->encoder), $time);
73+
$this->dataCollector->collectDecoding($traceId, $this->encoder::class, $time);
7474
}
7575

7676
return $encoded;

Debug/TraceableNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function normalize(mixed $object, string $format = null, array $context =
4646
$time = microtime(true) - $startTime;
4747

4848
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
49-
$this->dataCollector->collectNormalization($traceId, \get_class($this->normalizer), $time);
49+
$this->dataCollector->collectNormalization($traceId, $this->normalizer::class, $time);
5050
}
5151

5252
return $normalized;
@@ -72,7 +72,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
7272
$time = microtime(true) - $startTime;
7373

7474
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
75-
$this->dataCollector->collectDenormalization($traceId, \get_class($this->normalizer), $time);
75+
$this->dataCollector->collectDenormalization($traceId, $this->normalizer::class, $time);
7676
}
7777

7878
return $denormalized;

Tests/Normalizer/CustomNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function testSerialize()
5050

5151
public function testDeserialize()
5252
{
53-
$obj = $this->normalizer->denormalize('foo', \get_class(new ScalarDummy()), 'xml');
53+
$obj = $this->normalizer->denormalize('foo', (new ScalarDummy())::class, 'xml');
5454
$this->assertEquals('foo', $obj->xmlFoo);
5555
$this->assertNull($obj->foo);
5656

57-
$obj = $this->normalizer->denormalize('foo', \get_class(new ScalarDummy()), 'json');
57+
$obj = $this->normalizer->denormalize('foo', (new ScalarDummy())::class, 'json');
5858
$this->assertEquals('foo', $obj->foo);
5959
$this->assertNull($obj->xmlFoo);
6060
}

Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,10 @@ public function testDoesntHaveIssuesWithUnionConstTypes()
736736
$normalizer = new ObjectNormalizer(null, null, null, $extractor);
737737
$serializer = new Serializer([new ArrayDenormalizer(), new DateTimeNormalizer(), $normalizer]);
738738

739-
$this->assertSame('bar', $serializer->denormalize(['foo' => 'bar'], \get_class(new class() {
739+
$this->assertSame('bar', $serializer->denormalize(['foo' => 'bar'], (new class() {
740740
/** @var self::*|null */
741741
public $foo;
742-
}))->foo);
742+
})::class)->foo);
743743
}
744744

745745
public function testExtractAttributesRespectsFormat()

0 commit comments

Comments
 (0)