You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR was merged into the 6.4 branch.
Discussion
----------
[VarExporter] Fix exporting default values involving global constants
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| License | MIT
Hello, we hit a case when a service works fine when injected normally but stop working when injected lazily. The reason was that the default value of a parameter was a global constant that was used without explicitly specifying `\` nor importing it. It ends up being incorrectly transformer in the proxy class as `\MyNamespace\GLOBAL_CONSTANT` instead of `\GLOBAL_CONSTANT`.
We worked around that by adding the `\` in this service which is anyway rather a good move to be explicit. However I believe the `ReflectionCaster` should support this case because:
- You might want to use a class from a third-party you don't control the code as a lazy service in Symfony and they might be legit not to use the FQCN since it's a feature provided by PHP to work.
- So you can be confident that passing an injection from non-lazy to lazy is not going to cause problem.
- It minimize surprises. We were confident that mocking this service in our tests was fine and so we didn't catch it early, it would be relatively tedious if we start to assume the proxy class can be incompatible where the normal class is and so that we would have to test all non-mocked of them in all possible situations.
Commits
-------
5d33407 [VarExporter] Fix exporting default values involving global constants
0 commit comments