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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 15:01:27 2024 UTC