77use Symfony \Component \HttpFoundation \Request ;
88use Symfony \Component \HttpFoundation \Response ;
99use Symfony \Component \HttpKernel \DataCollector \DataCollector ;
10+ use Symfony \Component \HttpKernel \Kernel ;
1011
1112/**
1213 * The Collector holds profiled Stacks pushed by the StackPlugin. It also has a list of the configured clients.
1920 *
2021 * @internal
2122 */
22- final class Collector extends DataCollector
23+ class BaseCollector extends DataCollector
2324{
2425 private ?Stack $ activeStack = null ;
2526 private ?int $ capturedBodyLength = null ;
@@ -30,13 +31,6 @@ public function __construct(?int $capturedBodyLength = null)
3031 $ this ->reset ();
3132 }
3233
33- public function __wakeup (): void
34- {
35- $ this ->capturedBodyLength = null ;
36-
37- parent ::__wakeup ();
38- }
39-
4034 public function reset (): void
4135 {
4236 $ this ->data ['stacks ' ] = [];
@@ -158,4 +152,45 @@ public function collect(Request $request, Response $response, $exception = null)
158152 {
159153 // We do not need to collect any data from the Symfony Request and Response
160154 }
155+
156+ protected function resetBodyLength (): void
157+ {
158+ $ this ->capturedBodyLength = null ;
159+ }
160+ }
161+
162+ if (version_compare ('7.4.0 ' , Kernel::VERSION , '> ' )) {
163+ /**
164+ * @legacy Support Symfony < 7.4
165+ *
166+ * When we drop Support for Symfony < 7.4, remove this hackery.
167+ * - Rename BaseCollector back to Collector
168+ * - Make it final again
169+ * - move __unserialize into BaseCollector and inline resetBodyLength
170+ * - remove the if statement completely
171+ *
172+ * @internal
173+ */
174+ final class Collector extends BaseCollector
175+ {
176+ public function __wakeup (): void
177+ {
178+ $ this ->resetBodyLength ();
179+
180+ parent ::__wakeup (); /* @phpstan-ignore staticMethod.notFound */
181+ }
182+ }
183+ } else {
184+ /**
185+ * @internal
186+ */
187+ final class Collector extends BaseCollector
188+ {
189+ public function __unserialize (array $ data ): void
190+ {
191+ $ this ->resetBodyLength ();
192+
193+ parent ::__unserialize ($ data );
194+ }
195+ }
161196}
0 commit comments