TimingsHandler: return the result of $closure() for easier usage

this isn't type safe, but it doesn't matter a whole lot, and there's nothing we can do about it without generics.
This commit is contained in:
Dylan K. Taylor 2019-06-11 15:04:30 +01:00
parent de6053de11
commit 858f440bcf

View File

@ -184,10 +184,15 @@ class TimingsHandler{
}
}
public function time(\Closure $closure) : void{
/**
* @param \Closure $closure
*
* @return mixed the result of the given closure
*/
public function time(\Closure $closure){
$this->startTiming();
try{
$closure();
return $closure();
}finally{
$this->stopTiming();
}