Bug #79462 [Asn->Csd]: method_exists and property_exists incoherent behavior

From: Date: Thu, 09 Apr 2020 09:38:56 +0000
Subject: Bug #79462 [Asn->Csd]: method_exists and property_exists incoherent behavior
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226504@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79462&edit=1 ID: 79462 Updated by: cmb@php.net Reported by: lucasfbustamante at gmail dot com Summary: method_exists and property_exists incoherent behavior -Status: Assigned +Status: Closed Type: Bug Package: Class/Object related Operating System: Linux PHP Version: 7.4.4 Assigned To: girgias Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6458d67cfa54cdcd6d3c96897106fa8cb738414 Log: Fix #79462: method_exists and property_exists incoherent behavior Previous Comments: ------------------------------------------------------------------------ [2020-04-09 09:20:48] cmb@php.net The following pull request has been associated: Patch Name: Fix #79462: method_exists and property_exists incoherent behavior On GitHub: https://github.com/php/php-src/pull/5362 Patch: https://github.com/php/php-src/pull/5362.patch ------------------------------------------------------------------------ [2020-04-09 08:04:52] nikic@php.net We probably should change method_exists() to throw TypeError, just like property_exists() does now. ------------------------------------------------------------------------ [2020-04-09 01:02:26] lucasfbustamante at gmail dot com Description: ------------ This output speaks more than a thousand words: https://3v4l.org/oRnjq The first argument of method_exists just returns false if it's not an object, while it's twin method, property_exists, shows a warning if the exact same thing happens. This behavior is inconsistent and prone to cause confusion amongst users. I'd like to suggest that property_exists just returns false if the first argument is not an object, like method_exists does. Best regards, Lucas Test script: --------------- <?php var_dump( method_exists(null, 'foo') ); var_dump( property_exists(null, 'foo') ); Expected result: ---------------- property_exists returns false if the first argument is not an object Actual result: -------------- property_exists throws a warning if the first argument is not an object ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79462&edit=1

« previous php.bugs (#226504) next »