3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $cb; private $bar; public function __construct($cb) { $this->cb = $cb; unset($this->baz); } public function & __get($name) { if (! isset($this->$name)) { $cb = $this->cb; $cb(['bar' => & $this->bar]); } return $this->$name; } } $foo = new Foo(function ($properties) { $properties['bar'] = 'baz'; }); var_dump($foo->bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsRZ7
function name:  (null)
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Foo'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJsRZ7%3A26%240'
   28     2        SEND_VAL_EX                                              ~2
          3        DO_FCALL                                      0          
   26     4        ASSIGN                                                   !0, $1
   30     5        INIT_FCALL                                               'var_dump'
          6        FETCH_OBJ_R                                      ~5      !0, 'bar'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FJsRZ7%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsRZ7
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $properties
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        ASSIGN_DIM                                               !0, 'bar'
          2        OP_DATA                                                  'baz'
   28     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJsRZ7%3A26%240

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

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
Return found
Branch analysis from position: 11
filename:       /in/JsRZ7
function name:  __get
number of ops:  14
compiled vars:  !0 = $name, !1 = $cb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ISSET_ISEMPTY_PROP_OBJ                           ~2      !0
          2        BOOL_NOT                                         ~3      ~2
          3      > JMPZ                                                     ~3, ->11
   18     4    >   FETCH_OBJ_R                                      ~4      'cb'
          5        ASSIGN                                                   !1, ~4
   19     6        INIT_DYNAMIC_CALL                                        !1
          7        FETCH_OBJ_W                                      $6      'bar'
          8        INIT_ARRAY                                       ~7      $6, 'bar'
          9        SEND_VAL_EX                                              ~7
         10        DO_FCALL                                      0          
   22    11    >   FETCH_OBJ_W                                      $9      !0
         12      > RETURN_BY_REF                                            $9
   23    13*     > RETURN_BY_REF                                            null

End of function __get

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.31 ms | 1405 KiB | 15 Q