laravel-ide-macros
laravel-ide-macros copied to clipboard
Mixed return type includes null
This PR prevents appending ? to nullable return types if the return type is mixed because mixed already includes null. Appending the ? causes php-lint to complain. For now, I've just excluded _ide_macros.php from php-lint in CI so this is low-impact for me. But it might be helpful to others.
I'm not sure this solution is 100% complete. I haven't read the code carefully enough to see how pipe-joined mixed return types are handled and what would happen if the return type were something like string|int|null. Obviously in that case, the ? should also not be appended. Let me know if you think that's something that I should explore further.
Thanks for the great package! It's made my life a whole lot easier.
Hey @edgrosvenor, sadly I'm not in the PHP / Laravel ecosystem anymore, so I have no idea about any of this anymore :') To be honest, I'm very surprised that this package still works at all after so many years 😅
For now I'd suggest using a fork with your own fixes, as I'll be unable to verify whether this change works well or not :/