3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function &declare_int(int $value) { static $references = []; $valueWrapper = new class(5) { public function __construct(public int $value) { } }; $references[] = $valueWrapper; return $valueWrapper->value; } $intVariable = &declare_int(0); $intVariable = 42; // works $intVariable = 'test'; // fails
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T6GFS
function name:  (null)
number of ops:  7
compiled vars:  !0 = $intVariable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'declare_int'
          1        SEND_VAL                                                 0
          2        DO_FCALL                                      0  $1      
          3        ASSIGN_REF                                               !0, $1
   18     4        ASSIGN                                                   !0, 42
   19     5        ASSIGN                                                   !0, 'test'
          6      > RETURN                                                   1

Function declare_int:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/T6GFS
function name:  declare_int
number of ops:  12
compiled vars:  !0 = $value, !1 = $references, !2 = $valueWrapper
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        BIND_STATIC                                              !1
    7     2        DECLARE_ANON_CLASS                               <unknown> 
          3        NEW                                              $4      $3
          4        SEND_VAL_EX                                              5
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $4
   11     7        ASSIGN_DIM                                               !1
          8        OP_DATA                                                  !2
   13     9        FETCH_OBJ_W                                      $8      !2, 'value'
         10      > RETURN_BY_REF                                            $8
   14    11*     > RETURN_BY_REF                                            null

End of function declare_int

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

End of function __construct

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.4 ms | 1399 KiB | 14 Q