Re: Re: want an Object-oriented interface for HashContext

From: Date: Tue, 13 Oct 2020 15:43:39 +0000
Subject: Re: Re: want an Object-oriented interface for HashContext
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-112046@lists.php.net to get a copy of this message
On Tue, 13 Oct 2020 at 16:33, Hans Henrik Bergan <divinity76@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]

« previous php.internals (#112046) next »