3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private function foo(int $bar) { echo "This is private"; } public function getClosure($bar) { return function () use ($bar) { $this->foo($bar); }; } } class B extends A { public function test(A $a, C $c) { $aFN = $a->getClosure("Hello"); $bFN = $this->getClosure("Hello"); $cFN = $c->getClosure("Hello"); $aFN(); $cFN(); } } class C extends B { public function foo(bool $bar) { echo "This is public"; } public function getClosure($bar) { return function () use ($bar) { $this->foo($bar); }; } } $a = new A; $c = new c; $obj = new B(); $obj->test($a, $c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  (null)
number of ops:  14
compiled vars:  !0 = $a, !1 = $c, !2 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   34     3        NEW                                              $6      'c'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   35     6        NEW                                              $9      'B'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   36     9        INIT_METHOD_CALL                                         !2, 'test'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FLPIqS%3A9%240

Function %00%7Bclosure%7D%2Fin%2FLPIqS%3A29%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   BIND_STATIC                                              !0
          1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, 'foo'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLPIqS%3A29%241

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ECHO                                                     'This+is+private'
    6     2      > RETURN                                                   null

End of function foo

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPIqS%3A9%240'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   10     4*     > RETURN                                                   null

End of function getclosure

End of class A.

Class B:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  test
number of ops:  19
compiled vars:  !0 = $a, !1 = $c, !2 = $aFN, !3 = $bFN, !4 = $cFN
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_METHOD_CALL                                         !0, 'getClosure'
          3        SEND_VAL_EX                                              'Hello'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
   16     6        INIT_METHOD_CALL                                         'getClosure'
          7        SEND_VAL_EX                                              'Hello'
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !3, $7
   17    10        INIT_METHOD_CALL                                         !1, 'getClosure'
         11        SEND_VAL_EX                                              'Hello'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !4, $9
   19    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
   20    16        INIT_DYNAMIC_CALL                                        !4
         17        DO_FCALL                                      0          
   21    18      > RETURN                                                   null

End of function test

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ECHO                                                     'This+is+private'
    6     2      > RETURN                                                   null

End of function foo

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPIqS%3A9%240'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   10     4*     > RETURN                                                   null

End of function getclosure

End of class B.

Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        ECHO                                                     'This+is+public'
   27     2      > RETURN                                                   null

End of function foo

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPIqS%3A29%241'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   30     4*     > RETURN                                                   null

End of function getclosure

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPIqS
function name:  test
number of ops:  19
compiled vars:  !0 = $a, !1 = $c, !2 = $aFN, !3 = $bFN, !4 = $cFN
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_METHOD_CALL                                         !0, 'getClosure'
          3        SEND_VAL_EX                                              'Hello'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
   16     6        INIT_METHOD_CALL                                         'getClosure'
          7        SEND_VAL_EX                                              'Hello'
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !3, $7
   17    10        INIT_METHOD_CALL                                         !1, 'getClosure'
         11        SEND_VAL_EX                                              'Hello'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !4, $9
   19    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
   20    16        INIT_DYNAMIC_CALL                                        !4
         17        DO_FCALL                                      0          
   21    18      > RETURN                                                   null

End of function test

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.12 ms | 1394 KiB | 13 Q