Somewhere in my __call magic method I'm invoking transactional, accepting a Closure:
try { $that = $this $this->conn->transactional(function ($conn) use ($that, $realMethod) { $result = call_user_func([$that, $realMethod], $conn); $this->conn->exec('SET foreign_key_checks = 1'); }); } catch (\Exception $e) { $this->conn->exec('SET foreign_key_checks = 1'); throw $e; } Is there any way to return $result from inside the Closure (or using pass by reference, etc.)?
Method $conn->transactional is not under my control:
public function transactional(Closure $func) { $this->beginTransaction(); try { $func($this); $this->commit(); } catch (Exception $e) { $this->rollback(); throw $e; } }