3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Context { private int $a; private int $b; /** * @param int $a */ public function setA(int $a): self { $new = new self(); $new->setA($a); $new->setB($this->b); return $new; } public function setB(int $b): self { $new = new self(); $new->setA($this->a); $new->setB($b); return $new; } public function getData(): array { return [ 'a' => $this->a, 'b' => $this->b, ]; } } function test(Context &$context) { $context = $context->setB(5); } $context = new Context(); $context = $context->setA(2); test($context); var_dump($context->getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcT91
function name:  (null)
number of ops:  16
compiled vars:  !0 = $context
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $1      'Context'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   47     3        INIT_METHOD_CALL                                         !0, 'setA'
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !0, $4
   49     7        INIT_FCALL                                               'test'
          8        SEND_REF                                                 !0
          9        DO_FCALL                                      0          
   51    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'getData'
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcT91
function name:  test
number of ops:  6
compiled vars:  !0 = $context
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   42     1        INIT_METHOD_CALL                                         !0, 'setB'
          2        SEND_VAL_EX                                              5
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   43     5      > RETURN                                                   null

End of function test

Class Context:
Function seta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcT91
function name:  setA
number of ops:  16
compiled vars:  !0 = $a, !1 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   15     4        INIT_METHOD_CALL                                         !1, 'setA'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   16     7        INIT_METHOD_CALL                                         !1, 'setB'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $6      'b'
         10        SEND_FUNC_ARG                                            $6
         11        DO_FCALL                                      0          
   18    12        VERIFY_RETURN_TYPE                                       !1
         13      > RETURN                                                   !1
   19    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function seta

Function setb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcT91
function name:  setB
number of ops:  16
compiled vars:  !0 = $b, !1 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        NEW                          self                $2      
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   25     4        INIT_METHOD_CALL                                         !1, 'setA'
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $5      'a'
          7        SEND_FUNC_ARG                                            $5
          8        DO_FCALL                                      0          
   26     9        INIT_METHOD_CALL                                         !1, 'setB'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   28    12        VERIFY_RETURN_TYPE                                       !1
         13      > RETURN                                                   !1
   29    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function setb

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dcT91
function name:  getData
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        INIT_ARRAY                                       ~1      ~0, 'a'
   35     2        FETCH_OBJ_R                                      ~2      'b'
          3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'b'
          4        VERIFY_RETURN_TYPE                                       ~1
          5      > RETURN                                                   ~1
   37     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function getdata

End of class Context.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.61 ms | 1095 KiB | 15 Q