Hi, can someone give me idea how can I get information about namespace, class and method name and all parameters names for all public methods in class that extends MyMainClass?
For example, I have script like this:

<?php
require 'MyMainClass.php';
namespace myNameSpace;
class MyClass extends MyMainClass
{
public function myFunctionOne($firstParam,$otherParam)
{} 
public function myFunctionTwo($paramName)
{}
}
class MyOtherClass extends MyMainClass
{
public function myFunction()
{} 
}
?>

I want to have as output something like this:
myNameSpace->[MyClass]->[myFunctionOne]->[params: "firstParam, otherParam"]
myNameSpace->[MyClass]->[myFunctionTwo]->[params: "paramName"]
myNameSpace->[MyOtherClass]->[myFunction]->[params: ""]

Hi,

I think the closest you can get is to use the function get_class_methods(), to which you pass the class name for which you want the method. Although this doesn't provide a list of the method parameters.

// E.g. If calling from within the class for which you want all the methods
get_class_methods(__CLASS__);

R.

Yes, I know for that function

get_class_methods

but I want more sophisticated solution unfortunately.

I figure it out that I need to use reflection to receive information I want, but I'm not sure how...

Does anyone read this? :)

I have this code now:

<?php
require("MyReflectionClass.php");
class MySimpleClass {//should not be catch for reflection
	public static function MyFunction()
	{}
}
class MyOtherClass extends MyReflectionClass{ //should be cached for reflection
	public static function MyFunction($firstParam,$secondParam) //should be cached for reflection
	{}
	public static function MyFunctionNoTwo() //should be cached for reflection
	{}
}
function MySimpleFunction() //should not be catch for reflection
{}
new MyReflectionClass();
?>

and this as "MyReflectionClass.php"

<?php	
class MyReflectionClass
{
	private function GetReflection()
	{		
		$reflector = new ReflectionClass("MyReflectionClass"); 
		echo "Class name: ".$reflector->getName()."<br/>";
		echo "Defined in file: ".$reflector->getFileName()."<br/>"; 		
		
		foreach (get_class_methods("MyReflectionClass") as $methodName) {
			echo "<br/>Method found: $methodName<br/>";
			$method = $reflector->getMethod($methodName);		
			$parameters = $method->getParameters();
			var_dump($parameters);			
		} 
	}	
	function __construct() {
       $this->GetReflection();
	}
}
?>

How can I get all class reflection that MyReflectionClass extends, in this case for class "MyOtherClass"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.