473,396 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

List of PHP functions and classes

In Smalltalk I can get the list of the classes, methods and global
variables by querrying a global dictionary. In addition you can get the
arguments.

I know in PHP one can get the list of globals via the $GLOBALS array.

But Is there a way to get the list of all the functions and
classes/methods (and arguments) currently loaded in PHP by using
reflection?

Thank you

May 15 '06 #1
3 2963
ImOk said the following on 15/05/2006 18:18:
In Smalltalk I can get the list of the classes, methods and global
variables by querrying a global dictionary. In addition you can get the
arguments.

I know in PHP one can get the list of globals via the $GLOBALS array.

But Is there a way to get the list of all the functions and
classes/methods (and arguments) currently loaded in PHP by using
reflection?

PHP 5 implements reflection, although the documentation is somewhat
hidden away in the manual, under Classes and Objects.
http://uk.php.net/manual/en/language...reflection.php.

The documentation is also somewhat spartan, but with some
experimentation you should be able to get the reflection classes to work.
--
Oli
May 15 '06 #2
I tried the test according to the docs. It seems the method of
ReflectionFunction->getParameters() does not work for internal
functions although it detects the parameters. Any ideas? Is this a bug
or am i doing something wrong?

<?php
print phpversion(); // 5.1.4

function baz(ReflectionFunction $a, $b = 1, $c = null) { }

// Create an instance of Reflection_Function with the
// parameter given from the command line.
$reflect = new ReflectionFunction("baz"); // works for this one.
//$reflect = new ReflectionFunction("strncmp"); // e.g. does not work
for this function

echo $reflect;

foreach ($reflect->getParameters() as $i => $param) {
printf(
"-- Parameter #%d: %s {\n".
" Class: %s\n".
" Allows NULL: %s\n".
" Passed to by reference: %s\n".
" Is optional?: %s\n".
"}\n",
$i,
$param->getName(),
var_export($param->getClass(), 1),
var_export($param->allowsNull(), 1),
var_export($param->isPassedByReference(), 1),
$param->isOptional() ? 'yes' : 'no'
);
}

?>

May 16 '06 #3
Hi,

Nice to find another Smalltalker here. I guess you already have most of
your answer. Of course you still need some list of classes. With
phpPeanuts i have a classloading function that keeps such a list in a
global variable. It was meant for use with php4, to look up the
classname in original case from the lower case result php4's get_class
function gives, but i guess you can use it for other kinds of reflection
too:
function includeClass($className, $dirPath='') {
if ($dirPath && substr($dirPath, -1) != '/')
$dirPath .= '/';

$result = require_once("../classes/$dirPath"."$className.php");

if ($result)
$GLOBALS['PntIncludedClasses'][strtolower($className)] = $className;

return $result;
}
Greetings,

Henk Verhoeven,
www.metaclass.nl.

BTW, if you also miss the senders and implementers search, you could
take a look at this hypercode browser:
http://www.phppeanuts.org/site/index...7/methods.html
(To my regret i did still did not find time to make it an aplha download..)
ImOk wrote:
In Smalltalk I can get the list of the classes, methods and global
variables by querrying a global dictionary. In addition you can get the
arguments.

I know in PHP one can get the list of globals via the $GLOBALS array.

But Is there a way to get the list of all the functions and
classes/methods (and arguments) currently loaded in PHP by using
reflection?

Thank you

May 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fernando Rodriguez | last post by:
Hi, How can I get the list of all the functions defined in the current module?
6
by: Kamilche | last post by:
I can't figure out how to list all functions from an imported module. I searched Google, but all the answers I found didn't work. Did something change in Python 2.2, perhaps there's a new method of...
11
by: Michael B. Allen | last post by:
Coming from C and Java on *nix I'm a little out of my element messing around with CList and MSVC++ but I think my issues are largely syntactic. I have an ADT that I use called a 'varray' that can...
1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
5
by: Darryl B | last post by:
I can not get anywhere on this project I'm tryin to do. I'm not expecting any major help with this but any would be appreciated. The assignment is attached. The problem I'm having is trying to set...
2
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking afterwards with ILDASM at what is visible in those assemblies from a...
3
by: moondaddy | last post by:
I wrote my own List class which I use to bind to list controls. this class inherits CollectionBase and implements IBindingList. This class contains a list of business classes such as customers...
9
by: Paulo da Silva | last post by:
Hi! What is the best way to have something like the bisect_left method on a list of lists being the comparision based on an specified arbitrary i_th element of each list element? Is there,...
4
by: Jim Langston | last post by:
This should illistrate what I am trying to do: template <class T> T SomeFunction( T parm ) { return parm; } template <class T> class SomeClass
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.