3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $bar = 5; public function showBar() { return $this->bar; } public function stupid(): callable { $_bar =& $this->bar; return function (int $v) use (&$_bar): void { $this->bar = $v; }; } } $foo = new foo; $bar = $foo->stupid()(36); echo $foo->showBar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3njY
function name:  (null)
number of ops:  13
compiled vars:  !0 = $foo, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $2      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   14     3        INIT_METHOD_CALL                                         !0, 'stupid'
          4        DO_FCALL                                      0  $5      
          5        INIT_DYNAMIC_CALL                                        $5
          6        SEND_VAL_EX                                              36
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !1, $6
   15     9        INIT_METHOD_CALL                                         !0, 'showBar'
         10        DO_FCALL                                      0  $8      
         11        ECHO                                                     $8
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fn3njY%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3njY
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $v, !1 = $_bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    9     2        FETCH_THIS                                       $2      
          3        ASSIGN_OBJ                                               $2, 'bar'
          4        OP_DATA                                                  !0
   10     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fn3njY%3A8%240

Class foo:
Function showbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3njY
function name:  showBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function showbar

Function stupid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3njY
function name:  stupid
number of ops:  8
compiled vars:  !0 = $_bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_W                                      $1      'bar'
          1        ASSIGN_REF                                               !0, $1
    8     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fn3njY%3A8%240'
          3        BIND_LEXICAL                                             ~3, !0
   10     4        VERIFY_RETURN_TYPE                                       ~3
          5      > RETURN                                                   ~3
   11     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function stupid

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.82 ms | 1399 KiB | 13 Q