RE: [PHP-DEV] Reflection API idea
| From: | Bob Silva | Date: | Wed, 23 Nov 2005 08:43:54 +0000 |
| Subject: | RE: [PHP-DEV] Reflection API idea | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20261@lists.php.net to get a copy of this message | ||
Nope, sorry, I'll do my homework next time.
Bob
> -----Original Message-----
> From: Marcus Boerger [mailto:helly@php.net]
> Sent: Wednesday, November 23, 2005 12:39 AM
> To: Bob Silva
> Cc: 'internals'
> Subject: Re: [PHP-DEV] Reflection API idea
>
> Hello Bob,
>
> have you looked at head output of Reflection lately? I guess that
> contains
> all you want, right?
>
> marcus
>
> Wednesday, November 23, 2005, 5:19:10 AM, you wrote:
>
> > Here's an idea for the maintainer of the Reflection API, to be able to
> view
> > the class a method is defined in (if not overridden).
>
>
> > class Vehicle {
> > function go() {}
> > function crash() {}
> > }
>
> > class Car extends Vehicle {
> > function crash() {}
> > function collectInsurance() {}
> > }
>
> > class Ford extends Car {
> > function fixOrRepairDaily() {}
> > }
>
> > Reflection::export(new ReflectionClass(Car));
>
>
> > Class [ <user> class Ford extends Car ] {
> >
> > - Methods [4] {
> > Method [ <user> public method fixOrRepairDaily ] {
> > }
>
> > Method [ <user> public method crash inherited from Car ] {
> > }
>
> > Method [ <user> public method collectInsurance inherited from Car ]
> {
> > }
>
> > Method [ <user> public method go inherited from Vehicle ] {
> > }
> > }
>
> > I am developing on a Windows machine so a Unified Patch isn't easily
> > attainable (with the tools I have at least).
>
> > Psuedo Patch:
> > Modify _function_string in zend_reflection_api.c to take a
> zend_class_entry
> > of the reflecting class or NULL if not used in a class context.
> > Then add the "inherited from" section as below (or however you'd like to
> > implement).
>
> > string_printf(str, "%s", fptr->common.function_name);
> > if (fptr->common.scope && memcmp(fptr->common.scope->name, ce->name))
> > {
> > string_printf(str, " inherited from %s", fptr->common.scope->name);
> > }
> > string_printf(str, " ] {\n");
>
>
> > Not sure if this works in all situations, I'll leave that for you guys
> to
> > determine if you think this is useful functionality.
>
> > Bob Silva
>
>
>
>
> Best regards,
> Marcus