On 23 April 2010 10:55, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> I know the subject line might sound a bit like an oxymoron, but bear
> with me!
> What I'd like to have is a property of an object that behaves like a
> public variable when it comes to reading, but like a protected one when
> it comes to writing, as it would make my code a lot easier to read.
> I know about the __get($var) method to magically provide this behaviour,
> but from all I've read it can be pretty slow compared to a regular
> public variable. I've seen a thread on the dev lists where someone
> requested it, but can't find anything in the manual.
> Does anyone know if this is available in a later version of PHP, or if
> it's implementation is penned for some time in the future?
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

What you are asking for is commonly known as accessibility. This has
been discussed on the list and is something I think would be a great

http://wiki.php.net/rfc/propertygetsetsyntax is an incomplete RFC (it
says it is incomplete at the top).

The last update was 2010/01/08 22:11, so a few months old.

Hopefully, some of the clever brains here can get to grips with it and
come to some consensus.

Whilst you can easily code __get()/__set() or getVar()/setVar()
methods to deal with it, with the later ones being significantly
easier to docblock, there is no easy way to document the property,
only the methods to set or get the property.


Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to