php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69941 Casting a Variant object to boolean makes it false
Submitted: 2015-06-26 14:17 UTC Modified: 2015-06-26 17:14 UTC
From: kalle@php.net Assigned: kalle (profile)
Status: Not a bug Package: COM related
PHP Version: 7.0.0alpha2 OS: Windows
Private report: No CVE-ID: None
 [2015-06-26 14:17 UTC] kalle@php.net
Description:
------------
Much like Bug #69939, this is the same is true for a Variant object:

var_dump((boolean) new Variant); // bool(true)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 14:17 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: kalle
 [2015-06-26 14:37 UTC] cmb@php.net
It seems to me that is intended behavior. If the first parameter
($value) is ommitted a VT_EMPTY object is created, which is
supposed to be treated as FALSE. The following yield TRUE, for
instance:

    (bool) new VARIANT(1)
    (bool) new VARIANT("foo")
    (bool) new VARIANT(true)
 [2015-06-26 17:14 UTC] kalle@php.net
-Status: Assigned +Status: Not a bug
 [2015-06-26 17:14 UTC] kalle@php.net
Agreed Chris, seems like com was the only instance of such
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Oct 04 04:05:53 2022 UTC