3v4l.org

run code in 300+ PHP versions simultaneously
<?php class my { private $a = null; protected $b = 'b'; public $c = 'c'; function __construct($b, $c) { $this->a = 'a1'; $this->b = $b; $this->c = $c; } public function test() { echo $this->a, $this->b, $this->c; } } class my_ex extends my { function __construct() { $cleaner = function () { echo "Clearing all properties", "<br>"; unset($this->a, $this->b, $this->c); }; $cleaner->bindTo($this, get_parent_class($this))->__invoke(); } function __get($name) { $lazySetter = function($name) { echo "Lazy-loading property {$name}", "<br>"; $this->$name = "new{$name}"; }; $lazySetter->bindTo($this, get_parent_class($this))->__invoke($name); } } $my = new my_ex(1,2); $my->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  (null)
number of ops:  8
compiled vars:  !0 = $my
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $1      'my_ex'
          1        SEND_VAL_EX                                              1
          2        SEND_VAL_EX                                              2
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   46     5        INIT_METHOD_CALL                                         !0, 'test'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FpaBGp%3A27%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  {closure}
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ECHO                                                     'Clearing+all+properties'
          1        ECHO                                                     '%3Cbr%3E'
   29     2        FETCH_THIS                                       $0      
          3        UNSET_OBJ                                                $0, 'a'
          4        FETCH_THIS                                       $1      
          5        UNSET_OBJ                                                $1, 'b'
          6        FETCH_THIS                                       $2      
          7        UNSET_OBJ                                                $2, 'c'
   30     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpaBGp%3A27%240

Function %00%7Bclosure%7D%2Fin%2FpaBGp%3A37%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'Lazy-loading+property+', !0
          3        ECHO                                                     ~1
          4        ECHO                                                     '%3Cbr%3E'
   39     5        FETCH_THIS                                       $2      
          6        NOP                                                      
          7        FAST_CONCAT                                      ~4      'new', !0
          8        ASSIGN_OBJ                                               $2, !0
          9        OP_DATA                                                  ~4
   40    10      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpaBGp%3A37%241

Class my:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  __construct
number of ops:  9
compiled vars:  !0 = $b, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN_OBJ                                               'a'
          3        OP_DATA                                                  'a1'
   13     4        ASSIGN_OBJ                                               'b'
          5        OP_DATA                                                  !0
   14     6        ASSIGN_OBJ                                               'c'
          7        OP_DATA                                                  !1
   15     8      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  test
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        ECHO                                                     ~0
          2        FETCH_OBJ_R                                      ~1      'b'
          3        ECHO                                                     ~1
          4        FETCH_OBJ_R                                      ~2      'c'
          5        ECHO                                                     ~2
   20     6      > RETURN                                                   null

End of function test

End of class my.

Class my_ex:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  __construct
number of ops:  14
compiled vars:  !0 = $cleaner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpaBGp%3A27%240'
          1        ASSIGN                                                   !0, ~1
   31     2        INIT_METHOD_CALL                                         !0, 'bindTo'
          3        FETCH_THIS                                       $3      
          4        SEND_VAR_EX                                              $3
          5        INIT_FCALL                                               'get_parent_class'
          6        FETCH_THIS                                       ~4      
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        SEND_VAR_NO_REF_EX                                       $5
         10        DO_FCALL                                      0  $6      
         11        INIT_METHOD_CALL                                         $6, '__invoke'
         12        DO_FCALL                                      0          
   33    13      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  __get
number of ops:  16
compiled vars:  !0 = $name, !1 = $lazySetter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   37     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpaBGp%3A37%241'
          2        ASSIGN                                                   !1, ~2
   41     3        INIT_METHOD_CALL                                         !1, 'bindTo'
          4        FETCH_THIS                                       $4      
          5        SEND_VAR_EX                                              $4
          6        INIT_FCALL                                               'get_parent_class'
          7        FETCH_THIS                                       ~5      
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                         $6      
         10        SEND_VAR_NO_REF_EX                                       $6
         11        DO_FCALL                                      0  $7      
         12        INIT_METHOD_CALL                                         $7, '__invoke'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   42    15      > RETURN                                                   null

End of function __get

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/paBGp
function name:  test
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        ECHO                                                     ~0
          2        FETCH_OBJ_R                                      ~1      'b'
          3        ECHO                                                     ~1
          4        FETCH_OBJ_R                                      ~2      'c'
          5        ECHO                                                     ~2
   20     6      > RETURN                                                   null

End of function test

End of class my_ex.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.39 ms | 1396 KiB | 15 Q