mathiasverraes / jdump

J!Dump is a very easy to use debugging extension for Joomla developers and template designers. Download links below.
http://twitter.com/mathiasverraes
43 stars 25 forks source link

Can I use j!dump to find out where a class is defined? #29

Open newjie opened 9 years ago

newjie commented 9 years ago

I am a beginner with PHP and Joomla Core development. This great extension helps me a lot during my learning. A very frequent situation when I try to understand some code is, there is a method of a class being invoked in a line and I want to look into the definition of the class but have no idea where it is. Before j!dump, I had to download the extension in question and in-text search the class, which takes a lot of time. I believe this simple goal can be achieved by using j!dump, but I don't know how. It is like follows:

$messages = modPimediaplayerHelper::getStudy($params);

This line is found in a module's PHP file, I'd like to know where this modPimediaplayerHelper is defined, I tried dump(modPimediaplayerHelper) and dump(modPimediaplayerHelper::getStudy), both of them don't work, so what should I do?

By the way, when I try to dump($params), it returns a object without meaningful properties but only methods, which provokes me to look into how this $params object is defined also, how do I use j!dump to track it?

garstud commented 9 years ago

Hello, Sure, this is a point that can really help, I use the implemention of the Reflection process (native PHP 5), because it is not provided by jDump (... for now ;))

There it is how you can solve it :

$ref = new ReflectionClass('JModuleHelper');
dump($ref->getFileName(), 'Reflection Class path for '.$ref->getName());

It will execute the Reflection process on the name of the class in parameter (JModuleHelper). You juste have to 'dump' the getFileName() method on the resulted object and it's done !

jdump-reflection_class

Hope it helps ;)