3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { private $state = "valid"; public function getState(){ return $this->state; } public function changeState($inject){ $this->state = "invalid"; // State is temporarily invalid. It will be // valid again before the method returns. // This is ok, right? $inject->qux(); // State is valid again, the method returns. $this->state = "valid"; } } $bar = new Bar(); $bar->changeState(new class($bar){ function __construct(Bar $bar){ $this->bar = $bar; } function qux(){ echo "The state is: " . $this->bar->getState() . "!"; } });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsiFW
function name:  (null)
number of ops:  11
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'changeState'
          4        DECLARE_ANON_CLASS                               <unknown> 
          5        NEW                                              $5      $4
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $5
          9        DO_FCALL                                      0          
   36    10      > RETURN                                                   1

Class Bar:
Function getstate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsiFW
function name:  getState
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'state'
          1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getstate

Function changestate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsiFW
function name:  changeState
number of ops:  8
compiled vars:  !0 = $inject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'state'
          2        OP_DATA                                                  'invalid'
   18     3        INIT_METHOD_CALL                                         !0, 'qux'
          4        DO_FCALL                                      0          
   21     5        ASSIGN_OBJ                                               'state'
          6        OP_DATA                                                  'valid'
   22     7      > RETURN                                                   null

End of function changestate

End of class Bar.

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

End of function __construct

Function qux:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JsiFW
function name:  qux
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1        INIT_METHOD_CALL                                         ~0, 'getState'
          2        DO_FCALL                                      0  $1      
          3        CONCAT                                           ~2      'The+state+is%3A+', $1
          4        CONCAT                                           ~3      ~2, '%21'
          5        ECHO                                                     ~3
   35     6      > RETURN                                                   null

End of function qux

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.01 ms | 1403 KiB | 13 Q