Doc #80075 [NEW]: property_exists will return true for a protected member from a third class
From: liuduan2004 at 163 dot com
Operating system: mac 10.15.6
PHP version: 7.4.10
Package: Class/Object related
Bug Type: Documentation Problem
Bug description:property_exists will return true for a protected member from a third class
Description:
------------
---
From manual page: https://php.net/function.property-exists
---
my php version is PHP 7.4.8 with mac env(10.15.6)
eg:
class Object {
protected id_shop;
}
class Shop extends Object{
}
vardump(property_exists(new Shop(), "id_shop")); // will return true,
it's not the same as array_key_exists.
when your code is like below, error occurs
Class EntityMapper {
public function setField($shop, $key, $value) {
if (property_exists($shop,$key)) {
$shop->{$key} = $value; // handles public fields
return;
}
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=80075&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80075&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80075&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80075&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80075&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80075&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80075&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80075&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80075&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80075&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80075&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80075&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80075&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80075&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80075&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80075&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80075&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80075&r=mysqlcfg
Thread (1 message)
- liuduan2004 at 163 dot com