Re:Moving from Go to PHP Again
by sandreas on Friday February 08, 2019 @07:47AM
(#19113637)
With the "callable" concept i meant, that many things are seen as callable:
[$obj, "methodName"] => callable for $obj->methodName()
"str_replace" => callable for function "str_replace"
["ClassName", "staticMethod"] => callable for ClassName::staticMethod()
"ClassName::staticMethod" => callable for ClassName::staticMethod()
function() {} => callable for a lambda
I would prefer a "ClassMethod" and a "Function" type, instead of using strings.
$x = phpinfo;
$x();
$y = $obj->method;
$y();
But i don't think, this is possible, because PHP supports global constants and function names cannot be distinguished from constants, especially because PHP is not case sensitive regarding functions and classnames.
But I see, that my karma has decreased with this post, so it seems, that not many are in my opinion...
[$obj, "methodName"] => callable for $obj->methodName()
"str_replace" => callable for function "str_replace"
["ClassName", "staticMethod"] => callable for ClassName::staticMethod()
"ClassName::staticMethod" => callable for ClassName::staticMethod()
function() {} => callable for a lambda
I would prefer a "ClassMethod" and a "Function" type, instead of using strings.
$x = phpinfo; $x();
$y = $obj->method; $y();
But i don't think, this is possible, because PHP supports global constants and function names cannot be distinguished from constants, especially because PHP is not case sensitive regarding functions and classnames.
But I see, that my karma has decreased with this post, so it seems, that not many are in my opinion...