1 | <?php |
||
8 | class MultipleErrors extends InvalidEmail |
||
9 | { |
||
10 | /** |
||
11 | * @var Reason[] |
||
12 | */ |
||
13 | private $reasons = []; |
||
14 | |||
15 | public function __construct() |
||
18 | |||
19 | public function addReason(Reason $reason) |
||
23 | |||
24 | /** |
||
25 | * @return Reason[] |
||
26 | */ |
||
27 | public function getReasons() : array |
||
31 | |||
32 | public function reason() : Reason |
||
36 | } |
||
37 |
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: