PHP Sadness

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

Declaring a function called __lambda_func causes any call to php create_function to become a fatal instead:

$ cat tmp.php
<?php
function __lambda_func() {}

$fn = create_function("", "");
?>

$ php tmp.php
Fatal error: Cannot redeclare __lambda_func() (previously declared in tmp.php:2) in tmp.php(4) : runtime-created function on line 1

This is because php create_function eval-declares the function __lambda_func, then modifies the symbol table so that the function is instead named "\0lambda_".(++$i), and returns that name.

Significance: Implications for Internals

The mere presence of this issue tends to imply some fatal flaw or unnecessary complexity at the most basic levels of the language. For example, an overly complex parser might be trying to compensate for missing functionality in the interpreter by incorrectly (and misleadingly) validating code at the syntax level, or messages without details could indicate that the internal design prohibits access to values where they should be reachable in a sane implementation.