8000 ConfigDataCollector::isSymfonyLts() return type is inconsistent · Issue #40534 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
ConfigDataCollector::isSymfonyLts() return type is inconsistent #40534
Closed
@topikito

Description

@topikito

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.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0