Skip to content

Commit

Permalink
symfony#39102: thank you fabbot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Basster committed Dec 21, 2020
1 parent cfe328a commit 19a4e9b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
Expand Up @@ -25,7 +25,7 @@

->set('data_collector.serializer', SerializerDataCollector::class)
->args([service('debug.serializer'), tagged_iterator('debug.normalizer')])
->tag('data_collector', ['template' => '@WebProfiler/Collector/serializer.html.twig','id' => 'serializer'])
->tag('data_collector', ['template' => '@WebProfiler/Collector/serializer.html.twig', 'id' => 'serializer'])

->set('debug.serializer.action_factory', SerializerActionFactory::class)

Expand Down
Expand Up @@ -23,7 +23,7 @@ class SerializerDebugPassTest extends TestCase
{
private const NORMALIZER_TAG = 'serializer.normalizer';

public function testProcess(): void
public function testProcess()
{
$serializerDebugPass = new SerializerDebugPass();
$container = new ContainerBuilder();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Debug/LargeContent.php
Expand Up @@ -18,7 +18,7 @@ final class LargeContent
public function __construct()
{
$this->message = sprintf(
"The content of the serialized/deserialized data exceeded %d kB.",
'The content of the serialized/deserialized data exceeded %d kB.',
self::LIMIT_BYTES / 1024
);
}
Expand Down
Expand Up @@ -116,6 +116,6 @@ public function __call($name, $arguments)
return $this->delegate->$name(...$arguments);
}

throw new \LogicException('Unexpected method call');
throw new \LogicException('Unexpected method call.');
}
}
Expand Up @@ -50,7 +50,7 @@ public function createSerialization($data, string $result, string $format, array
);
}

public function createDeserialization(string $data, $result, string $type, string $format, array $context = [] ): Deserialization
public function createDeserialization(string $data, $result, string $type, string $format, array $context = []): Deserialization
{
return new Deserialization(
$this->sanitize($data),
Expand All @@ -63,6 +63,7 @@ public function createDeserialization(string $data, $result, string $type, strin

/**
* @param mixed $data
*
* @return mixed|string|LargeContent
*/
private function sanitize($data)
Expand All @@ -76,12 +77,13 @@ private function sanitize($data)

/**
* @param mixed $data
*
* @return string|LargeContent
*/
private function markAsHugeContent($data)
{
$output = new LargeContent();
if (is_string($data)) {
if (\is_string($data)) {
return (string) $output;
}

Expand All @@ -90,6 +92,6 @@ private function markAsHugeContent($data)

private function getVarSize($data): int
{
return \mb_strlen(serialize($data), 'UTF-8') ?? 0;
return mb_strlen(serialize($data), 'UTF-8') ?? 0;
}
}
Expand Up @@ -48,7 +48,7 @@ final class TraceableNormalizersTest extends TestCase
private $hybridDelegate;
private $serializerActionFactory;

public function testInterfaces(): void
public function testInterfaces()
{
self::assertInstanceOf(NormalizerInterface::class, $this->traceableNormalizer);
self::assertInstanceOf(DenormalizerInterface::class, $this->traceableDenormalizer);
Expand Down Expand Up @@ -208,7 +208,7 @@ public function provideDataForDenormalizationDelegation(): iterable
];
}

public function testAwarenessDelegation(): void
public function testAwarenessDelegation()
{
$serializer = $this->createMock(SerializerInterface::class);
$delegate = new TestSerializerNormalizerDenormalizerAware();
Expand All @@ -232,12 +232,12 @@ public function testCacheableSupport(bool $isCachable): void
self::assertSame($isCachable, $tracer->hasCacheableSupportsMethod());
}

public function testCacheableSupportOnNonCacheableDelegates(): void
public function testCacheableSupportOnNonCacheableDelegates()
{
self::assertFalse($this->traceableNormalizer->hasCacheableSupportsMethod());
}

public function testCallingUnknownMethodsOnDelegates(): void
public function testCallingUnknownMethodsOnDelegates()
{
$delegate = new class() implements NormalizerInterface {
public function normalize($object, string $format = null, array $context = [])
Expand All @@ -258,7 +258,7 @@ public function someAction(string $text)
self::assertSame('foo', $tracer->someAction('foo'));
}

public function testCallingUnknownButNotExistingMethodsOnDelegates(): void
public function testCallingUnknownButNotExistingMethodsOnDelegates()
{
$this->expectException(\LogicException::class);
$this->traceableNormalizer->someAction('foo');
Expand All @@ -279,8 +279,8 @@ protected function setUp(): void
$serializerActionFactory = $this->getSerializerActionFactory();

$this->traceableNormalizer = new TraceableNormalizer($this->normalizerDelegate, $serializerActionFactory);
$this->traceableDenormalizer = new TraceableDenormalizer($this->denormalizerDelegate,$serializerActionFactory);
$this->traceableHybridNormalizer = new TraceableHybridNormalizer($this->hybridDelegate,$serializerActionFactory);
$this->traceableDenormalizer = new TraceableDenormalizer($this->denormalizerDelegate, $serializerActionFactory);
$this->traceableHybridNormalizer = new TraceableHybridNormalizer($this->hybridDelegate, $serializerActionFactory);
}

private function getSerializerActionFactory(): SerializerActionFactory
Expand Down
Expand Up @@ -18,20 +18,20 @@

final class SerializerActionFactoryTest extends TestCase
{
private const EXPECTED_STRING_RESULT = "The content of the serialized/deserialized data exceeded 1024 kB.";
private const EXPECTED_STRING_RESULT = 'The content of the serialized/deserialized data exceeded 1024 kB.';
private static $hugeContent;
private static $obj;
private $factory;

public static function setUpBeforeClass(): void
{
self::$hugeContent = \str_repeat('X', 2000000);
self::$hugeContent = str_repeat('X', 2000000);

self::$obj = new \stdClass();
self::$obj->message = self::$hugeContent;
}

public function testCreateLargeContentObjects(): void
public function testCreateLargeContentObjects()
{
self::assertSame(
self::EXPECTED_STRING_RESULT,
Expand All @@ -54,7 +54,7 @@ public function testCreateLargeContentObjects(): void
);
}

public function testCreateLargeContentObjectsWithDelegate(): void
public function testCreateLargeContentObjectsWithDelegate()
{
self::assertSame(
self::EXPECTED_STRING_RESULT,
Expand Down
Expand Up @@ -45,13 +45,13 @@ protected function setUp(): void
$this->emptyContext = [];
}

public function testTracerIsSerializer(): void
public function testTracerIsSerializer()
{
self::assertInstanceOf('Symfony\Component\Serializer\SerializerInterface', $this->traceableSerializer);
self::assertInstanceOf('Symfony\Contracts\Service\ResetInterface', $this->traceableSerializer);
}

public function testSerializeMustCallDelegate(): void
public function testSerializeMustCallDelegate()
{
$this->assertSerializeToBeCalled();

Expand All @@ -61,7 +61,7 @@ public function testSerializeMustCallDelegate(): void
);
}

public function testTracerAddsSerializationToSerializationsStack(): void
public function testTracerAddsSerializationToSerializationsStack()
{
$this->assertSerializeToBeCalled();

Expand All @@ -70,7 +70,7 @@ public function testTracerAddsSerializationToSerializationsStack(): void
self::assertCount(1, $this->traceableSerializer->getSerializations());
}

public function testCollectedSerializationContainsResultOfSerialization(): void
public function testCollectedSerializationContainsResultOfSerialization()
{
$this->assertSerializeToBeCalled();

Expand All @@ -80,7 +80,7 @@ public function testCollectedSerializationContainsResultOfSerialization(): void
self::assertSame(self::SERIALIZED_OBJECT, $serializations[0]->result);
}

public function testDeserializeMustCallDelegate(): void
public function testDeserializeMustCallDelegate()
{
$this->assertDeserializeToBeCalled();

Expand All @@ -95,7 +95,7 @@ public function testDeserializeMustCallDelegate(): void
);
}

public function testTracerAddsDeserializationToDeserializationsStack(): void
public function testTracerAddsDeserializationToDeserializationsStack()
{
$this->assertDeserializeToBeCalled();

Expand All @@ -104,7 +104,7 @@ public function testTracerAddsDeserializationToDeserializationsStack(): void
self::assertCount(1, $this->traceableSerializer->getDeserializations());
}

public function testCollectedDeserializationContainsResultOfDescerialization(): void
public function testCollectedDeserializationContainsResultOfDescerialization()
{
$this->assertDeserializeToBeCalled();

Expand All @@ -114,7 +114,7 @@ public function testCollectedDeserializationContainsResultOfDescerialization():
self::assertSame($this->something, $deserializations[0]->result);
}

public function testResetClearsSerializationsAndDeserializationsStacks(): void
public function testResetClearsSerializationsAndDeserializationsStacks()
{
$this->assertSerializeToBeCalled();
$this->assertDeserializeToBeCalled();
Expand Down

0 comments on commit 19a4e9b

Please sign in to comment.