php-plus / engine

✨ The Plus source code.
https://php-plus.com
91 stars 3 forks source link

[RFC] Method overloading #10

Open olivernybroe opened 5 years ago

olivernybroe commented 5 years ago

Basically the support for having multiple methods named the same but with different parameters. For example, this would be really helpful in the Laravel Query builder, where if we look at the where method for example, it is full of if statements to call the correct method. If we had method overloading, this would simply be multiple methods, taking the correct argument in each of the methods. https://github.com/laravel/framework/blob/2906b572aa83ff46b8ad57093dd0e859c0ff783f/src/Illuminate/Database/Query/Builder.php#L487-L548

stancl commented 5 years ago

+1, pattern matching/method overloading makes some code so much more elegant.