3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makeClass($someData) { $c = new class { public static $d; public static function getData() { return self::$d; } }; $c::$d = $someData; return $c; }; $c1 = makeClass('a'); $c2 = makeClass('b'); assert($c1 !== $c2); assert($c2::getData() === 'b'); assert($c1::getData() === 'a'); assert(get_class($c1) !== get_class($c2)); echo "Ok";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZSoeI
function name:  (null)
number of ops:  42
compiled vars:  !0 = $c1, !1 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'makeclass'
          1        SEND_VAL                                                 'a'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   15     4        INIT_FCALL                                               'makeclass'
          5        SEND_VAL                                                 'b'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   17     8        ASSERT_CHECK                                             
          9        INIT_FCALL                                               'assert'
         10        IS_NOT_IDENTICAL                                 ~6      !0, !1
         11        SEND_VAL                                                 ~6
         12        SEND_VAL                                                 'assert%28%24c1+%21%3D%3D+%24c2%29'
         13        DO_ICALL                                                 
   18    14        ASSERT_CHECK                                             
         15        INIT_FCALL                                               'assert'
         16        FETCH_CLASS                                   0  $8      !1
         17        INIT_STATIC_METHOD_CALL                                  $8, 'getData'
         18        DO_FCALL                                      0  $9      
         19        IS_IDENTICAL                                     ~10     $9, 'b'
         20        SEND_VAL                                                 ~10
         21        SEND_VAL                                                 'assert%28%24c2%3A%3AgetData%28%29+%3D%3D%3D+%27b%27%29'
         22        DO_ICALL                                                 
   19    23        ASSERT_CHECK                                             
         24        INIT_FCALL                                               'assert'
         25        FETCH_CLASS                                   0  $12     !0
         26        INIT_STATIC_METHOD_CALL                                  $12, 'getData'
         27        DO_FCALL                                      0  $13     
         28        IS_IDENTICAL                                     ~14     $13, 'a'
         29        SEND_VAL                                                 ~14
         30        SEND_VAL                                                 'assert%28%24c1%3A%3AgetData%28%29+%3D%3D%3D+%27a%27%29'
         31        DO_ICALL                                                 
   20    32        ASSERT_CHECK                                             
         33        INIT_FCALL                                               'assert'
         34        GET_CLASS                                        ~16     !0
         35        GET_CLASS                                        ~17     !1
         36        IS_NOT_IDENTICAL                                 ~18     ~16, ~17
         37        SEND_VAL                                                 ~18
         38        SEND_VAL                                                 'assert%28get_class%28%24c1%29+%21%3D%3D+get_class%28%24c2%29%29'
         39        DO_ICALL                                                 
   21    40        ECHO                                                     'Ok'
         41      > RETURN                                                   1

Function makeclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZSoeI
function name:  makeClass
number of ops:  10
compiled vars:  !0 = $someData, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        DECLARE_ANON_CLASS                               3       
          2        NEW                                              $3      $2
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   10     5        FETCH_CLASS                                   0  $6      !1
          6        ASSIGN_STATIC_PROP                                       'd', $6
          7        OP_DATA                                                  !0
   11     8      > RETURN                                                   !1
   12     9*     > RETURN                                                   null

End of function makeclass

Class class@anonymous:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZSoeI
function name:  getData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'd'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function getdata

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.6 ms | 1403 KiB | 17 Q