【发布时间】:2018-02-22 14:46:00
【问题描述】:
如何在 $exception 变量中获取异常建议?
现在我正在使用 PHPStorm。我记得在 Netbeans 中有一个函数可以创建正确的 PHPdoc。
class Controller {
/**
* @param $params
* @param callable $callback
* @return array|\Exception
*/
public final function query(array $params, $callback = null) {
try {
/** another dummy code */
} catch (\Exception $exception) {
/** Boom! Error! */
if (is_null($callback)) return $params; else return $callback(null, $exception);
}
}
}
class someController extends Controller {
public function someFunction() {
$someParams = [];
$this->query($someParams, function ($response, $exception) {
if ($exception) return print $exception->/**getMessage(), getCode() etc */;
/** more dummy code */
print $this->render("template.twig", $response);
});
}
}
【问题讨论】:
-
“$exception 变量中的异常建议”是什么意思?
-
安德鲁,带着你的减号离开这里 stalkuuuur