3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict=1); class A { private function foo(float $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(42.5); $bFN = $this->getClosure(42.5); $cFN = $c->getClosure(42.5); $aFN(); $bFN(); $cFN(); } } class C extends B { public function foo(int $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/jrCWD
function name:  (null)
number of ops:  14
compiled vars:  !0 = $a, !1 = $c, !2 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   37     3        NEW                                              $6      'c'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   38     6        NEW                                              $9      'B'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   39     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%2FjrCWD%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrCWD
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     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%2FjrCWD%3A11%240

Function %00%7Bclosure%7D%2Fin%2FjrCWD%3A32%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrCWD
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     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%2FjrCWD%3A32%241

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jrCWD
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ECHO                                                     'This+is+private'
    8     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/jrCWD
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FjrCWD%3A11%240'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   12     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/jrCWD
function name:  test
number of ops:  21
compiled vars:  !0 = $a, !1 = $c, !2 = $aFN, !3 = $bFN, !4 = $cFN
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_METHOD_CALL                                         !0, 'getClosure'
          3        SEND_VAL_EX                                              42.5
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
   18     6        INIT_METHOD_CALL                                         'getClosure'
          7        SEND_VAL_EX                                              42.5
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !3, $7
   19    10        INIT_METHOD_CALL                                         !1, 'getClosure'
         11        SEND_VAL_EX                                              42.5
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !4, $9
   21    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
   22    16        INIT_DYNAMIC_CALL                                        !3
         17        DO_FCALL                                      0          
   23    18        INIT_DYNAMIC_CALL                                        !4
         19        DO_FCALL                                      0          
   24    20      > 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/jrCWD
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ECHO                                                     'This+is+private'
    8     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/jrCWD
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FjrCWD%3A11%240'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   12     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/jrCWD
function name:  foo
number of ops:  3
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   29     1        ECHO                                                     'This+is+public'
   30     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/jrCWD
function name:  getClosure
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   32     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FjrCWD%3A32%241'
          2        BIND_LEXICAL                                             ~1, !0
          3      > RETURN                                                   ~1
   33     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/jrCWD
function name:  test
number of ops:  21
compiled vars:  !0 = $a, !1 = $c, !2 = $aFN, !3 = $bFN, !4 = $cFN
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_METHOD_CALL                                         !0, 'getClosure'
          3        SEND_VAL_EX                                              42.5
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !2, $5
   18     6        INIT_METHOD_CALL                                         'getClosure'
          7        SEND_VAL_EX                                              42.5
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !3, $7
   19    10        INIT_METHOD_CALL                                         !1, 'getClosure'
         11        SEND_VAL_EX                                              42.5
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !4, $9
   21    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
   22    16        INIT_DYNAMIC_CALL                                        !3
         17        DO_FCALL                                      0          
   23    18        INIT_DYNAMIC_CALL                                        !4
         19        DO_FCALL                                      0          
   24    20      > RETURN                                                   null

End of function test

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.24 ms | 1403 KiB | 13 Q