Closed
Description
Symfony version(s) affected: 4.4/5.0/5.1/5.2
Description
The ConfigDataCollector
class allows for an optional KernelInterface $kernel
attribute. Note there are several isset
checks for this private property. This conflicts with the getter method isSymfonyLts
as it has a fixed return type bool
.
How to reproduce
<?php
use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
$c = new ConfigDataCollector();
$c->collect(new Request(), new Response());
$c->isSymfonyLts();
// TypeError: Return value of Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::isSymfonyLts() must be of the type bool, null returned
Possible Solution
Allow for the return type to be nullable and take advantage of the already typed return. Use the null coalescing operator on the attribute to retrieve the value.