Reflection and used classes

This is a discussion on Reflection and used classes within the PHP Language forums, part of the PHP Programming Forums category; Hi Folks, Is there any way of using reflection to find out what classes other classes use? I do not ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-25-2008
Hugh Oxford
 
Posts: n/a
Default Reflection and used classes

Hi Folks,

Is there any way of using reflection to find out what classes other
classes use?

I do not mean which classes extend other classes, I mean within methods,
for example, where the "new" keyword instantiates objects of other classes.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 04-27-2008
petersprc
 
Posts: n/a
Default Re: Reflection and used classes

Hi,

Don't know of a way to this with reflection.

You can use PHPXref to locate references to a particular class, or you
could try a recursive grep for a class identifier.

Regards,

John Peters

On Apr 25, 2:37 pm, Hugh Oxford <ares...@fas.com> wrote:
> Hi Folks,
>
> Is there any way of using reflection to find out what classes other
> classes use?
>
> I do not mean which classes extend other classes, I mean within methods,
> for example, where the "new" keyword instantiates objects of other classes.
>
> Any ideas?


Reply With Quote
  #3 (permalink)  
Old 04-27-2008
Hugh Oxford
 
Posts: n/a
Default Re: Reflection and used classes

petersprc wrote:
> Hi,
>
> Don't know of a way to this with reflection.
>
> You can use PHPXref to locate references to a particular class, or you
> could try a recursive grep for a class identifier.
>
> Regards,
>
> John Peters
>


I like PHPxref, the problem is I use autoload. Maybe I could look at the
code.

Reply With Quote
  #4 (permalink)  
Old 04-27-2008
Alexey Kulentsov
 
Posts: n/a
Default Re: Reflection and used classes

Hugh Oxford wrote:

> Is there any way of using reflection to find out what classes other
> classes use?
>
> I do not mean which classes extend other classes, I mean within methods,
> for example, where the "new" keyword instantiates objects of other classes.
>
> Any ideas?


Sorry, but in languages like PHP here is no way to do such things
reliably. This is real code from my current project:

<CODE>
....
$classname=self::getClassName($classId);
$filename=strtolower($classId.'.object.php');

include_once $filename;

$object= new $classname($this,$parentId,$name);
....
</CODE>

Class names taken from XML file. So if you have case like this and
PHPxref is not enough for you - I think here are tools to do this as you
want.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:48 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0