3v4l.org

run code in 300+ PHP versions simultaneously
<?php function creator($var) { return new class($var) extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; } print "From method:\n"; $a = creator('A'); $b = creator('B'); var_dump($a, $b, $a === $b); print "----------\n"; print "In clear:\n"; $c = new class('C') extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; $d = new class('D') extends StdClass { private static $var; function __construct($var) { static::$var = $var; } function __debugInfo() { return [ "\0*\0var" => static::$var, ]; } }; var_dump($c, $d, $c === $d); print "----------\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  (null)
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ECHO                                                     'From+method%3A%0A'
   22     1        INIT_FCALL                                               'creator'
          2        SEND_VAL                                                 'A'
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !0, $4
   23     5        INIT_FCALL                                               'creator'
          6        SEND_VAL                                                 'B'
          7        DO_FCALL                                      0  $6      
          8        ASSIGN                                                   !1, $6
   24     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        IS_IDENTICAL                                     ~8      !0, !1
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                                 
   25    15        ECHO                                                     '----------%0A'
   27    16        ECHO                                                     'In+clear%3A%0A'
   28    17        DECLARE_ANON_CLASS                               <unknown> 'stdclass'
         18        NEW                                              $11     $10
         19        SEND_VAL_EX                                              'C'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !2, $11
   42    22        DECLARE_ANON_CLASS                               <unknown> 'stdclass'
         23        NEW                                              $15     $14
         24        SEND_VAL_EX                                              'D'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !3, $15
   56    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !2
         29        SEND_VAR                                                 !3
         30        IS_IDENTICAL                                     ~18     !2, !3
         31        SEND_VAL                                                 ~18
         32        DO_ICALL                                                 
   57    33        ECHO                                                     '----------%0A'
         34      > RETURN                                                   1

Function creator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  creator
number of ops:  7
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        DECLARE_ANON_CLASS                               <undef> 'stdclass'
          2        NEW                                              $2      $1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $2
   19     6*     > RETURN                                                   null

End of function creator

Class StdClass@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __construct
number of ops:  4
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_STATIC_PROP                                       'var'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function __debuginfo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __debugInfo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'var'
          1        INIT_ARRAY                                       ~1      ~0, '%00%2A%00var'
          2      > RETURN                                                   ~1
   17     3*     > RETURN                                                   null

End of function __debuginfo

End of class StdClass@anonymous.

Class StdClass@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __construct
number of ops:  4
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        ASSIGN_STATIC_PROP                                       'var'
          2        OP_DATA                                                  !0
   33     3      > RETURN                                                   null

End of function __construct

Function __debuginfo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __debugInfo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'var'
          1        INIT_ARRAY                                       ~1      ~0, '%00%2A%00var'
          2      > RETURN                                                   ~1
   40     3*     > RETURN                                                   null

End of function __debuginfo

End of class StdClass@anonymous.

Class StdClass@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __construct
number of ops:  4
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        ASSIGN_STATIC_PROP                                       'var'
          2        OP_DATA                                                  !0
   47     3      > RETURN                                                   null

End of function __construct

Function __debuginfo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bgjqn
function name:  __debugInfo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'var'
          1        INIT_ARRAY                                       ~1      ~0, '%00%2A%00var'
          2      > RETURN                                                   ~1
   54     3*     > RETURN                                                   null

End of function __debuginfo

End of class StdClass@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.02 ms | 1407 KiB | 17 Q