3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {}; class Bar extends Foo {}; $foo_name = (new ReflectionClass(Foo::class))->getName(); $testClass = function($class) use ($foo_name) { $reflection = new ReflectionClass($class); return $reflection->isSubclassOf(Foo::class) || ($reflection->getName() == $foo_name); }; 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/ZPnbR
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo_name, !1 = $testClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                                              $2      'ReflectionClass'
          1        SEND_VAL_EX                                              'Foo'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $2, 'getName'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !0, $4
    7     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZPnbR%3A7%240'
          7        BIND_LEXICAL                                             ~6, !0
          8        ASSIGN                                                   !1, ~6
   13     9        INIT_FCALL                                               'var_dump'
         10        INIT_DYNAMIC_CALL                                        !1
         11        SEND_VAL_EX                                              'Foo'
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        INIT_DYNAMIC_CALL                                        !1
         15        SEND_VAL_EX                                              'Bar'
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZPnbR%3A7%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/ZPnbR
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $class, !1 = $foo_name, !2 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    8     2        NEW                                              $3      'ReflectionClass'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $3
   10     6        INIT_METHOD_CALL                                         !2, 'isSubclassOf'
          7        SEND_VAL_EX                                              'Foo'
          8        DO_FCALL                                      0  $6      
          9      > JMPNZ_EX                                         ~7      $6, ->14
         10    >   INIT_METHOD_CALL                                         !2, 'getName'
         11        DO_FCALL                                      0  $8      
         12        IS_EQUAL                                         ~9      !1, $8
         13        BOOL                                             ~7      ~9
         14    > > RETURN                                                   ~7
   11    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZPnbR%3A7%240

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.02 ms | 1396 KiB | 15 Q