Home: http://perassi.org/2007/11/19/filter-chaings-using-reflection/ License: GPL 2 (http://www.gnu.org/licenses/gpl.html) */ class test_bed { public $mprefix = 'test_'; public function test_0(&$my_string) { if (strlen($my_string) > 5) { return false; } else { return true; } } public function test_1(&$my_string) { if (strstr($my_string, 'a') == false) { return false; } else { return true; } } public function test_2(&$my_string) { if (strstr($my_string, 'b') == false) { return false; } else { return true; } } } $tb_class = 'test_bed'; $ao = new ArrayObject(); $ao->append('aaa'); $ao->append('aabaaa'); $ao->append('aba'); $tbr_class = new ReflectionClass($tb_class); $methods = $tbr_class->getMethods(); $tbo = new $tb_class(); foreach ($ao as $i) { foreach ($methods as $method) { if (($method->isPublic() == true ) and (strpos($method->getName(), $tbo->mprefix) === 0)) { $a = $method->getName(); if ($tbo->$a($i) == false) { print $method->getName() . " failed\n"; break; } else { print $method->getName() . " passed\n"; } } } print "***\n"; }