Class destructor is not called automatically #47

Closed
opened 2019-03-18 12:56:02 +01:00 by belliash · 7 comments
Owner

AerScript Information

  • Aer Version (or commit ref): d4992ff4ba
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

Class destructor is not called automatically, see example code:

<?php
class X {
    function __construct() {
            echo 'Constructor';
    }
    function __destruct() {
            echo 'Destructor';
    }
}
$x = new X();
?>

Above code gives the same result in PH7. This bug is derived from upstream project.

Expected results

'ConstructorDestructor' should appear.

Current results

'Constructor' appears only, what means that destructor is not called.

<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # AerScript Information - Aer Version (or commit ref): d4992ff4ba - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description Class destructor is not called automatically, see example code: <?php class X { function __construct() { echo 'Constructor'; } function __destruct() { echo 'Destructor'; } } $x = new X(); ?> Above code gives the same result in PH7. This bug is derived from upstream project. # Expected results 'ConstructorDestructor' should appear. # Current results 'Constructor' appears only, what means that destructor is not called.
belliash added the
bug
label 2019-03-18 12:56:02 +01:00
Author
Owner

Additionally, we have broken the unset() function, as it is calling the __destruct() method in PH7.

Additionally, we have broken the unset() function, as it is calling the __destruct() method in PH7.
Author
Owner

unset() builtin function seems broken partially since bd4d146d0a. Looks like it was never working for variables defined with a specified data type. If no data type is specified then unset() is still working.

Seems, there is some difference between:

$x = new Obj();

and

object $x = new Obj();
unset() builtin function seems broken partially since bd4d146d0a. Looks like it was never working for variables defined with a specified data type. If no data type is specified then unset() is still working. Seems, there is some difference between: $x = new Obj(); and object $x = new Obj();
Author
Owner
object $x;
$x = new Obj();

Above version is not affected.

object $x; $x = new Obj(); Above version is not affected.
Author
Owner

This is related to missed OP_POP call when assigning a value during variable declaration.

This is related to missed OP_POP call when assigning a value during variable declaration.
Author
Owner

Fixed everything, what got broken within 'typehinting' branch.
Static variables (both in methods/closure and class attributes) were never destroyed properly in PH7. Fixing this bug will lead to:

  • fixing a garbage collector and freeing more memory,
  • automatically calling a destructor if available (when static variable was an object)
Fixed everything, what got broken within 'typehinting' branch. Static variables (both in methods/closure and class attributes) were never destroyed properly in PH7. Fixing this bug will lead to: * fixing a garbage collector and freeing more memory, * automatically calling a destructor if available (when static variable was an object)
Author
Owner

Segmentation fault fixed in 407bcf5a29.

Segmentation fault fixed in 407bcf5a29.
Author
Owner

Fixed in 171456beb4.
Test extended in 4afcbc0815 confirms, it is working.

Fixed in 171456beb4. Test extended in 4afcbc0815 confirms, it is working.
belliash self-assigned this 2019-06-29 16:09:32 +02:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: aerscript/Aer#47
No description provided.