From: strate at yandex dot ru
Operating system: Ubuntu
PHP version: 5.5.15
Package: *General Issues
Bug Type: Bug
Bug description:Object is not destructed after disassigned even if refcount was 1
Description:
------------
If we store reference to $this inside object's constructor to external
variable, object will not destructed.
As you can see object A destructed only at the end of script, but
refcount was equals to 1 right before invalidating variable, containing
object.
Seems to be bug, because if we will store reference to variable,
containing object outside the constructor, everything works as expected.
Test script:
---------------
https://gist.github.com/Strate/b037e529ee752489a45f
Expected result:
----------------
php refcounttest.php
b: (refcount=2, is_ref=1)=class B { }
Expecting object destruction ... Object B destructed! Expectation
finished
a: (refcount=1, is_ref=0)=class A { }
Expecting object destruction ... Object A destructed! Expectation
finished
End of script
Actual result:
--------------
php refcounttest.php
b: (refcount=2, is_ref=1)=class B { }
Expecting object destruction ... Object B destructed! Expectation
finished
a: (refcount=1, is_ref=0)=class A { }
Expecting object destruction ... Expectation finished
End of script
Object A destructed!
--
Edit bug report at https://bugs.php.net/bug.php?id=67840&edit=1
--