Bug #78632 [NEW]: method_exists() in php74 works differently from php73 in checking priv. methods
| From: | work at iskida dot com | Date: | Fri, 04 Oct 2019 02:18:31 +0000 |
| Subject: | Bug #78632 [NEW]: method_exists() in php74 works differently from php73 in checking priv. methods | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-223043@lists.php.net to get a copy of this message | ||
From: work at iskida dot com
Operating system: Fedora 30
PHP version: 7.4.0RC3
Package: Reflection related
Bug Type: Bug
Bug description:method_exists() in php74 works differently from php73 in checking priv. methods
Description:
------------
method_exists() in php74 works differently from php73 in checking
private methods
versions used
php73 PHP 7.3.5 (cli) (built: Apr 30 2019 08:37:17) ( NTS )
php74 PHP 7.4.0RC3 (cli) (built: Oct 1 2019 08:30:29) ( NTS )
Operating system
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description: Fedora release 30 (Thirty)
Test script:
---------------
class Base {
public function __get($k) {
$m = '_get_'.$k;
if (!method_exists($this, $m)) throw new
\Exception('no-property:'.$k);
return $this->$m();
}
private function _get_a() { return 'a'; }
}
class Test extends Base {}
$x = new Test;
echo $x->a;
//php74 : PHP Fatal error: Uncaught Exception: no-property-a in
test.php
//php73 : prints a
Expected result:
----------------
I expect both php73 and php74 printing "a"
note that _get_a() method is properly executed (when no check with
"method_exists" is done) both by php73 and php74.
class Base {
public function __get($k) {
$m = '_get_'.$k;
//NO check
return $this->$m();
}
private function _get_a() { return 'a'; }
}
class Test extends Base {}
$x = new Test;
echo $x->a;
//prints "a" both in php73 and php74
***So I expect that method_exists() in php74 should return (bool) true
as in php73...because the method "EXISTS" is reached and executed***,
or, for consinstency, php74 should throw a "PHP Fatal error: Uncaught
Error: Call to private method Test::_get_a()" when accessing _get_a()
method. (But a huge amount of codebase is involved with no doubt)
Actual result:
--------------
php74 : PHP Fatal error: Uncaught Exception: no-property-a in test.php
php73 : prints a
--
Edit bug report at https://bugs.php.net/bug.php?id=78632&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78632&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78632&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78632&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78632&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78632&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78632&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78632&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78632&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78632&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78632&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78632&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78632&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78632&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78632&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78632&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78632&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78632&r=mysqlcfg