Skip to content

Conversation

@yoeunes
Copy link
Contributor

@yoeunes yoeunes commented Nov 26, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

I'm not sure if this is a bug or not, the load() method resets $this->instanceof to an empty array in the finally block. Because the loader instance is shared during recursive imports (via $loader->import() inside the callback), this wipes the configuration of the parent file when the child file finishes loading.

return function (ContainerConfigurator $container, PhpFileLoader $loader) {
    $services = $container->services();
    $services->instanceof(SomeInterface::class)->tag('my_tag');

    // This import triggers a recursive load() on the same loader instance
    $loader->import('child.php');

    // The instanceof rules above are currently lost here because the 
    // child load() reset the state in its finally block.
    $services->set(MyService::class, MyService::class); 
};

@OskarStark OskarStark changed the title [DependencyInjection] Fix state corruption in PhpFileLoader during recursive imports [DependencyInjection] Fix state corruption in PhpFileLoader during recursive imports Nov 28, 2025
@fabpot
Copy link
Member

fabpot commented Nov 29, 2025

Thank you @yoeunes.

@fabpot fabpot merged commit 86e50a0 into symfony:6.4 Nov 29, 2025
5 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants