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($attribute->newInstance() instanceof Constraint) echo 'Success';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/fFl3X
function name:  (null)
number of ops:  17
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, ->15
          8    > > FE_FETCH_R                                               $4, !0, ->15
   15     9    >   INIT_METHOD_CALL                                         !0, 'newInstance'
         10        DO_FCALL                                      0  $5      
         11        INSTANCEOF                                               $5, 'Constraint'
         12      > JMPZ                                                     ~6, ->14
   16    13    >   ECHO                                                     'Success'
   14    14    > > JMP                                                      ->8
         15    >   FE_FREE                                                  $4
   16    16      > 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/fFl3X
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:
251.88 ms | 995 KiB | 13 Q