| 1 | <?php |
||
| 17 | class ViewportSize implements \JsonSerializable |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Width. |
||
| 21 | * |
||
| 22 | * @var int |
||
| 23 | */ |
||
| 24 | private $width; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Height. |
||
| 28 | * |
||
| 29 | * @var int |
||
| 30 | */ |
||
| 31 | private $height; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Internal constructor. |
||
| 35 | * |
||
| 36 | * @param int $width |
||
| 37 | * @param int $height |
||
| 38 | */ |
||
| 39 | public function __construct($width, $height) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Format data for JSON serialization. |
||
| 47 | * |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | public function jsonSerialize() |
||
| 57 | } |
||
| 58 |
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: