php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #30063 call_user_func callable for instance methods, but not documented
Submitted: 2004-09-11 04:46 UTC Modified: 2004-09-12 11:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: aqsalter at westnet dot com dot au Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2004-09-11 04:46 UTC] aqsalter at westnet dot com dot au
Description:
------------
the current documentation for call_user_func and 
call_user_func_array does not mention that it can be 
used for calling instances as well...
There is some information in one of the comments to 
call_user_func.

Reproduce code:
---------------
<?php 

class provider { 
  function myfunction($x) { 
   echo "burak was at $x\n"; 
  } 
} 


$x= new provider(); 

call_user_func(array($x,'myfunction'),"a conference");

?>

Expected result:
----------------
burak was at a conference

Actual result:
--------------
The documentation does not mention that you can use 
call_user_func with instance methods.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-11 11:49 UTC] aidan@php.net
I don't know what is meant by "calling instances", I assume he means "ability to call a method of a class" - This information should be present, but not on this page.

I think we need some information about the "callback" type. This information really isn't specific to call_user_func, either.

I suggest we pop a language.types.callback page in, and link it somehow from pages that use a callback function.
 [2004-09-11 13:16 UTC] et@php.net
You mean something http://www.php.net/pseudo-types#language.types.callback ?

 [2004-09-11 13:17 UTC] et@php.net
Argh. "something like"
 [2004-09-11 14:55 UTC] aidan@php.net
Hah,

That'll teach me.

I ponder, how can we best link that information to pages that use a callback?

An entity?
Put it in the see-also?

Also, aqsalter, I hope this has answered your question. We'll work out how to make the information more accessable so the problem does not recur. Thanks for taking the time to contribute.
 [2004-09-11 18:35 UTC] betz@php.net
Add something like
See also
<function>foo</function>, 
.... 
and information about <type>callback</type>.

to every function which make use of callbacks.

The additional text : "and information ...." could exist as entity, of course ;-)
 [2004-09-12 10:11 UTC] reunion at pacific dot net dot au
aqsalter here:
I can't add comments for some reason. What's going on?
 [2004-09-12 10:14 UTC] reunion at pacific dot net dot au
If I put in comments with email address of 
aqsalter@westnet.com.au the comment is not added. Is 
this a bug in the bug tracker?

OK.
To reply to everybody's ealier questions:
Aidan: I was talking about "instance methods" of a class 
as opposed to "static methods". The documentation for 
call_user_func mentions static methods, but the 
callbacks link supplied by et mentions instance methods 
as well (which is great ;)
All: The callbacks docs are exactly what I was after. 
Thanks all for such a quick and community driven 
response.

Finally, the address listed above reunion@pacific.net.au 
will also work for me.
 [2004-09-12 11:02 UTC] aidan@php.net
I'll implement the entity now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 10:01:28 2024 UTC