Bug #79462 [NEW]: method_exists and property_exists incoherent behavior

From: Date: Thu, 09 Apr 2020 01:02:26 +0000
Subject: Bug #79462 [NEW]: method_exists and property_exists incoherent behavior
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226498@lists.php.net to get a copy of this message
From: lucasfbustamante at gmail dot com Operating system: Linux PHP version: 7.4.4 Package: Compile Warning Bug Type: Bug Bug description:method_exists and property_exists incoherent behavior 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 bug report at https://bugs.php.net/bug.php?id=79462&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79462&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79462&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79462&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79462&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79462&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79462&r=support Expected behavior: https://bugs.php.net/fix.php?id=79462&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79462&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79462&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79462&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79462&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79462&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79462&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79462&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79462&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79462&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79462&r=mysqlcfg

« previous php.bugs (#226498) next »