3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $ref; function __construct () { $this->ref = new class() { public $name; }; } public function create (string $name) { $this->ref->name = $name; return clone $this->ref; } } $A = new A(); $testA = $A->create("matti"); $testB = $A->create("Pekka"); var_dump($testA->name); var_dump($testB->name);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kBEnt
function name:  (null)
number of ops:  20
compiled vars:  !0 = $A, !1 = $testA, !2 = $testB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   23     3        INIT_METHOD_CALL                                         !0, 'create'
          4        SEND_VAL_EX                                              'matti'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !1, $6
   24     7        INIT_METHOD_CALL                                         !0, 'create'
          8        SEND_VAL_EX                                              'Pekka'
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !2, $8
   26    11        INIT_FCALL                                               'var_dump'
         12        FETCH_OBJ_R                                      ~10     !1, 'name'
         13        SEND_VAL                                                 ~10
         14        DO_ICALL                                                 
   27    15        INIT_FCALL                                               'var_dump'
         16        FETCH_OBJ_R                                      ~12     !2, 'name'
         17        SEND_VAL                                                 ~12
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class class@anonymous: [no user functions]
Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kBEnt
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_ANON_CLASS                               <unknown> 
          1        NEW                                              $2      $1
          2        DO_FCALL                                      0          
          3        ASSIGN_OBJ                                               'ref'
          4        OP_DATA                                                  $2
   12     5      > RETURN                                                   null

End of function __construct

Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kBEnt
function name:  create
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        FETCH_OBJ_W                                      $1      'ref'
          2        ASSIGN_OBJ                                               $1, 'name'
          3        OP_DATA                                                  !0
   17     4        FETCH_OBJ_R                                      ~3      'ref'
          5        CLONE                                            ~4      ~3
          6      > RETURN                                                   ~4
   18     7*     > RETURN                                                   null

End of function create

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
280.19 ms | 1396 KiB | 16 Q