3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "PHP_VERSION:".PHP_VERSION_ID."\n"; class C { private $x = 5; private function byRef(&$a) { $a *= 2; return $a; } private function byVal($b) { $b *= 3; return $b; } } $obj = new C(); $rp = new ReflectionProperty($obj, 'x'); try { echo "RP1:".$rp->getValue($obj)."\n"; } catch (Throwable $e) { echo "RP1_EX:".get_class($e)."\n"; } $rp2 = new ReflectionProperty($obj, 'x'); $rp2->setAccessible(true); try { echo "RP2:".$rp2->getValue($obj)."\n"; } catch (Throwable $e) { echo "RP2_EX:".get_class($e)."\n"; } $rp3 = new ReflectionProperty($obj, 'x'); $rp3->setAccessible(false); try { echo "RP3:".$rp3->getValue($obj)."\n"; } catch (Throwable $e) { echo "RP3_EX:".get_class($e)."\n"; } $rm1 = new ReflectionMethod($obj, 'byRef'); $arg = 10; try { $res = $rm1->invoke($obj, $arg); echo "RM1:$res/$arg\n"; } catch (Throwable $e) { echo "RM1_EX:".get_class($e)."\n"; } $rm2 = new ReflectionMethod($obj, 'byRef'); $arg2 = 10; $argsArr = [&$arg2]; try { $res2 = $rm2->invokeArgs($obj, $argsArr); echo "RM2:$res2/$arg2\n"; } catch (Throwable $e) { echo "RM2_EX:".get_class($e)."\n"; } $rm3 = new ReflectionMethod($obj, 'byVal'); $valArg = 7; try { $res3 = $rm3->invoke($obj, $valArg); echo "RM3:$res3/$valArg\n"; } catch (Throwable $e) { echo "RM3_EX:".get_class($e)."\n"; } $rm4 = new ReflectionMethod($obj, 'byVal'); $valArg2 = 7; $argsArr2 = [$valArg2]; try { $res4 = $rm4->invokeArgs($obj, $argsArr2); echo "RM4:$res4/$valArg2\n"; } catch (Throwable $e) { echo "RM4_EX:".get_class($e)."\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
1 jumps found. (Code = 42) Position 1 = 157
Branch analysis from position: 157
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Found catch point at position: 36
Branch analysis from position: 36
2 jumps found. (Code = 107) Position 1 = 37, Position 2 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
Found catch point at position: 56
Branch analysis from position: 56
2 jumps found. (Code = 107) Position 1 = 57, Position 2 = -2
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Found catch point at position: 79
Branch analysis from position: 79
2 jumps found. (Code = 107) Position 1 = 80, Position 2 = -2
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
Found catch point at position: 104
Branch analysis from position: 104
2 jumps found. (Code = 107) Position 1 = 105, Position 2 = -2
Branch analysis from position: 105
1 jumps found. (Code = 42) Position 1 = 132
Branch analysis from position: 132
Found catch point at position: 127
Branch analysis from position: 127
2 jumps found. (Code = 107) Position 1 = 128, Position 2 = -2
Branch analysis from position: 128
1 jumps found. (Code = 42) Position 1 = 157
Branch analysis from position: 157
Found catch point at position: 152
Branch analysis from position: 152
2 jumps found. (Code = 107) Position 1 = 153, Position 2 = -2
Branch analysis from position: 153
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LLbOH
function name:  (null)
number of ops:  158
compiled vars:  !0 = $obj, !1 = $rp, !2 = $e, !3 = $rp2, !4 = $rp3, !5 = $rm1, !6 = $arg, !7 = $res, !8 = $rm2, !9 = $arg2, !10 = $argsArr, !11 = $res2, !12 = $rm3, !13 = $valArg, !14 = $res3, !15 = $rm4, !16 = $valArg2, !17 = $argsArr2, !18 = $res4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ECHO                                                     'PHP_VERSION%3A80300%0A'
    8     1        NEW                                              $19     'C'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $19
    9     4        NEW                                              $22     'ReflectionProperty'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              'x'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $22
   10     9        INIT_METHOD_CALL                                         !1, 'getValue'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $25     
         12        CONCAT                                           ~26     'RP1%3A', $25
         13        CONCAT                                           ~27     ~26, '%0A'
         14        ECHO                                                     ~27
         15      > JMP                                                      ->21
         16  E > > CATCH                                       last         'Throwable'
         17    >   GET_CLASS                                        ~28     !2
         18        CONCAT                                           ~29     'RP1_EX%3A', ~28
         19        CONCAT                                           ~30     ~29, '%0A'
         20        ECHO                                                     ~30
   11    21    >   NEW                                              $31     'ReflectionProperty'
         22        SEND_VAR_EX                                              !0
         23        SEND_VAL_EX                                              'x'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !3, $31
   12    26        INIT_METHOD_CALL                                         !3, 'setAccessible'
         27        SEND_VAL_EX                                              <true>
         28        DO_FCALL                                      0          
   13    29        INIT_METHOD_CALL                                         !3, 'getValue'
         30        SEND_VAR_EX                                              !0
         31        DO_FCALL                                      0  $35     
         32        CONCAT                                           ~36     'RP2%3A', $35
         33        CONCAT                                           ~37     ~36, '%0A'
         34        ECHO                                                     ~37
         35      > JMP                                                      ->41
         36  E > > CATCH                                       last         'Throwable'
         37    >   GET_CLASS                                        ~38     !2
         38        CONCAT                                           ~39     'RP2_EX%3A', ~38
         39        CONCAT                                           ~40     ~39, '%0A'
         40        ECHO                                                     ~40
   14    41    >   NEW                                              $41     'ReflectionProperty'
         42        SEND_VAR_EX                                              !0
         43        SEND_VAL_EX                                              'x'
         44        DO_FCALL                                      0          
         45        ASSIGN                                                   !4, $41
   15    46        INIT_METHOD_CALL                                         !4, 'setAccessible'
         47        SEND_VAL_EX                                              <false>
         48        DO_FCALL                                      0          
   16    49        INIT_METHOD_CALL                                         !4, 'getValue'
         50        SEND_VAR_EX                                              !0
         51        DO_FCALL                                      0  $45     
         52        CONCAT                                           ~46     'RP3%3A', $45
         53        CONCAT                                           ~47     ~46, '%0A'
         54        ECHO                                                     ~47
         55      > JMP                                                      ->61
         56  E > > CATCH                                       last         'Throwable'
         57    >   GET_CLASS                                        ~48     !2
         58        CONCAT                                           ~49     'RP3_EX%3A', ~48
         59        CONCAT                                           ~50     ~49, '%0A'
         60        ECHO                                                     ~50
   18    61    >   NEW                                              $51     'ReflectionMethod'
         62        SEND_VAR_EX                                              !0
         63        SEND_VAL_EX                                              'byRef'
         64        DO_FCALL                                      0          
         65        ASSIGN                                                   !5, $51
   19    66        ASSIGN                                                   !6, 10
   20    67        INIT_METHOD_CALL                                         !5, 'invoke'
         68        SEND_VAR_EX                                              !0
         69        SEND_VAR_EX                                              !6
         70        DO_FCALL                                      0  $55     
         71        ASSIGN                                                   !7, $55
         72        ROPE_INIT                                     5  ~58     'RM1%3A'
         73        ROPE_ADD                                      1  ~58     ~58, !7
         74        ROPE_ADD                                      2  ~58     ~58, '%2F'
         75        ROPE_ADD                                      3  ~58     ~58, !6
         76        ROPE_END                                      4  ~57     ~58, '%0A'
         77        ECHO                                                     ~57
         78      > JMP                                                      ->84
         79  E > > CATCH                                       last         'Throwable'
         80    >   GET_CLASS                                        ~61     !2
         81        CONCAT                                           ~62     'RM1_EX%3A', ~61
         82        CONCAT                                           ~63     ~62, '%0A'
         83        ECHO                                                     ~63
   22    84    >   NEW                                              $64     'ReflectionMethod'
         85        SEND_VAR_EX                                              !0
         86        SEND_VAL_EX                                              'byRef'
         87        DO_FCALL                                      0          
         88        ASSIGN                                                   !8, $64
   23    89        ASSIGN                                                   !9, 10
   24    90        INIT_ARRAY                                       ~68     !9
         91        ASSIGN                                                   !10, ~68
   25    92        INIT_METHOD_CALL                                         !8, 'invokeArgs'
         93        SEND_VAR_EX                                              !0
         94        SEND_VAR_EX                                              !10
         95        DO_FCALL                                      0  $70     
         96        ASSIGN                                                   !11, $70
         97        ROPE_INIT                                     5  ~73     'RM2%3A'
         98        ROPE_ADD                                      1  ~73     ~73, !11
         99        ROPE_ADD                                      2  ~73     ~73, '%2F'
        100        ROPE_ADD                                      3  ~73     ~73, !9
        101        ROPE_END                                      4  ~72     ~73, '%0A'
        102        ECHO                                                     ~72
        103      > JMP                                                      ->109
        104  E > > CATCH                                       last         'Throwable'
        105    >   GET_CLASS                                        ~76     !2
        106        CONCAT                                           ~77     'RM2_EX%3A', ~76
        107        CONCAT                                           ~78     ~77, '%0A'
        108        ECHO                                                     ~78
   27   109    >   NEW                                              $79     'ReflectionMethod'
        110        SEND_VAR_EX                                              !0
        111        SEND_VAL_EX                                              'byVal'
        112        DO_FCALL                                      0          
        113        ASSIGN                                                   !12, $79
   28   114        ASSIGN                                                   !13, 7
   29   115        INIT_METHOD_CALL                                         !12, 'invoke'
        116        SEND_VAR_EX                                              !0
        117        SEND_VAR_EX                                              !13
        118        DO_FCALL                                      0  $83     
        119        ASSIGN                                                   !14, $83
        120        ROPE_INIT                                     5  ~86     'RM3%3A'
        121        ROPE_ADD                                      1  ~86     ~86, !14
        122        ROPE_ADD                                      2  ~86     ~86, '%2F'
        123        ROPE_ADD                                      3  ~86     ~86, !13
        124        ROPE_END                                      4  ~85     ~86, '%0A'
        125        ECHO                                                     ~85
        126      > JMP                                                      ->132
        127  E > > CATCH                                       last         'Throwable'
        128    >   GET_CLASS                                        ~89     !2
        129        CONCAT                                           ~90     'RM3_EX%3A', ~89
        130        CONCAT                                           ~91     ~90, '%0A'
        131        ECHO                                                     ~91
   31   132    >   NEW                                              $92     'ReflectionMethod'
        133        SEND_VAR_EX                                              !0
        134        SEND_VAL_EX                                              'byVal'
        135        DO_FCALL                                      0          
        136        ASSIGN                                                   !15, $92
   32   137        ASSIGN                                                   !16, 7
   33   138        INIT_ARRAY                                       ~96     !16
        139        ASSIGN                                                   !17, ~96
   34   140        INIT_METHOD_CALL                                         !15, 'invokeArgs'
        141        SEND_VAR_EX                                              !0
        142        SEND_VAR_EX                                              !17
        143        DO_FCALL                                      0  $98     
        144        ASSIGN                                                   !18, $98
        145        ROPE_INIT                                     5  ~101    'RM4%3A'
        146        ROPE_ADD                                      1  ~101    ~101, !18
        147        ROPE_ADD                                      2  ~101    ~101, '%2F'
        148        ROPE_ADD                                      3  ~101    ~101, !16
        149        ROPE_END                                      4  ~100    ~101, '%0A'
        150        ECHO                                                     ~100
        151      > JMP                                                      ->157
        152  E > > CATCH                                       last         'Throwable'
        153    >   GET_CLASS                                        ~104    !2
        154        CONCAT                                           ~105    'RM4_EX%3A', ~104
        155        CONCAT                                           ~106    ~105, '%0A'
        156        ECHO                                                     ~106
        157    > > RETURN                                                   1

Class C:
Function byref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LLbOH
function name:  byRef
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        ASSIGN_OP                                     3          !0, 2
          2      > RETURN                                                   !0
          3*     > RETURN                                                   null

End of function byref

Function byval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LLbOH
function name:  byVal
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        ASSIGN_OP                                     3          !0, 3
          2      > RETURN                                                   !0
          3*     > RETURN                                                   null

End of function byval

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.76 ms | 1024 KiB | 13 Q