3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface proxy {} trait assertFinal { private function assertFinal() { if (is_subclass_of($this, __CLASS__, false) && !$this instanceof proxy) { trigger_error('Nein! Class is final!', E_USER_NOTICE); } } } class finalfoo { use assertFinal; public function __construct() { $this->assertFinal(); } } class fooproxy extends finalfoo implements proxy { } class naughtyfoo extends finalfoo { } echo "new finalfoo: "; try {new finalfoo; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n"; echo "new fooproxy: "; try {new fooproxy; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n"; echo "new naughtyfoo: "; try {new naughtyfoo; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 9
Branch analysis from position: 9
2 jumps found. (Code = 107) Position 1 = 10, Position 2 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Found catch point at position: 18
Branch analysis from position: 18
2 jumps found. (Code = 107) Position 1 = 19, Position 2 = -2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Found catch point at position: 27
Branch analysis from position: 27
2 jumps found. (Code = 107) Position 1 = 28, Position 2 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HUYkX
function name:  (null)
number of ops:  31
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_CLASS                                            'finalfoo'
   25     1        DECLARE_CLASS                                            'fooproxy', 'finalfoo'
   30     2        DECLARE_CLASS                                            'naughtyfoo', 'finalfoo'
   35     3        ECHO                                                     'new+finalfoo%3A+'
          4        NEW                                              $1      'finalfoo'
          5        DO_FCALL                                      0          
          6        FREE                                                     $1
          7        ECHO                                                     'yes'
          8      > JMP                                                      ->11
          9  E > > CATCH                                       last         'Exception'
         10    >   ECHO                                                     'no'
         11    >   ECHO                                                     '%0A'
   36    12        ECHO                                                     'new+fooproxy%3A+'
         13        NEW                                              $3      'fooproxy'
         14        DO_FCALL                                      0          
         15        FREE                                                     $3
         16        ECHO                                                     'yes'
         17      > JMP                                                      ->20
         18  E > > CATCH                                       last         'Exception'
         19    >   ECHO                                                     'no'
         20    >   ECHO                                                     '%0A'
   37    21        ECHO                                                     'new+naughtyfoo%3A+'
         22        NEW                                              $5      'naughtyfoo'
         23        DO_FCALL                                      0          
         24        FREE                                                     $5
         25        ECHO                                                     'yes'
         26      > JMP                                                      ->29
         27  E > > CATCH                                       last         'Exception'
         28    >   ECHO                                                     'no'
         29    >   ECHO                                                     '%0A'
         30      > RETURN                                                   1

Class proxy: [no user functions]
Class assertFinal:
Function assertfinal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 12
filename:       /in/HUYkX
function name:  assertFinal
number of ops:  18
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'is_subclass_of'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        FETCH_CLASS_NAME                                 ~1      
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 <false>
          6        DO_ICALL                                         $2      
          7      > JMPZ_EX                                          ~3      $2, ->12
          8    >   FETCH_THIS                                       ~4      
          9        INSTANCEOF                                       ~5      ~4, 'proxy'
         10        BOOL_NOT                                         ~6      ~5
         11        BOOL                                             ~3      ~6
         12    > > JMPZ                                                     ~3, ->17
   10    13    >   INIT_FCALL                                               'trigger_error'
         14        SEND_VAL                                                 'Nein%21+Class+is+final%21'
         15        SEND_VAL                                                 1024
         16        DO_ICALL                                                 
   12    17    > > RETURN                                                   null

End of function assertfinal

End of class assertFinal.

Class finalfoo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HUYkX
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_METHOD_CALL                                         'assertFinal'
          1        DO_FCALL                                      0          
   22     2      > RETURN                                                   null

End of function __construct

End of class finalfoo.

Class fooproxy: [no user functions]
Class naughtyfoo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.89 ms | 1400 KiB | 17 Q