Req #80221 [NEW]: Object-oriented interface for HashContext
| From: | divinity76 at gmail dot com | Date: | Mon, 12 Oct 2020 10:02:54 +0000 |
| Subject: | Req #80221 [NEW]: Object-oriented interface for HashContext | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-229555@lists.php.net to get a copy of this message | ||
From: divinity76 at gmail dot com
Operating system:
PHP version: Next Minor Version
Package: hash related
Bug Type: Feature/Change Request
Bug description:Object-oriented interface for HashContext
Description:
------------
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:
https://3v4l.org/lXd3u
Test script:
---------------
<?php
$str1 = "foo";
$str2 = "bar";
$result = (new
HashContext("SHA1"))->update($str1)->update($str2)->final();
echo $result;
Expected result:
----------------
8843d7f92416211de9ebb963ff4ce28125932878
--
Edit bug report at https://bugs.php.net/bug.php?id=80221&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80221&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80221&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80221&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80221&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80221&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80221&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80221&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80221&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80221&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80221&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80221&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80221&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80221&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80221&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80221&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80221&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80221&r=mysqlcfg