Open djschilling opened 11 months ago
I had today the same issue with an other Class: GroupService
I think i now know the reason for this issue. Most of our dependencies can be resolved automatically by DI but not all. For some of them we define them in our code like this:
GroupService::class => static function (ContainerInterface $container) {
return new GroupService(
$container->get(EntityManager::class),
...
);
},
The Problem gets resolved if i define both GroupService and GroupService__AopProxied like this:
GroupService::class => static function (ContainerInterface $container) {
return new GroupService(
$container->get(EntityManager::class),
...
);
},
GroupService::class . '__AopProxied' => static function (ContainerInterface $container) {
return $container->get(GroupService::class);
},
It seems to work but its not a great solution because now i have to do this each time i use an Attribute in one of the classes i defined the definitions for in code.
I had again a similar case but a little different.
I have a class SignUpService
with a function signUpMultipleForms
. This function has a annotation which is handled by this framework and so a proxy class is created for it.
This is the start of the function:
When calling the constructor of SignUpConditions
i get the error: Churchtools\\Domain\\GroupHomepage\\SignUpConditions::__construct(): Argument #3 ($groupPolicy) must be of type Churchtools\\Domain\\Group\\GroupPolicy, Churchtools\\Domain\\Group\\GroupPolicy__AopProxied given, called in /private/var/tmp/ct-aop-cache/32167/proxies/src/Domain/GroupHomepage/SignUpService.php on line 159
My guess is that it has something to do with the SignUpConditions not being Proxied, but i am not sure.
@WalterWoshid do you have an idea about these issues?
Hi there, it was difficult trying to reproduce it, but I found some other errors. After a lot of thought and stupid luck, I removed all the type replacement logic and what a wonder, every test still worked. I think that might have fixed all your DI problems. I added some tests that looked similar to your code, they also work.
Try version 1.2.11
and tell me if that worked for you :)
I have a Class
GroupMemberService
which is Proxied by php-aop. In its constructor the classGroupPolicy
is passed which is also proxied.I use DI to inject the constructor params.
This error occurs when i try to get
GroupMemberService
from the DI Service: