On 07/25/2011 02:05 PM, Stefan Marr wrote:
> Hi Johannes:
> 
> 2011/7/25 Johannes Schlüter <johan...@schlueters.de>:
> 
>> Now I use reflection on this:
>>
>> $rc = new ReflectionClass('C');
>> print_r($rc->getTraitAliases());
>>
>> Array
>> (
>>    [tc] => T1::t1
>> )
> 
> Great, that is nice.
> 
> 
>> So far so nice but I'm missing the information where C::t1() is coming
>> from. In the reflection code I'm currently iterating over
>> ce->trait_aliases and can't find where I can get the information from.
>> Actually I'd be even interested in getting all important methods and
>> their origin. Stefan, do you know where I can find the information or
>> would we have to store it additionally?
> The functions do not store that information, so there are basically
> only two approaches, I see:
> 
> Either, factoring out the code which is doing the flattening, conflict
> resolution, and class composition into something which could be easily
> shared by both the reflection and the engine, and then re-doing it on
> demand in the reflection,
> or we extend zend_function by an origin pointer.
> 
> Not sure what the better tradeoff is general memory overhead vs.
> cache-able pay-as-you-go overhead.

Is it really worth any overhead here at all? This information is still
there, you just have to work at it a bit. You know which traits are
being used for class C. T1 and T2. You can look at T1 and T2 and see
they both provide t1 methods, but you see from the list of aliases on C
that T1::t1 was aliased to tc, therefore C::t1 must come from T2 since
the trait is used in C and it isn't aliased. I don't think we need
anything else here.

-Rasmus



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to