mardi 20 novembre 2018

PHP - function reflection - get all return values without running the function

I have a function like

function foo($p){
   if ($p == "") return 0;
   return 5;
}

Is it possible somehow to get all return values that function can return (in this case 0 and 5)? I can run the function, but I dont know which value will case which return.

I am building some kind of a plugin system and this function is user defined as a lambda. So I dont know its complexity or possible inputs. To be able to get all return values, it would increase user-friendliness. Currently, user have to specify it manually via variable in function like this:

function setLambda($lambda, array $returnValues)...





Aucun commentaire:

Enregistrer un commentaire