Bug #79749 [PATCH]: Object of class FFI could not be converted to bool in a simple if

From: Date: Mon, 29 Jun 2020 11:44:50 +0000
Subject: Bug #79749 [PATCH]: Object of class FFI could not be converted to bool in a simple if
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227723@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79749&edit=1 ID: 79749 Patch added by: cmb@php.net Reported by: kelunik@php.net Summary: Object of class FFI could not be converted to bool in a simple if Status: Verified Type: Bug Package: *Extensibility Functions Operating System: Ubuntu PHP Version: 8.0Git-2020-06-27 (Git) Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix #79749: Converting FFI instances to bool fails On GitHub: https://github.com/php/php-src/pull/5776 Patch: https://github.com/php/php-src/pull/5776.patch Previous Comments: ------------------------------------------------------------------------ [2020-06-27 20:57:17] kelunik@php.net Description: ------------ This works on PHP 7.4 and also works on PHP 8 with other objects like new \stdClass. Test script: --------------- <?php // create FFI object, loading libc and exporting function printf() $ffi = FFI::cdef( "int printf(const char *format, ...);", // this is regular C declaration "libc.so.6"); // call C printf() $ffi->printf("Hello %s!\n", "world"); if ($ffi) { print 'ok'; } Expected result: ---------------- Hello world! ok 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79749&edit=1

« previous php.bugs (#227723) next »