|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-10-04 08:25 UTC] cmb@php.net
-Assigned To:
+Assigned To: nikic
[2019-10-04 08:25 UTC] cmb@php.net
[2019-10-04 10:42 UTC] nikic@php.net
[2019-10-04 10:42 UTC] nikic@php.net
-Status: Assigned
+Status: Closed
[2019-10-04 10:43 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 16:00:02 2025 UTC |
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