1 | <?php |
||
19 | trait CountTrait { |
||
20 | /** |
||
21 | * Binds to count() method. This is equal to make $this->tree->size(). |
||
22 | * |
||
23 | * @return integer the tree size. 0 if it is empty. |
||
24 | */ |
||
25 | public function count() { |
||
28 | |||
29 | /** |
||
30 | * Returns the array size. |
||
31 | * |
||
32 | * @return int the length |
||
33 | */ |
||
34 | public function size() : int { |
||
37 | |||
38 | /** |
||
39 | * Checks if the list is empty. |
||
40 | * |
||
41 | * @return boolean true if is empty, else false. |
||
42 | */ |
||
43 | public function empty() : bool { |
||
46 | } |
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: