
Bug #36487 object === same object mismatch
Submitted: 2006-02-22 14:33 UTC Modified: 2009-01-06 21:03 UTC
From: xxoes at nw7 dot de Assigned:
Status: Not a bug Package: PHP-GTK related
PHP Version: 5.1.2 OS: *
Private report: No CVE-ID: None
 [2006-02-22 14:33 UTC] xxoes at nw7 dot de
Although the objects have the same object id after destruction, "===" doesn't equal them any more.

I try:
   $abc = new abc();
   $obj = new bla();
   $abc = new abc();
   $obj = new bla();

both the same result.

This does not happen when you remove "extends GtkObject" from the class signature.

Reproduce code:
   class bla extends GtkObject {
      public $xparent;

      function __construct() {

      function __destruct() {
         echo "bla::__destruct()\r\n";

   class abc {
      function __destruct() {
         echo "abc::__destruct()\r\n";

      function put($obj) {
         $this->obj = $obj;
         $obj->xparent = $this;

      function remove($obj) {
         echo "Object matched?: ".($this->obj === $obj)."\r\n";
         echo $this->obj." ".$obj."\r\n";

   $abc = new abc();
   $obj = new bla();

Expected result:
That the operation $this->obj === $obj is true.

Actual result:
$this->obj and $obj mismatch.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-22 15:04 UTC] xxoes at nw7 dot de
This is not PHP-GTK related.
If you replace GtkObject with DOMElement you get the same result.
 [2006-02-22 16:42 UTC]
a bug at

For === to return true on object comparison both objects must be instances of the same class and refer to the exact same internal object.
 [2006-02-23 08:05 UTC] xxoes at nw7 dot de
Sorry but i don't understand!

Thats are the same objects and the same instances, and === doesn't matched!

It works fine if a call $obj->__destruct === is true, but not if this function is called by php on exit.
 [2006-02-23 10:16 UTC]
As far as I see that, the objects *are* identical.
They equal === as long as they are not in the process of being destroyed - but as soon as the destroying process is begun, they don't equal any more although they are still equal
 [2006-03-28 12:55 UTC]
So this is GTK related then, isn't it?
 [2006-03-28 14:14 UTC] xxoes at nw7 dot de
No isn't php-gtk related. Is a general problem because DOMElement and GtkObject have the same result.
 [2009-01-06 21:03 UTC]
The order that objects are destroyed in cannot be guaranteed, so it's generally a good idea not to be trying to fiddle with objects (even objects stored inside other objects) in destructors
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 21 08:01:23 2020 UTC