Skip to content

Instantly share code, notes, and snippets.

@alexpw
Created August 28, 2014 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpw/c44ff885aadfef5c342e to your computer and use it in GitHub Desktop.
Save alexpw/c44ff885aadfef5c342e to your computer and use it in GitHub Desktop.
xdebug segmentation fault 11; minimal test case
<?php
class F
{
public static $fns = [
'apply' => 'call_user_func_array',
'min' => 'min',
];
public static function __callStatic($method, $args)
{
$f = self::$fns[$method];
return call_user_func_array($f, $args);
}
}
// Fails
F::apply('min', [1,2,3]);
// Works
F::min([1,2,3]);
// Works
F::$fns['identity'] = function ($x) { return $x; };
F::identity([1,2,3]);
// Works
F::$fns['all'] = function ($f, $xs) {
foreach ($xs as $x) {
if (! call_user_func_array($f, [$x])) {
return false;
}
}
return true;
};
F::all(function ($x) { return is_integer($x); }, [1,2,3]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment