3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface One { function callme(string $data): void; } interface Two { function callme(int $data): void; } class OneImpl implements One { function callme(string $data): void {} } class TwoImpl implements Two { function callme(int $data): void {} } class BothImpl implements One, Two { /** * @param int|string $data */ function callme($data): void {} } /** * @param "one"|"two"|"both" $switch * @return One|Two */ function getEither(string $switch) { if ($switch === "one") { return new OneImpl(); } if ($switch === "two") { return new TwoImpl(); } return new BothImpl(); } /** * @param One|Two $impl */ function process($impl): void { if ($impl instanceof One && $impl instanceof Two) { echo 'both'; } elseif ($impl instanceof One) { echo 'one'; } elseif ($impl instanceof Two) { echo 'two'; } } process(getEither("one")); process(getEither("two")); process(getEither("both"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e4tsG
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                                'oneimpl'
   15     1        DECLARE_CLASS                                                'twoimpl'
   19     2        DECLARE_CLASS                                                'bothimpl'
   54     3        INIT_FCALL                                                   'process'
          4        INIT_FCALL                                                   'geteither'
          5        SEND_VAL                                                     'one'
          6        DO_FCALL                                          0  $0      
          7        SEND_VAR                                                     $0
          8        DO_FCALL                                          0          
   55     9        INIT_FCALL                                                   'process'
         10        INIT_FCALL                                                   'geteither'
         11        SEND_VAL                                                     'two'
         12        DO_FCALL                                          0  $2      
         13        SEND_VAR                                                     $2
         14        DO_FCALL                                          0          
   56    15        INIT_FCALL                                                   'process'
         16        INIT_FCALL                                                   'geteither'
         17        SEND_VAL                                                     'both'
         18        DO_FCALL                                          0  $4      
         19        SEND_VAR                                                     $4
         20        DO_FCALL                                          0          
         21      > RETURN                                                       1

Function geteither:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e4tsG
function name:  getEither
number of ops:  15
compiled vars:  !0 = $switch
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
   31     1        IS_IDENTICAL                                                 !0, 'one'
          2      > JMPZ                                                         ~1, ->6
   32     3    >   NEW                                                  $2      'OneImpl'
          4        DO_FCALL                                          0          
          5      > RETURN                                                       $2
   34     6    >   IS_IDENTICAL                                                 !0, 'two'
          7      > JMPZ                                                         ~4, ->11
   35     8    >   NEW                                                  $5      'TwoImpl'
          9        DO_FCALL                                          0          
         10      > RETURN                                                       $5
   38    11    >   NEW                                                  $7      'BothImpl'
         12        DO_FCALL                                          0          
         13      > RETURN                                                       $7
   39    14*     > RETURN                                                       null

End of function geteither

Function process:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 5
filename:       /in/e4tsG
function name:  process
number of ops:  16
compiled vars:  !0 = $impl
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   RECV                                                 !0      
   45     1        INSTANCEOF                                           ~1      !0, 'One'
          2      > JMPZ_EX                                              ~1      ~1, ->5
          3    >   INSTANCEOF                                           ~2      !0, 'Two'
          4        BOOL                                                 ~1      ~2
          5    > > JMPZ                                                         ~1, ->8
   46     6    >   ECHO                                                         'both'
   45     7      > JMP                                                          ->15
   47     8    >   INSTANCEOF                                                   !0, 'One'
          9      > JMPZ                                                         ~3, ->12
   48    10    >   ECHO                                                         'one'
   47    11      > JMP                                                          ->15
   49    12    >   INSTANCEOF                                                   !0, 'Two'
         13      > JMPZ                                                         ~4, ->15
   50    14    >   ECHO                                                         'two'
   52    15    > > RETURN                                                       null

End of function process

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

End of function callme

End of class One.

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

End of function callme

End of class Two.

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

End of function callme

End of class OneImpl.

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

End of function callme

End of class TwoImpl.

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

End of function callme

End of class BothImpl.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.03 ms | 2125 KiB | 19 Q