1 | <?php |
||
8 | class ExceptionHandler |
||
9 | { |
||
10 | 4 | public function __construct() |
|
14 | |||
15 | /** |
||
16 | * @param string $name |
||
17 | * @param string $doc |
||
18 | */ |
||
19 | 3 | public function addExceptions($name, $doc) |
|
23 | |||
24 | /* |
||
25 | * @return array |
||
26 | * 返回包含异常类型和描述的数组 |
||
27 | * 示例 |
||
28 | * [ |
||
29 | * ['NotFoundHttpException', '这是说明'], |
||
30 | * ['ForbiddenHttpException', '这是说明'], |
||
31 | * ] |
||
32 | */ |
||
33 | 1 | public function getExceptions() |
|
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | * 示例 |
||
41 | * [ |
||
42 | * ['NotFoundHttpException', '这是说明'], |
||
43 | * ['ForbiddenHttpException', '这是说明'], |
||
44 | * ] |
||
45 | */ |
||
46 | private $exceptions = []; |
||
47 | |||
48 | /** |
||
49 | * @param Application $app |
||
50 | * @param callable $call |
||
51 | * @return \Symfony\Component\HttpFoundation\Response |
||
52 | */ |
||
53 | 1 | public function handler(Application $app, callable $call){ |
|
61 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: