Usando PHP, ¿hay una función/método/forma de verificar si una variable contiene algo que sería seguro poner en una construcción foreach? Algo así como¿Hay alguna manera de probar una variable para "isForEachable"
//the simple case, would probably never use it this bluntly
function foo($things)
{
if(isForEachable($things))
{
foreach($things as $thing)
{
$thing->doSomething();
}
}
else
{
throw new Exception("Can't foreach over variable");
}
}
Si su respuesta es "Configuración de un controlador para coger el error de PHP", se aprecian sus esfuerzos, pero estoy buscando otra cosa.
relacionadas: http://stackoverflow.com/questions/3584700/iterable-objects-and-array-type- Hinting/ – quantumSoup