Created
August 28, 2014 05:51
-
-
Save alexpw/c44ff885aadfef5c342e to your computer and use it in GitHub Desktop.
xdebug segmentation fault 11; minimal test case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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