3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Runnable { public function run(string $details): void; } abstract class RunnableBase implements Runnable { public function run(string $more): void { echo $more . "\n"; } } class Impl1 extends RunnableBase { public function run(string $extra): void { parent::run($extra); } } class Impl2 extends RunnableBase { public function run(string $other): void { parent::run($other); } } function getRunnable(): Runnable { if (time() % 2) { return new Impl1(); } else { return new Impl2(); } } $a = getRunnable(); try { // This is the only name that is known at compile time and what I would expect to work. $a->run(details: 'details'); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } try { // I wouldn't expect this to work as it's just an implementation detail. $a->run(more: 'more'); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } try { // I would absolutely never expect this to work, because it is -random-. $a->run(extra: 'extra'); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } try { // I would absolutely never expect this to work, because it is -random-. $a->run(other: 'other'); } catch (Throwable $e) { echo $e->getMessage() . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Found catch point at position: 21
Branch analysis from position: 21
2 jumps found. (Code = 107) Position 1 = 22, Position 2 = -2
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Found catch point at position: 31
Branch analysis from position: 31
2 jumps found. (Code = 107) Position 1 = 32, Position 2 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Found catch point at position: 41
Branch analysis from position: 41
2 jumps found. (Code = 107) Position 1 = 42, Position 2 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  (null)
number of ops:  47
compiled vars:  !0 = $a, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'runnablebase'
   13     1        DECLARE_CLASS                                            'impl1', 'runnablebase'
   19     2        DECLARE_CLASS                                            'impl2', 'runnablebase'
   34     3        INIT_FCALL                                               'getrunnable'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   38     6        INIT_METHOD_CALL                                         !0, 'run'
          7        SEND_VAL_EX                                              'details', 'details'
          8        CHECK_UNDEF_ARGS                                         
          9        DO_FCALL                                      1          
         10      > JMP                                                      ->16
   40    11  E > > CATCH                                       last         'Throwable'
   41    12    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         13        DO_FCALL                                      0  $5      
         14        CONCAT                                           ~6      $5, '%0A'
         15        ECHO                                                     ~6
   46    16    >   INIT_METHOD_CALL                                         !0, 'run'
         17        SEND_VAL_EX                                              'more', 'more'
         18        CHECK_UNDEF_ARGS                                         
         19        DO_FCALL                                      1          
         20      > JMP                                                      ->26
   48    21  E > > CATCH                                       last         'Throwable'
   49    22    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         23        DO_FCALL                                      0  $8      
         24        CONCAT                                           ~9      $8, '%0A'
         25        ECHO                                                     ~9
   54    26    >   INIT_METHOD_CALL                                         !0, 'run'
         27        SEND_VAL_EX                                              'extra', 'extra'
         28        CHECK_UNDEF_ARGS                                         
         29        DO_FCALL                                      1          
         30      > JMP                                                      ->36
   56    31  E > > CATCH                                       last         'Throwable'
   57    32    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         33        DO_FCALL                                      0  $11     
         34        CONCAT                                           ~12     $11, '%0A'
         35        ECHO                                                     ~12
   62    36    >   INIT_METHOD_CALL                                         !0, 'run'
         37        SEND_VAL_EX                                              'other', 'other'
         38        CHECK_UNDEF_ARGS                                         
         39        DO_FCALL                                      1          
         40      > JMP                                                      ->46
   64    41  E > > CATCH                                       last         'Throwable'
   65    42    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         43        DO_FCALL                                      0  $14     
         44        CONCAT                                           ~15     $14, '%0A'
         45        ECHO                                                     ~15
   66    46    > > RETURN                                                   1

Function getrunnable:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  getRunnable
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $0      
          2        MOD                                              ~1      $0, 2
          3      > JMPZ                                                     ~1, ->9
   27     4    >   NEW                                              $2      'Impl1'
          5        DO_FCALL                                      0          
          6        VERIFY_RETURN_TYPE                                       $2
          7      > RETURN                                                   $2
   26     8*       JMP                                                      ->13
   30     9    >   NEW                                              $4      'Impl2'
         10        DO_FCALL                                      0          
         11        VERIFY_RETURN_TYPE                                       $4
         12      > RETURN                                                   $4
   32    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function getrunnable

Class Runnable:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  run
number of ops:  2
compiled vars:  !0 = $details
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function run

End of class Runnable.

Class RunnableBase:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  run
number of ops:  4
compiled vars:  !0 = $more
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        CONCAT                                           ~1      !0, '%0A'
          2        ECHO                                                     ~1
   10     3      > RETURN                                                   null

End of function run

End of class RunnableBase.

Class Impl1:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  run
number of ops:  5
compiled vars:  !0 = $extra
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_STATIC_METHOD_CALL                                  'run'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   16     4      > RETURN                                                   null

End of function run

End of class Impl1.

Class Impl2:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2XSm
function name:  run
number of ops:  5
compiled vars:  !0 = $other
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_STATIC_METHOD_CALL                                  'run'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   22     4      > RETURN                                                   null

End of function run

End of class Impl2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.08 ms | 1444 KiB | 15 Q