|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-07 12:04 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 22:00:01 2025 UTC |
Description: ------------ When running the small examples below, the first version works fine, while the second triggers a warning: Warning: array_map() expects parameter 1 to be a valid callback, cannot access private method Bar::callBack() in /tmp/private_callback-buggy.php on line 6 The only difference between the two code snippets is the callback being camel case in the second example. Both versions work fine with 5.2. Reproduce code: --------------- First example: <?php class Foo { public function __construct(array $data) { var_dump(array_map(array($this, 'callback'), $data)); } private function callback($value) { if (!is_array($value)) { return stripslashes($value); } return array_map(array($this, 'callback'), $value); } } class Bar extends Foo { } var_dump(new Bar(array('foo' => 'bar', 'baz' => array('one', 'two\"')))); Second example: <?php class Foo { public function __construct(array $data) { var_dump(array_map(array($this, 'callBack'), $data)); } private function callBack($value) { if (!is_array($value)) { return stripslashes($value); } return array_map(array($this, 'callBack'), $value); } } class Bar extends Foo { } var_dump(new Bar(array('foo' => 'bar', 'baz' => array('one', 'two\"'))));