|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80221 Object-oriented interface for HashContext
Submitted: 2020-10-12 10:02 UTC Modified: 2020-10-12 11:01 UTC
From: divinity76 at gmail dot com Assigned:
Status: Suspended Package: hash related
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-10-12 10:02 UTC] divinity76 at gmail dot com
the current HashContext only has a procedural interface, 
some people would prefer having an Object-oriented interface instead. (the same way mysqli_query() & co has both a procedural and object-oriented api)

for example, the current way to hash $str1 and $str2 is:

$hc = hash_init("SHA1");
hash_update($hc, $str1);
hash_update($hc, $str2);
$result = hash_final($hc);

(i've omitted error-checking for brevity)
but if we had an OO interface, it could also be written as: 

$result = (new HashContext("SHA1"))->update($str1)->update($str2)->final();

some people would prefer that. something like this:

Test script:
$str1 = "foo";
$str2 = "bar";
$result = (new HashContext("SHA1"))->update($str1)->update($str2)->final();
echo $result;

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-12 11:01 UTC]
-Status: Open +Status: Suspended
 [2020-10-12 11:01 UTC]
That makes sense, but the details need to be discussed (and the
feature may require an RFC[1]), and this bug tracker isn't really
suitable for that kind of discussion.  Therefore please forward
that request to the internals mailing list[2].  For the time
being, I'm suspending this ticket.

[1] <>
[2] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon May 10 20:01:23 2021 UTC