3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @psalm-param class-string $class * @psalm-return \Generator<class-string> */ function classTypes(string $class): \Generator { yield $class; yield from class_parents($class); yield from (new \ReflectionClass($class))->getInterfaceNames(); } interface I1 {} interface I2 {} abstract class A implements I1 {} final class B extends A implements I2 {} var_dump(iterator_to_array(classTypes(B::class), false));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CBuMQ
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_CLASS                                            'a'
   20     1        DECLARE_CLASS                                            'b', 'a'
   22     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'iterator_to_array'
          4        INIT_FCALL                                               'classtypes'
          5        SEND_VAL                                                 'B'
          6        DO_FCALL                                      0  $0      
          7        SEND_VAR                                                 $0
          8        SEND_VAL                                                 <false>
          9        DO_ICALL                                         $1      
         10        SEND_VAR                                                 $1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function classtypes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/CBuMQ
function name:  classTypes
number of ops:  16
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    9     2        YIELD                                                    !0
   10     3        INIT_FCALL                                               'class_parents'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        YIELD_FROM                                       ~3      $2
          7        FREE                                                     ~3
   11     8        NEW                                              $4      'ReflectionClass'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        INIT_METHOD_CALL                                         $4, 'getInterfaceNames'
         12        DO_FCALL                                      0  $6      
         13        YIELD_FROM                                       ~7      $6
         14        FREE                                                     ~7
   12    15      > GENERATOR_RETURN                                         

End of function classtypes

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:
191.66 ms | 1399 KiB | 20 Q