Comparing SplFileInfo objects always returns true
<p>I've pretty much convinced myself that this is just leaky abstraction rearing it's ugly head, but I figured before filing a bug report I might probe Stack Overflow for a more insightful answer...</p>

<p>I'm writing a class in PHP to assist autoloading. I hate using the ridiculous, path-oriented class names like the Zend framework uses, so I've instead written a class that creates an object to recursively go through a directory and its subdirectories, find all PHP source files, and parse them for class definitions, which are then cached and reused until an autoload fails, which prompts the object to update its index.</p>

<p>I like to use built-in PHP classes wherever possible, so for the indexed paths I've used the <code>SplFileInfo</code> class.</p>

<p>Some of the operations required to update the index of classes require that I search the array of <code>SplFileInfo</code> objects my object holds, which is where I have run into a little trouble with using the comparison operator on the <code>SplFileInfo</code> object.</p>

<p>Simply put, searching for any file always returns true. I was a little baffled by it at first, but I've tried it on two machines and had a friend try it on his--same result. Seemingly no matter what, when you compare two <code>SplFileInfo</code> objects using the comparison (<code>==</code>) operator, it returns true, even if they point to different files located in completely directories. Whether I use a loop to iterate over each element in the array and compare that way, use <code>in_array()</code>, or <code>array_search()</code>, it always returns true and gives me a reference to a completely different file.</p>

<p>I poked around a little further and found that the identify operator (<code>===</code>) always returns false, even when two <code>SplFileInfo</code> objects point to exactly the same file, initialized with the same path string.</p>

<p>For my code, this means that when I go to update the class index to see if there are any new files, even if a file is new, the indexer object thinks it already knows about that file and moves on. I've made this to work by comparing the pathname strings, but that sort of defeats the purpose of using the <code>SplFileInfo</code> class to begin with.</p>

<p>The PHP manual says that extension developers can overload the comparison operators for objects, which is why I sort of assumed that <code>SplFileInfo</code> was smart enough to resolve relative paths and properly compare it with other relative paths, e.g. <code>./file</code> and <code>file</code> are equal. Turns out, it was only returning true in those instances because it <em>always</em> returns true when comparing two <code>SplFileInfo</code> objects!</p>

<p>This isn't linked to the code I'm working on. I tried a scratch source file with some new <code>SplFileInfo</code> objects, and compared them. It returns true whether the objects point to different files, the same file, and files that don't exist.</p>

<p>Since this isn't the default behavior for comparison operators on objects in PHP, there has to be something in the definition of the class in the extension that is causing this.</p>

<p>Does anyone have any idea why it's behaving like this, or have any insight?</p>
