Bug #78770 [NEW]: Incorrect callability check inside internal methods
From: nikic
Operating system:
PHP version: 7.2.24
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Incorrect callability check inside internal methods
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
--
Edit bug report at https://bugs.php.net/bug.php?id=78770&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78770&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78770&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78770&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78770&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78770&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78770&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78770&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78770&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78770&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78770&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78770&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78770&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78770&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78770&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78770&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78770&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78770&r=mysqlcfg
Thread (2 messages)
- nikic@php.net