3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Constraint {} #[Attribute(Attribute::TARGET_PROPERTY|Attribute::TARGET_METHOD|Attribute::TARGET_PARAMETER)] class NotNull implements Constraint {} class App { #[NotNull] public function test(): void {} } foreach((new ReflectionMethod(App::class, 'test'))->getAttributes() as $attribute) if((new ReflectionClass($attribute->getName()))->implementsInterface(Constraint::class)) echo 'Success';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/72aJN
function name:  (null)
number of ops:  22
compiled vars:  !0 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'notnull'
   14     1        NEW                                              $1      'ReflectionMethod'
          2        SEND_VAL_EX                                              'App'
          3        SEND_VAL_EX                                              'test'
          4        DO_FCALL                                      0          
          5        INIT_METHOD_CALL                                         $1, 'getAttributes'
          6        DO_FCALL                                      0  $3      
          7      > FE_RESET_R                                       $4      $3, ->20
          8    > > FE_FETCH_R                                               $4, !0, ->20
   15     9    >   NEW                                              $5      'ReflectionClass'
         10        INIT_METHOD_CALL                                         !0, 'getName'
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR_NO_REF_EX                                       $6
         13        DO_FCALL                                      0          
         14        INIT_METHOD_CALL                                         $5, 'implementsInterface'
         15        SEND_VAL_EX                                              'Constraint'
         16        DO_FCALL                                      0  $8      
         17      > JMPZ                                                     $8, ->19
   16    18    >   ECHO                                                     'Success'
   14    19    > > JMP                                                      ->8
         20    >   FE_FREE                                                  $4
   16    21      > RETURN                                                   1

Class Constraint: [no user functions]
Class NotNull: [no user functions]
Class App:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/72aJN
function name:  test
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   null

End of function test

End of class App.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.79 ms | 996 KiB | 13 Q