Req #46659 [Opn->Wfx]: I suggest changing get_functions_defined() function function
| From: | nikic@php.net | Date: | Sun, 23 Sep 2012 16:37:57 +0000 |
| Subject: | Req #46659 [Opn->Wfx]: I suggest changing get_functions_defined() function function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173657@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46659&edit=1
ID: 46659
Updated by: nikic@php.net
Reported by: Mike_G at ufamts dot ru
Summary: I suggest changing get_functions_defined() function
function
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
Closing as this information can already be easily obtained using Reflection:
foreach (get_defined_functions()['user'] as $function) {
echo $function, ' defined in ', (new ReflectionFunction($function))->getFileName();
}
I don't see a reason to add an argument for this to get_defined_functions() as it is a rather
narrow use case.
Previous Comments:
------------------------------------------------------------------------
[2008-11-24 10:10:07] Mike_G at ufamts dot ru
Description:
------------
I suggest changing get_functions_defined() function to have flag/option to return user function by
includes/requires.
Example:
#require1.php
<?php
function one()
{
return 1;
}
function two()
{
return 2;
}
?>
#require2.php
<?php
function three()
{
return 3;
}
function four()
{
return 4;
}
?>
#main code
<?php
require_once('require1.php');
require_once('require2.php');
$fn_arr = get_functions_defined(true); // true - is enabled return user function by
// includes and requires.
print_r($fn_arr);
?>
Output result:
Array ( [internal] => Array (
...
),
[user] => Array (
[require1.php] => Array ([0] => 'one', [1] =>
'two'),
[require2.php] => Array ([0] => 'three', [1] =>
'four'),
))
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46659&edit=1