Re: Recursive classes ... possible bug?
| From: | Antony Dovgal | Date: | Wed, 06 Jun 2007 06:10:04 +0000 |
| Subject: | Re: Recursive classes ... possible bug? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30102@lists.php.net to get a copy of this message | ||
On 06.06.2007 02:20, mark@cyanox.nl wrote:
Why? The behavior is quite clear - if the objects are instances of the same class, we have no other way to compare them but to compare their properties, this also applies to properties' properties and properties' properties' properties etc.Actually theoretically it should not give an error.Fatal error: Nesting level too deep - recursive dependency? in /home/cyanox/DEV/test_object_recursion.php on line 15$t->$tt->$t->$tt->$t->$tt->$t->$tt->$t->$tt->$t and so on. So you get endless recursion when comparing the objects.Although it is obvious that there is a recursion I think this simple example should work without error.Sure, if you have any proposals/ideas - feel free to share them.
I just stumbled upon this odd behavior when doing something very odd which would not work anyway so I can't really think of a situation where the correct behavior would be needed. Anyway the following also gives the error. <?php class class1{ public $c2; function __construct($c2){Right. $this and $this->c1 are class2 and class1, no need even to look at the properties to say that they are not equal.$this->c2 = $c2;} } class class2{ public $c1; function test(){$this == $this->c1; // no error.
This is what I described earlier. If you have any ideas on how to improve it - I'd be happy to hear them. -- Wbr, Antony Dovgal$this == $this; // errors.