php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24926 a lambda function (create_function()) cannot be stored in a class property
Submitted: 2003-08-03 16:37 UTC Modified: 2003-12-27 11:33 UTC
Votes:26
Avg. Score:4.9 ± 0.4
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kris dot hofmans at pandora dot be Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-11-29 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kris dot hofmans at pandora dot be
New email:
PHP Version: OS:

 

 [2003-08-03 16:37 UTC] kris dot hofmans at pandora dot be
Description:
------------
As soon as a lamba function created by create_function gets stored in a class property it cannot be called anymore.

Errors while trying:

Warning: call_user_func(bleh::): First argument is expected to be a valid callback in /home/blacky/public_html/php5-dev/callback-test.php on line 66

And

Fatal error: Call to a member function test() on a non-object in /home/blacky/public_html/php5-dev/callback-test.php on line 36

with test being my defined function.

The closest bug report I could find resembling this problem is: http://bugs.php.net/bug.php?id=21909

Reproduce code:
---------------
http://bbox.homelinux.net:4000/~blacky/php5-dev/callback-test.phps

Expected result:
----------------
I'd like to store functions in a property, preferably an array and call them like

$this->property[$index]($arg1, $arg2);

Actual result:
--------------
Warning: call_user_func(bleh::): First argument is expected to be a valid callback in /home/blacky/public_html/php5-dev/callback-test.php on line 66

Or

Fatal error: Call to a member function test() on a non-object in /home/blacky/public_html/php5-dev/callback-test.php on line 36

I'd expected both cases to work, first one being more logical.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-28 21:27 UTC] sniper@php.net
Note: Works fine with PHP 4..

 [2003-12-27 11:33 UTC] helly@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Btw: Your code example is wrong because you declared the class bleh twice. Also you cannot call a non method with $this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC