| 1 | <?php |
||
| 5 | trait CountTrait { |
||
| 6 | /** |
||
| 7 | * Binds to count() method. This is equal to make $this->tree->size(). |
||
| 8 | * |
||
| 9 | * @return integer the tree size. 0 if it is empty. |
||
| 10 | */ |
||
| 11 | public function count() { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Returns the array size. |
||
| 17 | * |
||
| 18 | * @return int the length |
||
| 19 | */ |
||
| 20 | public function size() : int { |
||
| 23 | } |
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: