Re: [SMARTY-DEV] Incompatibility to older versions again

From: Date: Wed, 19 Feb 2003 08:44:29 +0000
Subject: Re: [SMARTY-DEV] Incompatibility to older versions again
References: 1 2  Groups: php.smarty.dev php.smarty.general 
Request: Send a blank email to php-smarty-dev+get-728@lists.php.net to get a copy of this message
Hi, > On an afterthought, I'm wondering if we should enforce good habits with > OO programming. One issue is direct access to properties... in reality > you shouldn't access an object property directly, but through a method > instead. > We could just allow access to methods only, enforcing good OO practice > and simplifying Smarty. I suppose that could cause an uproar though from > already established OO property access. Besides, Smarty doesn't abide by > these rules itself. Example, we set the template_dir directly instead of > using something like set_template_dir(). This is absolutely right. But in newer versions of PHP you can use overloaded methods ( $foo->__get( ), $foo->__set( ) ) to access object properties. This behaviour is completely transparent for Smarty so you shouldn't restrict object access to only methods. Currently I am thinking about using overloading to restrict access to my object properties. Bye, André "Monte Ohrt" <monte@ispi.net> schrieb im Newsbeitrag news:1045590588.23551.67.camel@lena.ispi.prv... > So you say you have an object with arrays of data as properties, and you > want to access those arrays... I think we could accomodate that. > > On an afterthought, I'm wondering if we should enforce good habits with > OO programming. One issue is direct access to properties... in reality > you shouldn't access an object property directly, but through a method > instead. > > Example: > > class foo { > var $email = 'foo@bar.com'; > > function get_email() { > return $this->email; > } > function set_email($email) { > $this->email = $email; > } > } > > Improper OO Practice: > $obj->email = 'blah@foo.com'; > echo $obj->email; > > Proper OO Practice: > $obj->set_email('blah@foo.com'); > echo $obj->get_email(); > > We could just allow access to methods only, enforcing good OO practice > and simplifying Smarty. I suppose that could cause an uproar though from > already established OO property access. Besides, Smarty doesn't abide by > these rules itself. Example, we set the template_dir directly instead of > using something like set_template_dir(). > > Did I open a can of worms? ;-) > > Monte > > On Tue, 2003-02-18 at 11:06, Rainer Collet wrote: > > Hi! > > > > Except the already mentioned syntax > > {$var|mod:$obj->prop} > > > > I found some other syntaxes that worked in older versions of smarty but > > not any longer in 2.4.2 > > > > {$obj->array.index} > > {$obj->array[index]} in sections > > > > And combinations of them: > > > > {$obj->array[index1].index2} > > {$obj->array.index1[index2]} > > > > etc... > > > > > > Because I use smarty in an big application already shipped to several > > customers which design their templates on their own this is a very big > > problem for me if I want to upgrade smarty from now 2.3.1 to 2.4.2. And > > this is very recommened because I use it in security-mode. > > > > Is very any possibility to make smarty again compatible to older > > version? Where can I find this in the source code? I will try to solve > > it on my own. > > > > Thanks very much, > > Rainer > -- > Monte Ohrt <monte@ispi.net> >

« previous php.smarty.dev (#728) next »