3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $secret = 'I actually prefer coding with Go'; public function getClosure() : closure { return function() { return $this->secret; }; } public function dontLeakMyStuff() { return create_function('', 'return $this->secret;'); } } $foo = new Foo(); $closure = $foo->getClosure(); var_dump($closure()); $function = $foo->dontLeakMyStuff(); var_dump($function());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sd9ee
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo, !1 = $closure, !2 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        INIT_METHOD_CALL                                         !0, 'getClosure'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   20     6        INIT_FCALL                                               'var_dump'
          7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                                 
   22    11        INIT_METHOD_CALL                                         !0, 'dontLeakMyStuff'
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !2, $10
   23    14        INIT_FCALL                                               'var_dump'
         15        INIT_DYNAMIC_CALL                                        !2
         16        DO_FCALL                                      0  $12     
         17        SEND_VAR                                                 $12
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fsd9ee%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sd9ee
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'secret'
          2      > RETURN                                                   ~1
    9     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fsd9ee%3A7%240

Class Foo:
Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sd9ee
function name:  getClosure
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fsd9ee%3A7%240'
    9     1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   10     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getclosure

Function dontleakmystuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sd9ee
function name:  dontLeakMyStuff
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL_BY_NAME                                       'create_function'
          1        SEND_VAL_EX                                              ''
          2        SEND_VAL_EX                                              'return+%24this-%3Esecret%3B'
          3        DO_FCALL                                      0  $0      
          4      > RETURN                                                   $0
   15     5*     > RETURN                                                   null

End of function dontleakmystuff

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.3 ms | 1400 KiB | 15 Q