3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $x; public function __construct($self) { $this->x = $self; } } Class Bar { static function create(){ $b = new Bar(); $b->f = new Foo($b->get()); } function get(){ $self = $this; return function() use ($self) {return $self;}; } } echo memory_get_usage(), "\n"; for ($i = 0; $i < 1000; ++$i) { Bar::create(); } echo gc_collect_cycles() . "\n"; echo memory_get_usage(), "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 6
Branch analysis from position: 11
Branch analysis from position: 6
filename:       /in/IG5F5
function name:  (null)
number of ops:  20
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        DO_ICALL                                         $1      
          2        ECHO                                                     $1
          3        ECHO                                                     '%0A'
   29     4        ASSIGN                                                   !0, 0
          5      > JMP                                                      ->9
   30     6    >   INIT_STATIC_METHOD_CALL                                  'Bar', 'create'
          7        DO_FCALL                                      0          
   29     8        PRE_INC                                                  !0
          9    >   IS_SMALLER                                               !0, 1000
         10      > JMPNZ                                                    ~5, ->6
   32    11    >   INIT_FCALL                                               'gc_collect_cycles'
         12        DO_ICALL                                         $6      
         13        CONCAT                                           ~7      $6, '%0A'
         14        ECHO                                                     ~7
   34    15        INIT_FCALL                                               'memory_get_usage'
         16        DO_ICALL                                         $8      
         17        ECHO                                                     $8
         18        ECHO                                                     '%0A'
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FIG5F5%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IG5F5
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   BIND_STATIC                                              !0
          1      > RETURN                                                   !0
          2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FIG5F5%3A21%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IG5F5
function name:  __construct
number of ops:  4
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'x'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

End of class Foo.

Class Bar:
Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IG5F5
function name:  create
number of ops:  11
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $1      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   15     3        NEW                                              $5      'Foo'
          4        INIT_METHOD_CALL                                         !0, 'get'
          5        DO_FCALL                                      0  $6      
          6        SEND_VAR_NO_REF_EX                                       $6
          7        DO_FCALL                                      0          
          8        ASSIGN_OBJ                                               !0, 'f'
          9        OP_DATA                                                  $5
   16    10      > RETURN                                                   null

End of function create

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IG5F5
function name:  get
number of ops:  6
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_THIS                                       ~1      
          1        ASSIGN                                                   !0, ~1
   21     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIG5F5%3A21%240'
          3        BIND_LEXICAL                                             ~3, !0
          4      > RETURN                                                   ~3
   22     5*     > RETURN                                                   null

End of function get

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.49 ms | 1400 KiB | 17 Q