Skip to content

fix: ApiPlatform\Symfony\Bundle\Test\Client::getContainer return type - #7230

Merged
soyuka merged 1 commit into
api-platform:4.1from
VincentLanglet:fixGetContainer
Jun 20, 2025
Merged

fix: ApiPlatform\Symfony\Bundle\Test\Client::getContainer return type#7230
soyuka merged 1 commit into
api-platform:4.1from
VincentLanglet:fixGetContainer

Conversation

@VincentLanglet

Copy link
Copy Markdown
Contributor
Q A
Branch? 4.1 for bugfix
Tickets Closes #...
License MIT
Doc PR api-platform/docs#...

Implementation was

    public function getContainer(): ?ContainerInterface
    {
        return $this->kernelBrowser->getContainer();
    }

but this->kernelBrowser is not nullable and KernelBrowser implementation is

    public function getContainer(): ContainerInterface
    {
        $container = $this->kernel->getContainer();

        return $container->has('test.service_container') ? $container->get('test.service_container') : $container;
    }

so it's never nullable.

@VincentLanglet VincentLanglet changed the title Fix ApiPlatform\Symfony\Bundle\Test\Client::getContainer return type fix: ApiPlatform\Symfony\Bundle\Test\Client::getContainer return type Jun 18, 2025
@soyuka

soyuka commented Jun 19, 2025

Copy link
Copy Markdown
Member

I like the change but its a bc break to change a return type https://symfony.com/doc/current/contributing/code/bc.html#changing-classes. Would you be able to target the main branch?

@VincentLanglet

Copy link
Copy Markdown
Contributor Author

I like the change but its a bc break to change a return type

I don't think it is since the class is final, no ?

@soyuka
soyuka merged commit f0604a0 into api-platform:4.1 Jun 20, 2025
110 of 111 checks passed
@soyuka

soyuka commented Jun 20, 2025

Copy link
Copy Markdown
Member

thanks @VincentLanglet !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants