|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79749 Object of class FFI could not be converted to bool in a simple if
Submitted: 2020-06-27 20:57 UTC Modified: 2020-06-29 11:41 UTC
From: Assigned:
Status: Closed Package: *Extensibility Functions
PHP Version: 8.0Git-2020-06-27 (Git) OS: Ubuntu
Private report: No CVE-ID: None
 [2020-06-27 20:57 UTC]
This works on PHP 7.4 and also works on PHP 8 with other objects like new \stdClass.

Test script:
// create FFI object, loading libc and exporting function printf()
$ffi = FFI::cdef(
    "int printf(const char *format, ...);", // this is regular C declaration
// call C printf()
$ffi->printf("Hello %s!\n", "world");
if ($ffi) {
    print 'ok';

Expected result:
Hello world!

Actual result:
Hello world!
PHP Recoverable fatal error:  Object of class FFI could not be converted to bool in /home/kelunik/test.php on line 8


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-28 05:27 UTC]
-Package: Scripting Engine problem +Package: ffi
 [2020-06-28 05:28 UTC]
-Package: ffi +Package: Scripting Engine problem
 [2020-06-29 11:41 UTC]
-Status: Open +Status: Verified -Package: Scripting Engine problem +Package: *Extensibility Functions
 [2020-06-29 11:44 UTC]
The following pull request has been associated:

Patch Name: Fix #79749: Converting FFI instances to bool fails
On GitHub:
 [2020-06-29 14:03 UTC]
Automatic comment on behalf of
Log: Fix #79749: Converting FFI instances to bool fails
 [2020-06-29 14:03 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 00:01:28 2024 UTC