php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78770 Incorrect callability check inside internal methods
Submitted: 2019-11-01 15:53 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: [email protected] Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.2.24 OS:
Private report: No CVE-ID: None
 [2019-11-01 15:53 UTC] [email protected]
Description:
------------
Due to the way zend_get_executed_scope() works, callability checks inside internal *methods* work different from internal *functions*. They will use the scope of the method itself, rather than the scope of the calling userland method.

The attached example uses an IntlChar method with "f" parameter to show the problem.

Test script:
---------------
<?php
  
class Test {
    public function method() {
        IntlChar::enumCharTypes([$this, 'privateMethod']);
    }

    private function privateMethod($start, $end, $name) {
    }
}

(new Test)->method();

Actual result:
--------------
Fatal error: Uncaught TypeError: IntlChar::enumCharTypes() expects parameter 1 to be a valid callback, cannot access private method Test::privateMethod() in /home/nikic/php-src/t074.php:5
Stack trace:
#0 /home/nikic/php-src/t074.php(5): IntlChar::enumCharTypes(Array)
#1 /home/nikic/php-src/t074.php(12): Test->method()
#2 {main}
  thrown in /home/nikic/php-src/t074.php on line 5


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-14 08:24 UTC] [email protected]
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jun 12 18:01:26 2025 UTC