3v4l.org

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

Class class@anonymous:
Function sayname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eNmMT
function name:  sayName
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   VERIFY_RETURN_TYPE                                       !0
          1      > RETURN                                                   !0
   14     2*       VERIFY_RETURN_TYPE                                       
          3*     > RETURN                                                   null

End of function sayname

End of class class@anonymous.

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

End of function create

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.92 ms | 1400 KiB | 15 Q