3v4l.org

run code in 300+ PHP versions simultaneously
var_dump(gc_status()); <?php class Container { private array $services; public function __construct() { $this->services = [ fn() => doStuff($this), ]; } } $container = new Container; unset($container); var_dump(gc_status()); class Container2 { private array $services; public function __construct() { $this->services = [ fn(self $self) => doStuff($self), ]; } public function build() { foreach ($this->services as $service) { $service($this); } } } $container = new Container2; unset($container); var_dump(gc_status());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPoEj
function name:  (null)
number of ops:  20
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     'var_dump%28gc_status%28%29%29%3B%0A%0A'
   17     1        NEW                                              $1      'Container'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   18     4        UNSET_CV                                                 !0
   19     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'gc_status'
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   40    10        NEW                                              $6      'Container2'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !0, $6
   41    13        UNSET_CV                                                 !0
   42    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'gc_status'
         16        DO_ICALL                                         $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class Container:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPoEj
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        INIT_ARRAY                                       ~2      ~1
   11     2        ASSIGN_OBJ                                               'services'
   12     3        OP_DATA                                                  ~2
   14     4      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPoEj
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL_BY_NAME                                       'doStuff'
          1        FETCH_THIS                                       $0      
          2        SEND_VAR_EX                                              $0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 0

End of function __construct

End of class Container.

Class Container2:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPoEj
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        INIT_ARRAY                                       ~2      ~1
   27     2        ASSIGN_OBJ                                               'services'
   28     3        OP_DATA                                                  ~2
   30     4      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KPoEj
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        INIT_FCALL_BY_NAME                                       'doStuff'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 0

End of function __construct

Function build:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/KPoEj
function name:  build
number of ops:  10
compiled vars:  !0 = $service
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~1      'services'
          1      > FE_RESET_R                                       $2      ~1, ->8
          2    > > FE_FETCH_R                                               $2, !0, ->8
   35     3    >   INIT_DYNAMIC_CALL                                        !0
          4        FETCH_THIS                                       $3      
          5        SEND_VAR_EX                                              $3
          6        DO_FCALL                                      0          
   34     7      > JMP                                                      ->2
          8    >   FE_FREE                                                  $2
   37     9      > RETURN                                                   null

End of function build

End of class Container2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.9 ms | 1016 KiB | 15 Q