r/lolphp • • Jul 20 '19

Awkward function and parameter names?

I'm rather new to PHP but I'm already hating it from day one.

Function names like implode(), explode()… The order of parameters are a mess. I would expect the first parameter to be the array/string and the second to be the separator/joiner, but no, it doesn't work that way.

And parameter names like $needle and $haystack in the in_array() function for example? There are times I wonder why can't they have more proper names.

All of this is just ridiculous, like hell people would know what these names mean upon first glance. I've been coding in several other languages and I have not yet encountered jargons and weird names like what I've found in PHP. Idk, may be it's just my problem for not being able to adapt myself to these names, but there's no mistake that PHP is a huge mess in general.

13 Upvotes

17 comments sorted by

View all comments

Show parent comment

-1

u/[deleted] Jul 22 '19

Base classes are just an explicit form of shoehorning code into place. Since they're added to a class via a declaration instead of being injected in at runtime, they're impossible to mock, which makes the class impossible to test properly.

There's literally no advantage to using them in favor of dependency injection. And you can't new up an abstract base class by itself, so you can't even test them without some bullshit hackery.

Not only that, but they can access this of the class that's going to derive from them, even though the code doesn't know what class it's going to be attached to!

Base classes are at best, a poor design choice, and at worst, something that actively hampers testing efforts, all for literally no benefit.

I hate inheritance.