3v4l.org

run code in 500+ PHP versions simultaneously
<?php class a { public function test(): self|string { return new \stdClass; } }; $b = new class { public function test(): self|string { return new \stdClass; } }; try { (new a)->test(); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; } try { $b->test(); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
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 = 22
Branch analysis from position: 22
Found catch point at position: 17
Branch analysis from position: 17
2 jumps found. (Code = 107) Position 1 = 18, Position 2 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e83WV
function name:  (null)
number of ops:  23
compiled vars:  !0 = $b, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   DECLARE_ANON_CLASS                                   <reference>   
          1        NEW                                                  $3      $2
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   18     4        NEW                                                  $6      'a'
          5        DO_FCALL                                          0          
          6        INIT_METHOD_CALL                                             $6, 'test'
          7        DO_FCALL                                          0          
          8      > JMP                                                          ->14
   19     9  E > > CATCH                                           last         'Throwable'
   20    10    >   INIT_METHOD_CALL                                             !1, 'getMessage'
         11        DO_FCALL                                          0  $9      
         12        CONCAT                                               ~10     $9, '%0A'
         13        ECHO                                                         ~10
   24    14    >   INIT_METHOD_CALL                                             !0, 'test'
         15        DO_FCALL                                          0          
         16      > JMP                                                          ->22
   25    17  E > > CATCH                                           last         'Throwable'
   26    18    >   INIT_METHOD_CALL                                             !1, 'getMessage'
         19        DO_FCALL                                          0  $12     
         20        CONCAT                                               ~13     $12, '%0A'
         21        ECHO                                                         ~13
   27    22    > > RETURN                                                       1

Class a:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e83WV
function name:  test
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   NEW                                                  $0      'stdClass'
          1        DO_FCALL                                          0          
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
    7     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function test

End of class a.

Class class@anonymous:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e83WV
function name:  test
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   NEW                                                  $0      'stdClass'
          1        DO_FCALL                                          0          
          2        VERIFY_RETURN_TYPE                                           $0
          3      > RETURN                                                       $0
   14     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function test

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
193.95 ms | 1669 KiB | 13 Q