Re: [SMARTY-DEV] RE: [SMARTY] php5 Iterators.
| From: | Jochem Maas | Date: | Tue, 18 Jan 2005 00:24:54 +0000 |
| Subject: | Re: [SMARTY-DEV] RE: [SMARTY] php5 Iterators. | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2610@lists.php.net to get a copy of this message | ||
[ps - im not on the smarty dev list please reply direct, thanks]
George Miroshnikov wrote:
Hello David, What about using instanceof operator?In order to support Iterator objects they also need to implement Countable (or atleast a count() method?) - because the code does count( $var ) as well as foreach( $var ) and an Iterator object does not work with the std. count() function unless it implements Countable (which I don't have in the version of php I'm running - I have defined an replacement Interface which stipulates a count() method which my iterator objects use.)
It would raise parser error on php4, but my thought is all php5 code could be (temporarily?) moved into separate plugin that will be conditionally included if Smarty is being run on php5 box. Or maybe use runtime functions to avoid parser error.on a side note: Are there any ideas regarding an eventual break from php4? that is to say a point in time where the new functionality of php5 becomes stable/wellknown enough and the install base wide enough that it is decided to no longer support php4 in active development (Looking at the smarty source code - its just begging to have a stack of functions/vars declared private for instance, in the sense that the CS is very clear as to the intended scope of functions/vars etc :-)
I'm wondering, if is_a() is forward-compatible with interfaces?don't know that but judging by the fact that there is get_classes() and class_implements() I doub't that should be relied on. semantically it would be incorrect also: if you implement a steeringwheel does that make you one?
Monday, January 17, 2005, 10:45:01 PM, you wrote: DZ> Jochem, DZ> Someone posted a patch for this "problem" a couple of days ago on the DZ> Developers list (this is where this discussion belongs to anyway, so I'm DZ> crossposting there).with regard to the patch, no worries - I have patched mine own install - twas easy to 'fix' - I'll ( try to :-) ) maintain a copy in my projects cvs and just merge the updates now and again.. rgds, Jochem
DZ> I totally agree with you, we need the possibility to use iterators. The DZ> point is we need to find a clean way to implement this without breaking BC. DZ> If we just do an is_object() check, we will break BC because you actually DZ> CAN loop over objects using foreach, it will return the property values (and DZ> their names as keys). We cannot remove the array casting either because some DZ> people might rely on the fact that their int, string, whatever gets DZ> converted to a one-value array and they can loop over them.