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: nikic@php.net 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] nikic@php.net
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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-14 08:24 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=befe10fd21c82e82d8621558b7998424ab6d2c6d
Log: Fix bug #78770
 [2020-08-14 08:24 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jul 28 15:01:23 2021 UTC