Skip to content

Lazy services in root namespace cannot be found #34863

Closed
@bfeaver

Description

@bfeaver

Symfony version(s) affected: 4.4.0, 4.4.1

Description
After upgrading to 4.4.0 (and trying 4.4.1) when using a single container file, proxy classes for lazy services that have classes in the root namespace can't be found since the container file is in a generated namespace.

How to reproduce
Create a class without a namespace and use it as a lazy service in the container. Must be using the proxy-manager-bridge and container.dumper.inline_factories must be true.

Reproducer app: https://github.com/bfeaver/lazy-service-bug

All you'll need to do is:

$ composer install

When it does the Symfony cache warmup, it'll fail to find the TestService class.

Possible Solution
I traced it down to \Zend\Code\Generator\ClassGenerator::generateShortOrCompleteClassname() stripping off the leading backslash. If that method instead left it, there wouldn't be a problem. Maybe it would be possible to include the container's namespace as the currentNamespace in the ClassGenerator. Then it wouldn't match the final if condition in that method and it would add back the backslash to the class name.

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