PHP Sadness

These are things in PHP which make me sad. They are real, objective issues which I have personally encountered in my normal day-to-day activites. Nothing on this site should be taken to be the view of my employer or is related to my employer in any way.

If you'd like to contact me (in a polite and constructive way), I'm @ericwastl on Twitter.

Update 2018-07-08: Updated reflection argument inspection for PHP 7.0.

Useless Error Reporting

#44 Detail in error messages

#16 Exception thrown without a stack frame

#1 Unexpected T_PAAMAYIM_NEKUDOTAYIM

#7 Parse error: syntax error, unexpected T_SL in...

#54 Empty T_ENCAPSED_AND_WHITESPACE tokens

Inconsistency

#4 Function naming (underscores)

#15 Function naming (prefixes)

#48 Function naming (to/2)

#6 Order of arguments (array manipulations)

#9 Order of arguments (array/string search)

#51 (<5.6) Occasionally significant parentheses

#52 Comparison operators

Outright Bugs

#50 Segfault during deep recursion

#13 Segfault with dba_*() functions

#19 (<5.3) Can point a variable into raw memory with array_walk and debug_backtrace

#22 (documented) The stream_tell() method cannot be overridden with a wrapper

#23 (<7.0) Can't inspect some kinds of arguments with reflection

#30 Ternary operator associativity

#36 (<5.3) Segfault when calling an undefined method on PDOStatement

#39 Declaring a function called __lambda_func() completely breaks create_function()

#53 (<5.4) Syntax errors re-arm superglobals

Cruft

#11 (<5.5) PHPE9568F34-D428-11d2-A769-00AA001ACF42

#45 Syntax verbosity (arrays and array keys)

Misleading/Confusing topics

#26 (<5.4) E_ALL = E_ACTUALLY_ALL & ~E_STRICT

#27 Bad function names - parse_str()

#34 mktime() argument order (not inconsistent, just confusing)

#47 Type-coercing comparison operators will convert numeric strings to numbers

#28 The empty($v) function is actually (!isset($v) || $v != true)-and-silence-warnings

Arbitrary Restrictions

#14 Can't throw exceptions from __toString() functions

#25 (<5.3) The func_get_args() function can't be used as a parameter

#38 (<7.0) Some error conditions are simply uncatchable

#40 (<5.4) The ob_start() function doesn't allow for a buffer length of 1 ("special value" for 4096)

#43 (<5.6) The array_fill() function doesn't allow length 0

#35 The explode() function won't split with empty string

Anti-Functional Design

#5 Sort functions operate in-place

#12 Functions that do many unrelated things

#21 (<5.4) Cannot chain lookups/calls

#32 (dubious) Function calls have enormous overhead (15x perl)

#42 Instanceof produces a syntax error on expressions

Missing Features

#17 Standard libc process control (fork/exec/etc)

#20 (<5.4) No string escape code for ESC (ascii 27), normally \e

#29 Can't decode php-session-format serialization outside a session

#49 (<5.5) No support for finally-type error handling

Object-Oriented System Issues

#8 Implementing all the right methods (array) still doesn't work in array functions

#18 (intended) Static variables in methods are bound to all instances of the class

#24 Seemingly redundant reflection methods with no documentation

#33 No good way to modify private method behavior in a testing environment

#41 Cannot create a final abstract class

Lexer/Parser Issues

#2 Member variable definition is a constant expression

#31 (<7.0) Fails to produce errors on bad octal

#37 (<5.6) Cannot do static concatenation in member variable definition

#46 Semicolon required at end of block