Re: [SMARTY-DEV] RE: [SMARTY] php5 Iterators.

From: Date: Wed, 19 Jan 2005 19:03:33 +0000
Subject: Re: [SMARTY-DEV] RE: [SMARTY] php5 Iterators.
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2614@lists.php.net to get a copy of this message
boots wrote:
FWIW, is_a is not available prior to PHP 4.2 so we would actually need to implement it. The Pear compat library has what appears to be an adequate BC implementation: http://cvs.php.net/co.php/pear/PHP_Compat/Compat/Function/is_a.php?r=1.15 In fact we can just use function_exists.
I can see why people want to overload foreach for object support under PHP5
but I wonder if it might be a better idea to introduce a new tag (say, forevery or onevery or something) even if just to keep the amount of BC headaches and pitfalls to a minimum. -1.
xo boots --- Boris Bezrukov <lovchy@php.net> wrote:
George Miroshnikov wrote:
Hello David, What about using instanceof operator? 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. I'm wondering, if is_a() is forward-compatible with interfaces?
     
Yes, it is. And it should be used.
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). 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.
     


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