php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51855 Optional tuning parameter for get_defined_functions and get_defined_constants
Submitted: 2010-05-19 02:02 UTC Modified: 2018-07-29 02:27 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: a at b dot c dot de Assigned: requinix (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.2 OS: Irrelevant
Private report: No CVE-ID: None
 [2010-05-19 02:02 UTC] a at b dot c dot de
Description:
------------
get_defined_constants() offers an optional parameter which, when passed true, categorises the constants by extension.

get_defined_functions() returns a list of function names categorised by whether they are "user" or "internal".

Both could benefit from being able to specify an actual category, instead of just that the returned list be categorised. For example, get_defined_functions('internal') would return a one-dimensional numerically-indexed array of internally-defined functions.

It's mainly for convenience: avoiding the extra variable, and depending on the internals some work collating the data.

Since the list of extensions is so variable from configuration to configuration, it would be infeasible to define("DEFINED_CONSTANTS_PCRE", "pcre") and so forth.

If the syntax engine could be convinced then this suggestion would be redundant, since it could then be achieved as get_defined_functions()['internal'].

Test script:
---------------
print_r(get_defined_functions('internal'));

Equivalent to:

$functions = get_defined_functions();
print_r($functions['internal']);


Expected result:
----------------
Array(
            [0] => zend_version
            [1] => func_num_args
            [2] => func_get_arg
            [3] => func_get_args
            [4] => strlen
            ....
)

Actual result:
--------------
A Warning is triggered stating that get_defined_functions() expects exactly 0 parameters, not the 1 that it was given. print_r() outputs null.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-19 02:04 UTC] a at b dot c dot de
Oh, one other thing ... the optional parameter to get_defined_constants() would be of type mixed: give it true and it behaves as it does currently, give it a string and it will restrict its results to the extension with the given name.
 [2016-03-25 20:06 UTC] andreas at dqxtech dot net
https://bugs.php.net/bug.php?id=71903&thanks=4
 [2018-07-29 02:23 UTC] a at b dot c dot de
As suggested in the original post, and due to the resolution of bug #47161, this can now be resolved as

get_defined_functions()['internal']
 [2018-07-29 02:27 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC