On Tue, 13 Oct 2020 at 16:33, Hans Henrik Bergan <divinit...@gmail.com>
wrote:

> also the sample class in the 3v4l link has an issue i hadn't thought
> of: i wanted to support method chaining, so i made nearly everything
> return `:self` , but hash_update_stream() returns int, the number of
> bytes actually read from the stream. that could easily be fixed with a
> `updateStream($stream, int $length = -1, int &$bytesRead = null):self`
> or something tho
>


I think I'd prefer to drop the fluent interface (returning void on most
things, and relevant values on others) than have to use reference
parameters. Since PHP doesn't have actual "out" parameters, references like
that are awkward for static analysis; and simple things like using them in
conditions becomes much more verbose:

$result  = null;
$foo->updateStream($bar, bytesRead: $result)
if ( $result > 42 ) ...

vs

if ( $foo->updateStream($bar) > 42 ) ...

Regards,
-- 
Rowan Tommins
[IMSoP]

Reply via email to