I stumbled across a bug in the autoresolver. The issue seems to be here:
https://github.com/auraphp/Aura.Di/blob/4.x/src/Resolver/AutoResolver.php#L63
When the constructer parameter has a union type such as "\DateTimeImmutable|string" a ReflectionUnionType instance is instantiated but this class doesn't have a 'getName()' method. I guess from the docs you are supposed to call 'getTypes()' and loop through them to retrieve the actual types.
I stumbled across a bug in the autoresolver. The issue seems to be here:
https://github.com/auraphp/Aura.Di/blob/4.x/src/Resolver/AutoResolver.php#L63
When the constructer parameter has a union type such as "\DateTimeImmutable|string" a ReflectionUnionType instance is instantiated but this class doesn't have a 'getName()' method. I guess from the docs you are supposed to call 'getTypes()' and loop through them to retrieve the actual types.