22
33namespace Http \HttplugBundle \Collector ;
44
5- use Exception ;
5+ use Symfony \ Component \ HttpKernel \ Kernel ;
66use Symfony \Component \HttpFoundation \Request ;
77use Symfony \Component \HttpFoundation \Response ;
88use Symfony \Component \HttpKernel \DataCollector \DataCollector ;
9+ use Throwable ;
910
1011/**
1112 * The Collector hold profiled Stacks pushed by StackPlugin. It also have a list of configured clients.
1819 *
1920 * @internal
2021 */
21- class Collector extends DataCollector
22+ // Make this class non-abstract and move collect into it when we drop support for Symfony 4.
23+ abstract class BaseCollector extends DataCollector
2224{
2325 /**
2426 * @var Stack|null
@@ -30,14 +32,6 @@ public function __construct()
3032 $ this ->reset ();
3133 }
3234
33- /**
34- * {@inheritdoc}
35- */
36- public function collect (Request $ request , Response $ response , Exception $ exception = null )
37- {
38- // We do not need to collect any data from the Symfony Request and Response
39- }
40-
4135 /**
4236 * {@inheritdoc}
4337 */
@@ -199,3 +193,27 @@ public function getTotalDuration()
199193 }, 0 );
200194 }
201195}
196+
197+ if (Kernel::MAJOR_VERSION >= 5 ) {
198+ class Collector extends BaseCollector
199+ {
200+ /**
201+ * {@inheritdoc}
202+ */
203+ public function collect (Request $ request , Response $ response , Throwable $ exception = null )
204+ {
205+ // We do not need to collect any data from the Symfony Request and Response
206+ }
207+ }
208+ } else {
209+ class Collector extends BaseCollector
210+ {
211+ /**
212+ * {@inheritdoc}
213+ */
214+ public function collect (Request $ request , Response $ response , \Exception $ exception = null )
215+ {
216+ // We do not need to collect any data from the Symfony Request and Response
217+ }
218+ }
219+ }
0 commit comments