shlogg · Early preview
Michalczerski @michalczerski

PHP Method Overloading With Type Hinting

Overloaded methods in PHP, inspired by Java & C#. Call methods with different params: `$userRepository->add('Michael', 'Jordan', 23);` or `$userRepository->add(new User("Micheal", "Jordan", 23));`. Get it on GitHub!

Since PHP 7.4 we have types and I have feeling I was programming in languages like Java or C# which is really nice but then I noticed I can’t overload my methods way I used to in other projects with typed languages.
Solutions given on StackOverflow are unacceptable so I was thinking how to overload methods in most efficient and clean way and made library to support it. I want to share it with you because it’s best You could find. You can get it on GitHub and learn more.
I think short snippet of code beneath is sufficient to understand how does it work.

$userRepository = new UserRepository();...