php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45744 Case sensitive callback behaviour
Submitted: 2008-08-07 10:01 UTC Modified: 2008-08-07 12:04 UTC
From: lstrojny@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.0alpha1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lstrojny@php.net
New email:
PHP Version: OS:

 

 [2008-08-07 10:01 UTC] lstrojny@php.net
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\"'))));





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-07 12:04 UTC] dmitry@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 22:00:01 2025 UTC