Protected Instead Of Private please please please!
#1
Posted 29 October 2012 - 12:43 PM
private $_name;
private $_basePath;
private $_baseUrl;
into
protected $_name;
protected $_basePath;
protected $_baseUrl;
#3
Posted 12 November 2012 - 06:19 PM
if you want to provide no access directly from other classes then using private
I you are going to extend the class and having access to this variables from it then use protected
In other cases use public
So, In CTheme case, there is no reason to modify this variables after of created instance.
Finally, this prevents you to set this variables by accident.
#4
Posted 14 November 2012 - 06:41 AM
Protected variables offer the same level of encapsulation, while allowing developers to tinker with class internals when extending. You can't possibly envision all the ways in which your class may be used at the time of writing it, so why not err on the side of exposing too much, rather than too little?
#5
Posted 14 November 2012 - 03:08 PM
#6
Posted 15 November 2012 - 05:05 AM
#7
Posted 15 November 2012 - 05:50 AM
#8
Posted 15 November 2012 - 06:09 AM
Check this one for example: http://www.yiiframew...-private-scope/
fact is that there are reasons why not all attributes are public... and again re-read my previous post... if there is a good reason or use-case for a private property to be changed to public... just ask and it will be done. If not we are just talking the talk and not walking the talk
#10
Posted 15 November 2012 - 05:13 PM
#11
Posted 26 November 2012 - 11:54 AM
samdark, on 29 October 2012 - 01:28 PM, said:
I want to extend from those Yii classes, but since properties are private, I can't use them in my extended class.
#12
Posted 26 November 2012 - 11:56 AM
KonApaz, on 12 November 2012 - 06:19 PM, said:
Finally, this prevents you to set this variables by accident.
But I can't extend CTheme to create my own theme handler. That's the problem. Yii claims to be extensible, but can not be extended without modifiying some core classes, and those changes will need to be redone if you upgrade Yii. That's a big issue to me.
#13
Posted 26 November 2012 - 11:57 AM
Maurizio Domba, on 15 November 2012 - 05:05 AM, said:
Not public but protected. I'll open the ticket. Thanks.
#14
Posted 26 November 2012 - 12:11 PM

Help















