BUG: Generated proxy method uses wrong return type
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
An original class containing an __invoke() method with a return type of mixed results in a auto-generated proxy method with return type ?mixed.
That results in the following error:
Fatal error: Type mixed cannot be marked as nullable since mixed already includes null
Expected Behavior
The proxy method should contain the correct return type (mixed can never be optional).
Steps To Reproduce
Create a class containing the following method:
public function __invoke($objectValue, $args, $_, ResolveInfo $info): mixed
{
}
Protect that method with a security policy, so that a proxy method is generated.
Environment
- Flow: dev-master (56bd731b691270b208423d4cadf4c7c4803d71ec), shortly after the 8.1.1 release
- PHP: 8.1
Anything else?
No response
Woah, probably the result of Flow checking vie reflection of the return type is nullable. Having null in mixed makes that check pass, even though it must not be marked nullable. Awesome insonsistency. 🤷♂️
Also, judging from
mixed can never be optional
the ? doesn't even mean nullable, but optional. TIL.
We need that new / revamped Reflection Service I've been talking about.
We need that new / revamped Reflection Service I've been talking about.
True. But that would still be a special case I would not have anticipated.