3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @return non-empty-list<non-empty-string> */ function valueTypes(mixed $value): array { if (is_object($value)) { return [ $value::class, ...array_values(class_parents($value)), ...array_values(class_implements($value)), ]; } return [get_debug_type($value)]; } interface I1 {} interface I2 {} abstract class A implements I1 {} final class B extends A implements I2 {} var_dump(valueTypes(1)); var_dump(valueTypes('string')); var_dump(valueTypes(new B()));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DFuO8
function name:  (null)
number of ops:  23
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   DECLARE_CLASS                                            'a'
   25     1        DECLARE_CLASS                                            'b', 'a'
   27     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'valuetypes'
          4        SEND_VAL                                                 1
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                                 
   28     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'valuetypes'
         10        SEND_VAL                                                 'string'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   29    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'valuetypes'
         16        NEW                                              $4      'B'
         17        DO_FCALL                                      0          
         18        SEND_VAR                                                 $4
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function valuetypes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DFuO8
function name:  valueTypes
number of ops:  29
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        TYPE_CHECK                                  256          !0
          2      > JMPZ                                                     ~1, ->21
   10     3    >   FETCH_CLASS_NAME                                 ~2      !0
          4        INIT_ARRAY                                       ~3      ~2
   11     5        INIT_FCALL                                               'array_values'
          6        INIT_FCALL                                               'class_parents'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                         $5      
         11        ADD_ARRAY_UNPACK                                 ~3      $5
   12    12        INIT_FCALL                                               'array_values'
         13        INIT_FCALL                                               'class_implements'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                         $7      
         18        ADD_ARRAY_UNPACK                                 ~3      $7
         19        VERIFY_RETURN_TYPE                                       ~3
         20      > RETURN                                                   ~3
   16    21    >   INIT_FCALL                                               'get_debug_type'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $8      
         24        INIT_ARRAY                                       ~9      $8
         25        VERIFY_RETURN_TYPE                                       ~9
         26      > RETURN                                                   ~9
   17    27*       VERIFY_RETURN_TYPE                                       
         28*     > RETURN                                                   null

End of function valuetypes

Class I1: [no user functions]
Class I2: [no user functions]
Class A: [no user functions]
Class B: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.21 ms | 1444 KiB | 21 Q