Classes and Functions
am 01.11.2009 21:50:55 von Daniel Kolbo
Hello,
Is there a way to see what objects and functions a script
loaded/required/used?
I could recursively loop through the globals, but if objects were unset,
then i may miss some.
I could make a 'tracking' object and every time i load/include a file
(which contains a class def or a function def) to add that file to the
tracking object...but it would be nice if i didn't have to modify my
existing code to see which objects and functions a script actually used,
or at least, requested and loaded into memory.
Thanks in advance,
Daniel Kolbo
`
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Classes and Functions
am 01.11.2009 21:59:03 von Mathieu Rochette
--001517447f0c1c2b88047755895d
Content-Type: text/plain; charset=UTF-8
On Sun, Nov 1, 2009 at 9:50 PM, Daniel Kolbo wrote:
> Hello,
>
> Is there a way to see what objects and functions a script
> loaded/required/used?
>
I don't think it's possible to that in PHP code.
>
> I could recursively loop through the globals, but if objects were unset,
> then i may miss some.
>
> I could make a 'tracking' object and every time i load/include a file
> (which contains a class def or a function def) to add that file to the
> tracking object...but it would be nice if i didn't have to modify my
> existing code to see which objects and functions a script actually used,
> or at least, requested and loaded into memory.
>
maybe what you are looking for is xdebug (http://xdebug.org/). It provide
code coverage analysis.
>
> Thanks in advance,
> Daniel Kolbo
> `
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
--001517447f0c1c2b88047755895d--
Re: Classes and Functions
am 01.11.2009 22:46:56 von Larry Garfield
On Sunday 01 November 2009 2:50:55 pm Daniel Kolbo wrote:
> Hello,
>
> Is there a way to see what objects and functions a script
> loaded/required/used?
>
> I could recursively loop through the globals, but if objects were unset,
> then i may miss some.
>
> I could make a 'tracking' object and every time i load/include a file
> (which contains a class def or a function def) to add that file to the
> tracking object...but it would be nice if i didn't have to modify my
> existing code to see which objects and functions a script actually used,
> or at least, requested and loaded into memory.
>
> Thanks in advance,
> Daniel Kolbo
> `
Depends what you are trying to do with it, but I suspect these are a good
start:
http://www.php.net/get_defined_functions
http://www.php.net/get_defined_vars
http://www.php.net/get_defined_constants
http://www.php.net/get_declared_classes
http://www.php.net/get_declared_interfaces
http://www.php.net/get_included_files
--
Larry Garfield
larry@garfieldtech.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Classes and Functions
am 02.11.2009 14:41:02 von Martin Scotta
--0015175cf9c051d946047763879b
Content-Type: text/plain; charset=ISO-8859-1
On Sun, Nov 1, 2009 at 6:46 PM, Larry Garfield wrote:
> On Sunday 01 November 2009 2:50:55 pm Daniel Kolbo wrote:
> > Hello,
> >
> > Is there a way to see what objects and functions a script
> > loaded/required/used?
> >
> > I could recursively loop through the globals, but if objects were unset,
> > then i may miss some.
> >
> > I could make a 'tracking' object and every time i load/include a file
> > (which contains a class def or a function def) to add that file to the
> > tracking object...but it would be nice if i didn't have to modify my
> > existing code to see which objects and functions a script actually used,
> > or at least, requested and loaded into memory.
> >
> > Thanks in advance,
> > Daniel Kolbo
> > `
>
> Depends what you are trying to do with it, but I suspect these are a good
> start:
>
> http://www.php.net/get_defined_functions
> http://www.php.net/get_defined_vars
> http://www.php.net/get_defined_constants
> http://www.php.net/get_declared_classes
> http://www.php.net/get_declared_interfaces
> http://www.php.net/get_included_files
>
> --
> Larry Garfield
> larry@garfieldtech.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You can use the tokenizer's functions to parse the files and recover the
information.
They are easy to understand and make the perfect tool for this kind of
scenario.
I'd like to know how do you solve this.
cheers
--
Martin Scotta
--0015175cf9c051d946047763879b--
Re: Classes and Functions
am 04.11.2009 15:44:26 von Nathan Rixham
Daniel Kolbo wrote:
> Hello,
>
> Is there a way to see what objects and functions a script
> loaded/required/used?
>
> I could recursively loop through the globals, but if objects were unset,
> then i may miss some.
>
> I could make a 'tracking' object and every time i load/include a file
> (which contains a class def or a function def) to add that file to the
> tracking object...but it would be nice if i didn't have to modify my
> existing code to see which objects and functions a script actually used,
> or at least, requested and loaded into memory.
>
> Thanks in advance,
> Daniel Kolbo
> `
>
if it's for debugging, get a good debugger so you can inspect at break
points; for use during runtime and something "scripted" you can call the
relevant get_defined/declared functions before before your app does it's
loading, then the same later on and compare to get a definitive list.
also worth asking if you're refering to objects (as in instances) or
classes.
Object = instance of a Class [ $object = new Class() ]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Classes and Functions
am 29.12.2009 04:24:58 von Daniel Kolbo
Nathan Rixham wrote:
> Daniel Kolbo wrote:
>> Hello,
>>
>> Is there a way to see what objects and functions a script
>> loaded/required/used?
>>
>> I could recursively loop through the globals, but if objects were unset,
>> then i may miss some.
>>
>> I could make a 'tracking' object and every time i load/include a file
>> (which contains a class def or a function def) to add that file to the
>> tracking object...but it would be nice if i didn't have to modify my
>> existing code to see which objects and functions a script actually used,
>> or at least, requested and loaded into memory.
>>
>> Thanks in advance,
>> Daniel Kolbo
>> `
>>
>
> if it's for debugging, get a good debugger so you can inspect at break
> points; for use during runtime and something "scripted" you can call the
> relevant get_defined/declared functions before before your app does it's
> loading, then the same later on and compare to get a definitive list.
>
> also worth asking if you're refering to objects (as in instances) or
> classes.
>
> Object = instance of a Class [ $object = new Class() ]
>
Hello Mr. Rixham,
Thanks for the reminder about those 'get' functions. (just what i was
looking for).
Thanks,
dK
`
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php