Re: Accessors v2 Patch
| From: | guilhermeblanco@gmail.com | Date: | Tue, 13 Dec 2011 01:10:35 +0000 |
| Subject: | Re: Accessors v2 Patch | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56899@lists.php.net to get a copy of this message | ||
Hi,
I don't see how we could possibly do as option 1.
The structure would be weird, because considering I'm looking for an
specific ReflectionMethod that matches a property name, I'd also be
able to call it through invoke, but also regularly through
$obj->Setter($value);
Since I don't see in the match as possible to be executed as the
second possibility, I'd rather bring to a more centralized approach.
$reflProperty = $reflClass->getProperty('Hours');
$reflProperty->hasGetter() === true
$reflProperty->hasSetter() === true
Also,
$reflProperty->setValue($object, $value); would call the Setter method
as well as
$reflProperty->getValue($object) would call the Getter method
It seems the most consistent and centralized approach.
Regards,
2011/12/12 Johannes Schlüter <johannes@schlueters.de>:
> On Mon, 2011-12-12 at 01:01 +0000, Clint M Priest wrote:
>> To be complete I should probably add something to the reflection system as well. At
>> present the getters/setters would show up as functions.
>>
>> What would be preferable?
>> 1) Show up as regular functions and let users fend for themselves?
>> 2) Hide from getMethods() and:
>> 2.1) Provide getAccessors() - Probably returning a new ReflectionPropertyAccessor class?
>> 2.2) Provide getGetters(), getSetters()
>> 3) Modify ReflectionProperty to include hasGetter() and hasSetter()
>>
>> Comments?
>
> Reflection in PHP typically is leaking the implementation details
> typically quite a lot instead of abstracting things away (interfaces and
> Traits are ReflectionClass instances etc.)
>
> I didn't look at the implementation but if these accessors are
> implemented as methods (especially if it can be called just like one) I
> would go for approach 1) and probably mark with a flag. For everything
> else we'd probably have to clean-u reflection to leak less details to
> make sense.
>
> johannes
>
>> -----Original Message-----
>> From: Pierre Joye [mailto:pierre.php@gmail.com]
>> Sent: Sunday, December 11, 2011 6:47 PM
>> To: Clint M Priest
>> Cc: internals@lists.php.net
>> Subject: Re: [PHP-DEV] Accessors v2 Patch
>>
>> oh right, I missed them. Yes, so it is covered as well :)
>>
>> On Mon, Dec 12, 2011 at 1:42 AM, Clint M Priest <cpriest@zerocue.com> wrote:
>> > There are already two tests against private read and private write, should I add two
>> > for protected as well?
>>
>> Cheers,
>> --
>> Pierre
>>
>> @pierrejoye | http://blog.thepimp.net |
>> http://www.libgd.org
>>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Guilherme Blanco
MSN: guilhermeblanco@hotmail.com
GTalk: guilhermeblanco
Toronto - ON/Canada