3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum Marker {} #[Marker] class C {} class D {} function has_marker(string $class) { return !empty((new ReflectionClass($class))->getAttributes(Marker::class)); } var_dump(has_marker(C::class)); var_dump(has_marker(D::class));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8Lih3
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'marker'
   13     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'has_marker'
          3        SEND_VAL                                                     'C'
          4        DO_FCALL                                          0  $0      
          5        SEND_VAR                                                     $0
          6        DO_ICALL                                                     
   14     7        INIT_FCALL                                                   'var_dump'
          8        INIT_FCALL                                                   'has_marker'
          9        SEND_VAL                                                     'D'
         10        DO_FCALL                                          0  $2      
         11        SEND_VAR                                                     $2
         12        DO_ICALL                                                     
         13      > RETURN                                                       1

Function has_marker:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8Lih3
function name:  has_marker
number of ops:  11
compiled vars:  !0 = $class
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
   10     1        NEW                                                  $1      'ReflectionClass'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        INIT_METHOD_CALL                                             $1, 'getAttributes'
          5        SEND_VAL_EX                                                  'Marker'
          6        DO_FCALL                                          0  $3      
          7        BOOL_NOT                                             ~4      $3
          8        BOOL_NOT                                             ~5      ~4
          9      > RETURN                                                       ~5
   11    10*     > RETURN                                                       null

End of function has_marker

Class Marker: [no user functions]
Class C: [no user functions]
Class D: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.12 ms | 1215 KiB | 16 Q