RE: [PHP-DEV] Reflection API idea
| From: | Bob Silva | Date: | Wed, 23 Nov 2005 07:58:48 +0000 |
| Subject: | RE: [PHP-DEV] Reflection API idea | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20258@lists.php.net to get a copy of this message | ||
Whoops, that memcmp should be a strcmp.
> -----Original Message-----
> From: Bob Silva [mailto:me@bobsilva.com]
> Sent: Tuesday, November 22, 2005 8:19 PM
> To: 'internals'
> Subject: [PHP-DEV] Reflection API idea
>
> 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
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php