1 | <?php |
||
13 | class DroppingStream implements StreamInterface |
||
14 | { |
||
15 | use StreamDecoratorTrait; |
||
16 | |||
17 | private $maxLength; |
||
18 | |||
19 | /** |
||
20 | * @param StreamInterface $stream Underlying stream to decorate. |
||
21 | * @param int $maxLength Maximum size before dropping data. |
||
22 | */ |
||
23 | 1 | public function __construct(StreamInterface $stream, int $maxLength) |
|
28 | |||
29 | 1 | public function write($string) |
|
45 | } |
||
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: