3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); file_put_contents('/tmp/bug2.php', <<<EOT <?php declare(strict_types=1); class myParentClass { const myConst = 'Parent'; } EOT ); require('/tmp/bug2.php'); // Error: mySubClass2 does NOT exist! var_dump( class_exists( 'myClass1', FALSE ), class_exists( 'mySubClass1', FALSE ), class_exists( 'myParentClass', FALSE ), class_exists( 'mySubClass2', FALSE ) ); class myClass1 { const myConst = 'C1'; } class mySubClass1 extends myClass1 { const myConst = 'S1'; } class mySubClass2 extends myParentClass { const myConst = 'S2'; } // Correct: Now mySubClass2 DOES exist! var_dump( class_exists( 'myClass1', FALSE ), class_exists( 'mySubClass1', FALSE ), class_exists( 'myParentClass', FALSE ), class_exists( 'mySubClass2', FALSE ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GnDr2
function name:  (null)
number of ops:  51
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   INIT_FCALL                                               'file_put_contents'
         1        SEND_VAL                                                 '%2Ftmp%2Fbug2.php'
   4     2        SEND_VAL                                                 '%3C%3Fphp+declare%28strict_types%3D1%29%3B%0A%0Aclass+myParentClass+%7B%0A++++const+myConst+%09%09%09%3D+%27Parent%27%3B%0A%7D'
         3        DO_ICALL                                                 
  12     4        INCLUDE_OR_EVAL                                          '%2Ftmp%2Fbug2.php', REQUIRE
  15     5        INIT_FCALL                                               'var_dump'
  16     6        INIT_FCALL                                               'class_exists'
         7        SEND_VAL                                                 'myClass1'
         8        SEND_VAL                                                 <false>
         9        DO_ICALL                                         $2      
        10        SEND_VAR                                                 $2
  17    11        INIT_FCALL                                               'class_exists'
        12        SEND_VAL                                                 'mySubClass1'
        13        SEND_VAL                                                 <false>
        14        DO_ICALL                                         $3      
        15        SEND_VAR                                                 $3
  18    16        INIT_FCALL                                               'class_exists'
        17        SEND_VAL                                                 'myParentClass'
        18        SEND_VAL                                                 <false>
        19        DO_ICALL                                         $4      
        20        SEND_VAR                                                 $4
  19    21        INIT_FCALL                                               'class_exists'
        22        SEND_VAL                                                 'mySubClass2'
        23        SEND_VAL                                                 <false>
        24        DO_ICALL                                         $5      
        25        SEND_VAR                                                 $5
        26        DO_ICALL                                                 
  30    27        ADD_INTERFACE                                            'mysubclass2', 'myparentclass'
  35    28        INIT_FCALL                                               'var_dump'
  36    29        INIT_FCALL                                               'class_exists'
        30        SEND_VAL                                                 'myClass1'
        31        SEND_VAL                                                 <false>
        32        DO_ICALL                                         $7      
        33        SEND_VAR                                                 $7
  37    34        INIT_FCALL                                               'class_exists'
        35        SEND_VAL                                                 'mySubClass1'
        36        SEND_VAL                                                 <false>
        37        DO_ICALL                                         $8      
        38        SEND_VAR                                                 $8
  38    39        INIT_FCALL                                               'class_exists'
        40        SEND_VAL                                                 'myParentClass'
        41        SEND_VAL                                                 <false>
        42        DO_ICALL                                         $9      
        43        SEND_VAR                                                 $9
  39    44        INIT_FCALL                                               'class_exists'
        45        SEND_VAL                                                 'mySubClass2'
        46        SEND_VAL                                                 <false>
        47        DO_ICALL                                         $10     
        48        SEND_VAR                                                 $10
        49        DO_ICALL                                                 
  40    50      > RETURN                                                   1

Class myClass1: [no user functions]
Class mySubClass1: [no user functions]
Class mySubClass2: [no user functions]

Generated using Vulcan Logic Dumper, using php 7.4.0