Skip to content

Commit 429e8d1

Browse files
committed
Remove old debug stack context
1 parent c0d2552 commit 429e8d1

2 files changed

Lines changed: 3 additions & 40 deletions

File tree

src/Normalizer/SimpleNormalizer.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
class SimpleNormalizer
2525
{
2626
private readonly ?ClassMetadataFactory $doctrineMetadata;
27-
private const string STACK_CONTEXT = "simple-normalizer.debug-stack";
2827
private const int DEFAULT_MAX_DEPTH = 128;
2928

3029
/** @var array<class-string, class-string> */
@@ -53,7 +52,7 @@ public function __construct (
5352
*/
5453
public function normalize (mixed $value, array $context = []) : mixed
5554
{
56-
$stack = $this->extractInitialStack($context);
55+
$stack = [];
5756
$normalizedValue = $this->recursiveNormalize($value, $context, $stack);
5857

5958
if ($this->isDebug)
@@ -68,7 +67,7 @@ public function normalize (mixed $value, array $context = []) : mixed
6867
*/
6968
public function normalizeArray (array $array, array $context = []) : array
7069
{
71-
$stack = $this->extractInitialStack($context);
70+
$stack = [];
7271
$normalizedValue = $this->recursiveNormalizeArray($array, $context, $stack);
7372

7473
if ($this->isDebug)
@@ -86,7 +85,7 @@ public function normalizeArray (array $array, array $context = []) : array
8685
public function normalizeMap (array $array, array $context = []) : array|\stdClass
8786
{
8887
// return stdClass if the array is empty here, as it will be automatically normalized to `{}` in JSON.
89-
$stack = $this->extractInitialStack($context);
88+
$stack = [];
9089
$normalizedValue = $this->recursiveNormalizeArray($array, $context, $stack) ?: new \stdClass();
9190

9291
if ($this->isDebug)
@@ -144,9 +143,6 @@ private function recursiveNormalize (mixed $value, array $context, array &$stack
144143
$normalizer = $this->objectNormalizers->get($className);
145144
\assert($normalizer instanceof SimpleObjectNormalizerInterface);
146145

147-
// Preserve debug stack visibility for custom object normalizers.
148-
$context[self::STACK_CONTEXT] = $stack;
149-
150146
return $normalizer->normalize($value, $context, $this);
151147
}
152148
catch (ServiceNotFoundException $exception)
@@ -229,25 +225,4 @@ private function recursiveNormalizeArray (array $array, array $context, array &$
229225

230226
return $result;
231227
}
232-
233-
/**
234-
* @return list<string>
235-
*/
236-
private function extractInitialStack (array $context) : array
237-
{
238-
if (!isset($context[self::STACK_CONTEXT]) || !\is_array($context[self::STACK_CONTEXT]))
239-
{
240-
return [];
241-
}
242-
243-
$stack = [];
244-
245-
foreach ($context[self::STACK_CONTEXT] as $entry)
246-
{
247-
\assert(\is_string($entry));
248-
$stack[] = $entry;
249-
}
250-
251-
return $stack;
252-
}
253228
}

tests/Normalizer/ObjectNormalizer/ValueWithContextNormalizerTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ public function testContextPassing () : void
3636
[
3737
"test" => 123,
3838
"o" => "hai",
39-
"simple-normalizer.debug-stack" => [
40-
get_debug_type($value),
41-
DummyVO::class,
42-
],
4339
],
4440
);
4541

@@ -68,10 +64,6 @@ public function testEmptyWrappedContextKeepsIncomingContext () : void
6864
$value->value,
6965
[
7066
"test" => 123,
71-
"simple-normalizer.debug-stack" => [
72-
get_debug_type($value),
73-
DummyVO::class,
74-
],
7567
],
7668
);
7769

@@ -101,10 +93,6 @@ public function testEmptyIncomingContextUsesWrappedContext () : void
10193
$value->value,
10294
[
10395
"o" => "hai",
104-
"simple-normalizer.debug-stack" => [
105-
get_debug_type($value),
106-
DummyVO::class,
107-
],
10896
],
10997
);
11098

0 commit comments

Comments
 (0)