[PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
I have discovered that when I foreach over a RecursiveDirectoryIterator (see example below) the $item actually turns into a SplFileInfo object. I would expect it to be a RecursiveDirectoryIterator. How do I do a hasChildren() on SplFileInfo? However, if I change it to a non-recursive, Director

[PHP] Re: RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
Ryan Panning wrote: I have discovered that when I foreach over a RecursiveDirectoryIterator (see example below) the $item actually turns into a SplFileInfo object. I would expect it to be a RecursiveDirectoryIterator. How do I do a hasChildren() on SplFileInfo? However, if I change it to a

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
Nathan Nobbe wrote: if youre trying to do recursive iteration whereby you 'flatten' the tree structure, drop the RecursiveDirectoryIterator into a RecursiveIteratorIterator (its for iterating over RecursiveIterators), then you dont have to bother w/ calling hasChildren() at all. you probly also

Re: [PHP] RecursiveDirectoryIterator and foreach

2009-02-23 Thread Ryan Panning
Philip Graham wrote: Here's a RecursiveDirectoryIterator class I've written and find quite useful: mailto:phi...@lightbox.org";>Philip Graham */ class Util_RecursiveFileIterator implements Iterator { CONST SHOW_DOT_FILES = true; private $_basePath; private $_curDirIter; private

[PHP] autoload with namespace

2008-04-01 Thread Ryan Panning
I haven't been keeping an eye on this list so if this has come up before please point me in the right direction. :) Playing around with dev PHP 5.3 and namespaces, I'm finding it hard to write an autoload function. Since autoload will be triggered on any namespace call, the request could be fo

Re: [PHP] autoload with namespace

2008-04-02 Thread Ryan Panning
Jochem Maas wrote: essentially it boils down to replacing '::' with '/' to determine the path from the namespace in your case - that is easy enough, your still stuck with finding out whether your being asked to load a namespace, class, or function (do namespaced functions even trigger an autolo

Re: [PHP] autoload with namespace

2008-04-02 Thread Ryan Panning
Richard Heyes wrote: err-um sorry for the noise; actually the namespaces work w/ functions as well. So not OO specific? Is there anything I can read that describes them? Yes, it's on the docs site. Although this continues to change as I believe brackets {} are now the declaration method (but

[PHP] Re: autoload with namespace

2008-04-02 Thread Ryan Panning
Colin Guthrie wrote: Ryan Panning wrote: Your idea for replacing '::' with '/' is good but I'd think it'll interfere with the arithmetic operator '/'. I'm sure they must have discussed such options. He didn't mean doing that in the code syntax

Re: [PHP] How to get a code review?

2008-04-03 Thread Ryan Panning
Robert Cummings wrote: You could provide links to the source code and post the links here. Pastebin is often used... http://www.pastebin.com Cheers, Rob. Another good option is PHP Builder, they have a forum setup specifically for code reviewing. They have a large user base too. http://phpb

[PHP] Static Member Overloading

2008-07-03 Thread Ryan Panning
Does anyone know if static member overloading was added in PHP 5.3? I noticed that static method overloading was (__callStatic). Thought I'd ask here before attempting to ask in the internals. Ex: __setStatic() __getStatic() __isset() __unset() -- PHP General Mailing List (http://www.php.net/)

[PHP] Using Static Class Variables to Access Globally

2008-09-23 Thread Ryan Panning
The typical way to access a variable or instance from inside a function/method is to either declare it a global variable or pass it as a argument. Is there any reason why someone shouldn't use static class variables to do this? Ex: do_something(); } foo_bar(); ?> Crude example but imagine th

Re: [PHP] Using Static Class Variables to Access Globally

2008-09-23 Thread Ryan Panning
Nathan Nobbe wrote: in many cases, people like to drive client code through methods, which, given the current set of language features in php, could be reason to favor a singleton w/ __get() & __set() methods defined. you still have the same 'global' scope, except that the data doesnt have to be