3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {}; class Bar extends Foo {}; function testClass($class) { $reflection = new ReflectionClass($class); return $reflection->isSubclassOf(Foo::class) || ($reflection->getName() == (new ReflectionClass(Foo::class))->getName()); }; var_dump($testClass(Foo::class), $testClass(Bar::class));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aNcBP
function name:  (null)
number of ops:  11
compiled vars:  !0 = $testClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_DYNAMIC_CALL                                        !0
          2        SEND_VAL_EX                                              'Foo'
          3        DO_FCALL                                      0  $1      
          4        SEND_VAR                                                 $1
          5        INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAL_EX                                              'Bar'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function testclass:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/aNcBP
function name:  testClass
number of ops:  20
compiled vars:  !0 = $class, !1 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        NEW                                              $2      'ReflectionClass'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
    9     5        INIT_METHOD_CALL                                         !1, 'isSubclassOf'
          6        SEND_VAL_EX                                              'Foo'
          7        DO_FCALL                                      0  $5      
          8      > JMPNZ_EX                                         ~6      $5, ->18
          9    >   INIT_METHOD_CALL                                         !1, 'getName'
         10        DO_FCALL                                      0  $7      
         11        NEW                                              $8      'ReflectionClass'
         12        SEND_VAL_EX                                              'Foo'
         13        DO_FCALL                                      0          
         14        INIT_METHOD_CALL                                         $8, 'getName'
         15        DO_FCALL                                      0  $10     
         16        IS_EQUAL                                         ~11     $7, $10
         17        BOOL                                             ~6      ~11
         18    > > RETURN                                                   ~6
   10    19*     > RETURN                                                   null

End of function testclass

Class Foo: [no user functions]
Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.23 ms | 1388 KiB | 15 Q