3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class AnonymousExtendsExistingClassInUnion { private ?DateTime $x = null; public function __construct() { if (rand(0,1)) { $this->x = new \DateTime('now'); var_dump('not extends'); var_dump($this->x); } else { $this->x = new class extends \DateTime {}; var_dump('extends'); var_dump($this->x); } } } (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion()); (new AnonymousExtendsExistingClassInUnion());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HTQT
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $0      'AnonymousExtendsExistingClassInUnion'
          1        DO_FCALL                                      0          
          2        FREE                                                     $0
   22     3        NEW                                              $2      'AnonymousExtendsExistingClassInUnion'
          4        DO_FCALL                                      0          
          5        FREE                                                     $2
   23     6        NEW                                              $4      'AnonymousExtendsExistingClassInUnion'
          7        DO_FCALL                                      0          
          8        FREE                                                     $4
   24     9        NEW                                              $6      'AnonymousExtendsExistingClassInUnion'
         10        DO_FCALL                                      0          
         11        FREE                                                     $6
   25    12        NEW                                              $8      'AnonymousExtendsExistingClassInUnion'
         13        DO_FCALL                                      0          
         14        FREE                                                     $8
   26    15        NEW                                              $10     'AnonymousExtendsExistingClassInUnion'
         16        DO_FCALL                                      0          
         17        FREE                                                     $10
   27    18        NEW                                              $12     'AnonymousExtendsExistingClassInUnion'
         19        DO_FCALL                                      0          
         20        FREE                                                     $12
   28    21        NEW                                              $14     'AnonymousExtendsExistingClassInUnion'
         22        DO_FCALL                                      0          
         23        FREE                                                     $14
   29    24        NEW                                              $16     'AnonymousExtendsExistingClassInUnion'
         25        DO_FCALL                                      0          
         26        FREE                                                     $16
   30    27        NEW                                              $18     'AnonymousExtendsExistingClassInUnion'
         28        DO_FCALL                                      0          
         29        FREE                                                     $18
         30      > RETURN                                                   1

Class DateTime@anonymous: [no user functions]
Class AnonymousExtendsExistingClassInUnion:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4HTQT
function name:  __construct
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'rand'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 1
          3        DO_ICALL                                         $0      
          4      > JMPZ                                                     $0, ->18
   10     5    >   NEW                                              $2      'DateTime'
          6        SEND_VAL_EX                                              'now'
          7        DO_FCALL                                      0          
          8        ASSIGN_OBJ                                               'x'
          9        OP_DATA                                                  $2
   11    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAL                                                 'not+extends'
         12        DO_ICALL                                                 
   12    13        INIT_FCALL                                               'var_dump'
         14        FETCH_OBJ_R                                      ~5      'x'
         15        SEND_VAL                                                 ~5
         16        DO_ICALL                                                 
    9    17      > JMP                                                      ->30
   14    18    >   DECLARE_ANON_CLASS                               <unknown> 'datetime'
         19        NEW                                              $9      $8
         20        DO_FCALL                                      0          
         21        ASSIGN_OBJ                                               'x'
         22        OP_DATA                                                  $9
   15    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAL                                                 'extends'
         25        DO_ICALL                                                 
   16    26        INIT_FCALL                                               'var_dump'
         27        FETCH_OBJ_R                                      ~12     'x'
         28        SEND_VAL                                                 ~12
         29        DO_ICALL                                                 
   18    30    > > RETURN                                                   null

End of function __construct

End of class AnonymousExtendsExistingClassInUnion.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.88 ms | 1094 KiB | 15 Q