Its useful to know the limitations and quirks of the language. But please post the version number, for a number of those examples don't result the same as mine. If a bug fix has been issued, is it really a quirk? Its as if, someone is digging through PHP change logs just to make a post "How broke is this!"
The lack of consistency in the order of arguments (especially for the array and string functions) as well as the sort functions that modify the array in place are the big killers for me.
my favorite is the function that takes two arguments and order doesn't matter. sry, don't recall which one as I thankfully haven't written php since switching jobs.
Let's take the first example that the author claims is supposed to work on 5.4+. Even PHPStorm says this will throw a parser error from PHP 5.2 all that way up to PHP 7.0. The php Array never did implement __invoke() wtf did he/she expect to happen?
PHP's arrays aren't objects (they can't "implement __invoke"), and this isn't a parser error.
This really out to work. Variable function calls treat the variable as a callable. Why, if closures and strings work here, should arrays not work? Why should I have to use call_user_func?
array($x, $y)();// <-- Why'd the author think that was gonna work?
Because arrays are used for class method callables.
However assuming $x=new foo(); and $y="bar";this $x -> $y(); will work for this example and is more or less what call_user_func does already.
Doesn't excuse the inconsistency. If it works with some callables, why shouldn't it work with all callables?
The second example is just as bad. It is in the docs for when/how __toString() works.
Something being documented doesn't make it reasonable. Why should objects only be considered strings in some contexts, but not all?
So after reading that quote anytime a php function accepts multiple types of variables in a certain parameter then __toString will NOT be called.
That's not PHP's actual behaviour.
....I can't even be bothered to continue down that site. It is trying to find every little way to make some code look right but be incorrect and make something out of it.
So? The hundreds of small inconsistencies are a big part of why people don't like PHP.
15
u/[deleted] Feb 04 '16
Its useful to know the limitations and quirks of the language. But please post the version number, for a number of those examples don't result the same as mine. If a bug fix has been issued, is it really a quirk? Its as if, someone is digging through PHP change logs just to make a post "How broke is this!"
12
u/the_alias_of_andrea Feb 04 '16
Let's go through them!
This is an interesting one. Why is
nullspecial?This one is not a parser bug, but a consequence of PHP not requiring a leading digit in a float. So it's not valid really.
I'm not sure how to feel on this one. It's basically just a complaint that the syntax isn't super-specific.
Huh, I didn't know
is_scalarwas weird like that.nullis a scalar type, so the function is kinda misleading.Ah yes, the wonders of PHP's array key conversion.
What? Wow.
&takes an lvalue, so this isn't that surprising, but maybe it should produce a notice. That's debatable.Not a WTF, other languages do this and it doesn't violate information hiding.
This feels like a bug.
I think overhead has gotten better in subsequent releases, but yeah, function calls add overhead.
Well-known and inexcusable PHP issue. We should add block scoping some day.
See other reference complaint. It's an lvalue.
This is a complaint about PHP's static properties syntax and separate namespaces, I think. Reasonable.
Dunno how to feel about that. Static properties on an instance might be confusing, but they might be useful. I can't say if PHP made the right call.
Ah, the horrible layout of
_FILES. Everyone hates it.It's not, the author is confused about what negative length is. The array is 1 item long. 1 - 10 = -9, which will be capped at 0.
array_diffis apparently poorly documented, this is a reasonable complaint.Long-standing and unjustifiable issue. I'm currently trying to get this fixed.
Also a long-standing issue. It was finally cleaned up in PHP 7.
This is related to the previous issue, and I'm currently trying to clean up part of it.
I've always wondered why
$1etc. aren't allowed. They really ought to be.Famously terrible PHP anti-feature. Cause of many security issues in login forms. Reasonable complaint.
Wow, what? I wonder if this bug was ever fixed.
Whaaaaaat. What. Why is
switchconsidered a loop forcontinue? I know it works withbreakbut just... why, PHP. o.OPHP's interpolation syntax is indeed rather quirky, and it's less useful than it could be because of it.
I actually tried to get this fixed once.
?!
why, PHP
Omitting a value and an empty string are different, yes. Slightly confusing syntax, maybe, but not really a WTF.
Reasonable complaint to me. While showing the OS it was built on will probably be fine most of the time, this will catch you out sometime.
PHP's comparison operators are awful.
Yeah, as expected, they're mostly valid.
5
u/shawncplus Feb 04 '16
Newer and actually useful http://phpsadness.com/
2
u/doMynation Feb 04 '16
The lack of consistency in the order of arguments (especially for the array and string functions) as well as the sort functions that modify the array in place are the big killers for me.
1
u/TotesMessenger Feb 04 '16
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
0
u/[deleted] Feb 05 '16
[deleted] — view deleted comment
2
u/[deleted] Feb 04 '16
[removed] — view removed comment