3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface Subject { // valid return types public function int(): int; public function bool(): bool; public function array(): array; public function float(): float; public function string(): string; public function iterable(): iterable; public function callable(): callable; public function void(): void; public function object(): object; public function mixed(): mixed; // invalid return types public function self(): self; public function integer(): integer; public function boolean(): boolean; public function double(): double; public function resource(): resource; } interface Subject2 { // valid return types PUBLIC FUNCTION INT(): INT; PUBLIC FUNCTION BOOL(): BOOL; PUBLIC FUNCTION ARRAY(): ARRAY; PUBLIC FUNCTION FLOAT(): FLOAT; PUBLIC FUNCTION STRING(): STRING; PUBLIC FUNCTION ITERABLE(): ITERABLE; PUBLIC FUNCTION CALLABLE(): CALLABLE; PUBLIC FUNCTION VOID(): VOID; PUBLIC FUNCTION OBJECT(): OBJECT; PUBLIC FUNCTION MIXED(): MIXED; PUBLIC FUNCTION SELF(): SELF; // invalid return types PUBLIC FUNCTION INTEGER(): INTEGER; PUBLIC FUNCTION BOOLEAN(): BOOLEAN; PUBLIC FUNCTION DOUBLE(): DOUBLE; PUBLIC FUNCTION RESOURCE(): RESOURCE; } test(Subject::class); test(Subject2::class); /** * @param class-string $class */ function test(string $class): void { $result = []; $ref = new ReflectionClass($class); foreach ($ref->getMethods() as $ref_method) { $name = $ref_method->getName(); $type = $ref_method->getReturnType(); $is_valid = $type instanceof ReflectionNamedType && $type->isBuiltin(); $key = $is_valid ? 'valid' : 'invalid'; $type_name = $type instanceof ReflectionNamedType ? $type->getName() : null; if ($type_name && $name !== $type_name) { $name = "{$name} -> {$type_name}"; } $result[$key][] = $name; } echo $class, ' ', json_encode($result, JSON_PRETTY_PRINT), PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   INIT_FCALL_BY_NAME                                           'test'
          1        SEND_VAL_EX                                                  'Subject'
          2        DO_FCALL                                          0          
   49     3        INIT_FCALL_BY_NAME                                           'test'
          4        SEND_VAL_EX                                                  'Subject2'
          5        DO_FCALL                                          0          
   77     6      > RETURN                                                       1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 47
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 47
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 43
Branch analysis from position: 38
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
Branch analysis from position: 38
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
Branch analysis from position: 33
Branch analysis from position: 21
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/fJgLA
function name:  test
number of ops:  57
compiled vars:  !0 = $class, !1 = $result, !2 = $ref, !3 = $ref_method, !4 = $name, !5 = $type, !6 = $is_valid, !7 = $key, !8 = $type_name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   55     0  E >   RECV                                                 !0      
   57     1        ASSIGN                                                       !1, <array>
   59     2        NEW                                                  $10     'ReflectionClass'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !2, $10
   61     6        INIT_METHOD_CALL                                             !2, 'getMethods'
          7        DO_FCALL                                          0  $13     
          8      > FE_RESET_R                                           $14     $13, ->47
          9    > > FE_FETCH_R                                                   $14, !3, ->47
   62    10    >   INIT_METHOD_CALL                                             !3, 'getName'
         11        DO_FCALL                                          0  $15     
         12        ASSIGN                                                       !4, $15
   63    13        INIT_METHOD_CALL                                             !3, 'getReturnType'
         14        DO_FCALL                                          0  $17     
         15        ASSIGN                                                       !5, $17
   64    16        INSTANCEOF                                           ~19     !5, 'ReflectionNamedType'
         17      > JMPZ_EX                                              ~19     ~19, ->21
         18    >   INIT_METHOD_CALL                                             !5, 'isBuiltin'
         19        DO_FCALL                                          0  $20     
         20        BOOL                                                 ~19     $20
         21    >   ASSIGN                                                       !6, ~19
   65    22      > JMPZ                                                         !6, ->25
         23    >   QM_ASSIGN                                            ~22     'valid'
         24      > JMP                                                          ->26
         25    >   QM_ASSIGN                                            ~22     'invalid'
         26    >   ASSIGN                                                       !7, ~22
   67    27        INSTANCEOF                                                   !5, 'ReflectionNamedType'
         28      > JMPZ                                                         ~24, ->33
         29    >   INIT_METHOD_CALL                                             !5, 'getName'
         30        DO_FCALL                                          0  $25     
         31        QM_ASSIGN                                            ~26     $25
         32      > JMP                                                          ->34
         33    >   QM_ASSIGN                                            ~26     null
         34    >   ASSIGN                                                       !8, ~26
   69    35      > JMPZ_EX                                              ~28     !8, ->38
         36    >   IS_NOT_IDENTICAL                                     ~29     !4, !8
         37        BOOL                                                 ~28     ~29
         38    > > JMPZ                                                         ~28, ->43
   70    39    >   ROPE_INIT                                         3  ~31     !4
         40        ROPE_ADD                                          1  ~31     ~31, '+-%3E+'
         41        ROPE_END                                          2  ~30     ~31, !8
         42        ASSIGN                                                       !4, ~30
   73    43    >   FETCH_DIM_W                                          $34     !1, !7
         44        ASSIGN_DIM                                                   $34
         45        OP_DATA                                                      !4
   61    46      > JMP                                                          ->9
         47    >   FE_FREE                                                      $14
   76    48        ECHO                                                         !0
         49        ECHO                                                         '+'
         50        INIT_FCALL                                                   'json_encode'
         51        SEND_VAR                                                     !1
         52        SEND_VAL                                                     128
         53        DO_ICALL                                             $36     
         54        ECHO                                                         $36
         55        ECHO                                                         '%0A'
   77    56      > RETURN                                                       null

End of function test

Class Subject:
Function int:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  int
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function int

Function bool:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  bool
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function bool

Function array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  array
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function array

Function float:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  float
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function float

Function string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  string
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function string

Function iterable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  iterable
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function iterable

Function callable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  callable
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function callable

Function void:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  void
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E > > RETURN                                                       null

End of function void

Function object:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  object
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function object

Function mixed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  mixed
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function mixed

Function self:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  self
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function self

Function integer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  integer
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function integer

Function boolean:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  boolean
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function boolean

Function double:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  double
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function double

Function resource:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  resource
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function resource

End of class Subject.

Class Subject2:
Function int:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  INT
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function int

Function bool:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  BOOL
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function bool

Function array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  ARRAY
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function array

Function float:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  FLOAT
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function float

Function string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  STRING
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function string

Function iterable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  ITERABLE
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function iterable

Function callable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  CALLABLE
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function callable

Function void:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  VOID
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E > > RETURN                                                       null

End of function void

Function object:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  OBJECT
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function object

Function mixed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  MIXED
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function mixed

Function self:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  SELF
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   38     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function self

Function integer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  INTEGER
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   41     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function integer

Function boolean:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  BOOLEAN
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   42     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function boolean

Function double:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  DOUBLE
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   43     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function double

Function resource:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fJgLA
function name:  RESOURCE
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function resource

End of class Subject2.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
153.91 ms | 1657 KiB | 14 Q