php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73771 Wrong "return values" section
Submitted: 2016-12-17 09:49 UTC Modified: 2018-07-08 12:53 UTC
From: rjhdby@php.net Assigned:
Status: Verified Package: COM related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 + 11 = ?
Subscribe to this entry?

 
 [2016-12-17 09:49 UTC] rjhdby@php.net
Description:
------------
---
From manual page: http://www.php.net/function.variant-eqv
---


Totaly wrong:

"If each bit in left is equal to the corresponding bit in right then TRUE is returned, otherwise FALSE is returned."

This is BITWISE operation.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-17 11:43 UTC] requinix@php.net
-Package: Documentation problem +Package: COM related
 [2016-12-17 11:43 UTC] requinix@php.net
It's equivalence: returning boolean makes sense. And it mirrors the VarEqv documentation.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms221077(v=vs.85).aspx

What's the problem?
 [2016-12-17 18:20 UTC] andrewgrom at rambler dot ru
$a = new VARIANT(255, VT_UI1); // 11111111
$b = new VARIANT(2, VT_UI1);    // 00000010
$c = variant_eqv($a, $b);

echo "result is: ".$c;

result is: 2     <--- Does not match description   "If each bit in left is equal to the corresponding bit in right then TRUE is returned, otherwise FALSE is returned."

It is bitwise, not logical, operation.
 [2018-04-23 15:39 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2018-04-23 15:39 UTC] cmb@php.net
> It is bitwise, not logical, operation.

Indeed, so apparently MSDN is wrong, also wrt. VarXor which also
works bitwise.
 [2018-04-23 21:20 UTC] requinix@php.net
After some testing, VarEqv appears to return the same/similar type of value as it was passed; give it VT_BOOLs and it returns a VT_BOOL, or give it VT_UI8s and it returns a VT_UI8. I've also found some anecdotal evidence that VARIANTs have always blurred the line between integer and boolean.
Presumably this behavior extends to any situation where integers and booleans can be treated the same way, though with a bit more testing the return type is the same boolean/integer nature but not necessarily the same VT_* type - for example, VT_UI8(255) + VT_UI8(2) = VT_I4(2).

I'm thinking a warning in the variant_* functions that work with booleans (probably and,eqv,imp,not,or,xor), and/or a note in the VARIANT class docs that this type looseness happens.
 [2018-04-23 21:24 UTC] requinix@php.net
> VT_UI8(255) + VT_UI8(2) = VT_I4(2).
Er, that's an AND, not addition.
 [2018-07-08 12:53 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 [2018-07-08 12:53 UTC] cmb@php.net
It seems to me the COM documentation needs a general overhaul.
There's still a lot of talk about the differences between PHP 4
and 5, which is water under the bridge now.  Also, the return type
of variant_eqv() and lots of other variant_*() functions is given
as `mixed`, but is most certainly `VARIANT`.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 10:01:29 2024 UTC