3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class A{ protected $stuff; function __construct(int $foo){ $this->stuff = $foo; } function getStuff(): int{ return $this->stuff; } static function __set_state($data){ return new A($data['stuff']); } } $x = new A(10); eval('$y = ' . var_export($x, true) . ';'); var_dump($y->getStuff());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7jdRX
function name:  (null)
number of ops:  17
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $2      'A'
          1        SEND_VAL_EX                                              10
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   17     4        INIT_FCALL                                               'var_export'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $5      
          8        CONCAT                                           ~6      '%24y+%3D+', $5
          9        CONCAT                                           ~7      ~6, '%3B'
         10        INCLUDE_OR_EVAL                                          ~7, EVAL
   19    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !1, 'getStuff'
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

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

End of function __construct

Function getstuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7jdRX
function name:  getStuff
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'stuff'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   10     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getstuff

Function __set_state:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7jdRX
function name:  __set_state
number of ops:  8
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        NEW                                              $1      'A'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_DIM_FUNC_ARG                               $2      !0, 'stuff'
          4        SEND_FUNC_ARG                                            $2
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $1
   13     7*     > RETURN                                                   null

End of function __set_state

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.62 ms | 1400 KiB | 17 Q