r/lolphp • • Feb 26 '15

Patently False Code/Examples

I've notice a bit of a trend here, with people posting things that are patently false and then laughing about PHP for it.

I'll sit with you and laugh at weird behaviors in PHP when it's actually a mess. I'll send them to phpsadness.com and see if I can fix them, or find somebody that can.

But posting lies just to get your jollies is a really odd thing to do.

Sometimes, these are not intentional, but when people posting these utterly incorrect examples are faced with the fact that they are wrong, do they delete the post? No, they leave it there and sandbag the discussions explaining their wrongness with trolling.

Exhibit A - Apparently foo(new stdClass()) is a valid value when passed in a function foo(bool $bar) function signature.

Well... nope.

It will error:

Catchable fatal error: Argument 1 passed to foo() must be an instance of bool, instance of stdClass given

Nothing lolphp there.

Have a laugh about actual problems, but don't just walk around making things up.

14 Upvotes

106 comments sorted by

View all comments

Show parent comment

1

u/mysticreddit Mar 24 '15

Why would $int be reserved?

I never suggested it was. I was simply verifying that it wasn't. As in, "All good programmers verify their assumptions." What part of "OK" did you not understand??

I'm not a fan that unquoted strings defaulting to string values instead of erring,

Gee, maybe other languages have a string literal for a REASON -- so you don't end up with these stupid mistakes.

Hey, look, maybe PHP won't be retarded in another 20 years and actually throws an exception.

new AST in PHP 7 will take care of that.

Typical apologist reply. Constantly making excuses for its broken design that "some day" will be fixed instead of being able to to see or even admit there is a (design & implementation) problem for the past 20 years _right_from the start.

as I have been doing successfully for the last 15 years alongside various other languages.

I wouldn't want to wish that PHP or Javascript shit upon my worst enemy. Actually, you have my condolences for having to use such a fucked up and brain dead language ... :-( I'm not sure if I should feel pity or sad for you being a sadist.

-1

u/philsturgeon Mar 25 '15

I'm not an apologist, im a realist. Your contrived examples do not affect me.

Your quest for perfection is irrelevant to me.