3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function privateMethod($x) { return $x + 1; } function publicMethod($x) { return $x + 1; } function testMap() { return array_map(array($this, 'publicMethod'), array(1,2,3)); } function testMyMap() { return my_array_map(array($this, 'publicMethod'), array(1,2,3)); } } function my_array_map($fun, $arr) { $result = array(); foreach ($arr as $k => $v) { $result[$k] = $fun($v); } return $result; } var_dump((new Foo())->testMap()); var_dump((new Foo())->testMyMap());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rENM
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Foo'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'testMap'
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   32     7        INIT_FCALL                                               'var_dump'
          8        NEW                                              $4      'Foo'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $4, 'testMyMap'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function my_array_map:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/3rENM
function name:  my_array_map
number of ops:  15
compiled vars:  !0 = $fun, !1 = $arr, !2 = $result, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        ASSIGN                                                   !2, <array>
   25     3      > FE_RESET_R                                       $6      !1, ->12
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->12
          5    >   ASSIGN                                                   !4, ~7
   26     6        INIT_DYNAMIC_CALL                                        !0
          7        SEND_VAR_EX                                              !3
          8        DO_FCALL                                      0  $10     
          9        ASSIGN_DIM                                               !2, !4
         10        OP_DATA                                                  $10
   25    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $6
   28    13      > RETURN                                                   !2
   29    14*     > RETURN                                                   null

End of function my_array_map

Class Foo:
Function privatemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rENM
function name:  privateMethod
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
    7     3*     > RETURN                                                   null

End of function privatemethod

Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rENM
function name:  publicMethod
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
   11     3*     > RETURN                                                   null

End of function publicmethod

Function testmap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rENM
function name:  testMap
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'array_map'
          1        FETCH_THIS                                       ~0      
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'publicMethod'
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   15     8*     > RETURN                                                   null

End of function testmap

Function testmymap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3rENM
function name:  testMyMap
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL_BY_NAME                                       'my_array_map'
          1        FETCH_THIS                                       ~0      
          2        INIT_ARRAY                                       ~1      ~0
          3        ADD_ARRAY_ELEMENT                                ~1      'publicMethod'
          4        SEND_VAL_EX                                              ~1
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   19     8*     > RETURN                                                   null

End of function testmymap

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.76 ms | 1400 KiB | 17 Q