3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $b = null; protected static $instance = null; public static function get() { if (static::$instance === null) { static::$instance = new static(); } return static::$instance; } public function __construct() { echo __METHOD__ . PHP_EOL; $this->b = Bar::get(); } public function __destruct() { echo __METHOD__ . PHP_EOL; $this->b->func(); } } class Bar { public $destroyed = false; protected static $instance = null; public static function get() { if (static::$instance === null) { static::$instance = new static(); } return static::$instance; } public function __construct() { echo __METHOD__ . PHP_EOL; } public function __destruct() { echo __METHOD__ . PHP_EOL; $this->destroyed = true; } public function func() { echo __METHOD__ . PHP_EOL; } } Bar::get(); Foo::get();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   INIT_STATIC_METHOD_CALL                                  'Bar', 'get'
          1        DO_FCALL                                      0          
   61     2        INIT_STATIC_METHOD_CALL                                  'Foo', 'get'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class Foo:
Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/Ifgn9
function name:  get
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   11     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   14     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   15     9*     > RETURN                                                   null

End of function get

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'Foo%3A%3A__construct%0A'
   19     1        INIT_STATIC_METHOD_CALL                                  'Bar', 'get'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN_OBJ                                               'b'
          4        OP_DATA                                                  $1
   20     5      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  __destruct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                     'Foo%3A%3A__destruct%0A'
   25     1        FETCH_OBJ_R                                      ~0      'b'
          2        INIT_METHOD_CALL                                         ~0, 'func'
          3        DO_FCALL                                      0          
   26     4      > RETURN                                                   null

End of function __destruct

End of class Foo.

Class Bar:
Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/Ifgn9
function name:  get
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   37     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   40     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   41     9*     > RETURN                                                   null

End of function get

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   ECHO                                                     'Bar%3A%3A__construct%0A'
   46     1      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  __destruct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   ECHO                                                     'Bar%3A%3A__destruct%0A'
   51     1        ASSIGN_OBJ                                               'destroyed'
          2        OP_DATA                                                  <true>
   52     3      > RETURN                                                   null

End of function __destruct

Function func:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ifgn9
function name:  func
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   ECHO                                                     'Bar%3A%3Afunc%0A'
   57     1      > RETURN                                                   null

End of function func

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.28 ms | 1403 KiB | 13 Q