3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { var $me='hello'; function __construct() { $b = b::kill(); var_dump($b); /* object(b)#2 (1) { ["killerMessage"]=> string(5) "Oops!" } */ return $b; } } class b { var $killerMessage=null; function __construct() { $this->killerMessage = 'Oops!'; return $this; } static function kill() { return new b; } } $a= new a; var_dump($a); /* object(a)#1 (1) { ["me"]=> string(5) "hello" } */ //-------------------------------------- //CurrentResult: //php -f test.php //object(b)#2 (1) { // ["killerMessage"]=> // string(5) "Oops!" //} //object(a)#1 (1) { // ["me"]=> // string(5) "hello" //} //-------------------------------------- //ExpectedOutput: //object(b)#2 (1) { // ["killerMessage"]=> // string(5) "Oops!" //} //object(b)#2 (1) { // ["killerMessage"]=> // string(5) "Oops!" //} ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QBlE
function name:  (null)
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'a'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   58     6      > RETURN                                                   1

Class a:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QBlE
function name:  __construct
number of ops:  8
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'b', 'kill'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
    8     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   15     6      > RETURN                                                   !0
   16     7*     > RETURN                                                   null

End of function __construct

End of class a.

Class b:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QBlE
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN_OBJ                                               'killerMessage'
          1        OP_DATA                                                  'Oops%21'
          2        FETCH_THIS                                       ~1      
          3      > RETURN                                                   ~1
          4*     > RETURN                                                   null

End of function __construct

Function kill:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8QBlE
function name:  kill
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $0      'b'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function kill

End of class b.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.27 ms | 1396 KiB | 15 Q