3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { public function unlock() { $this->isLocked = false; echo 'You unlocked the Lock'."\n"; } public function lock() { $this->isLocked = true; echo 'You locked the Lock'."\n"; } public function isLocked() { return $this->isLocked; } } class Door { public function __construct(Lock $lock) { $this->lock = $lock; $this->connectsTo = 'bedroom'."\n"; } public function open() { if($this->lock->isLocked()) { echo 'Cannot open Door. It is locked.'."\n"; } else { echo 'You opened the Door connecting to: ', $this->connectsTo."\n"; } } } $lock = new Lock; $door = new Door($lock); $door->open(); $lock->unlock(); $door->open();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  (null)
number of ops:  14
compiled vars:  !0 = $lock, !1 = $door
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $2      'Lock'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   40     3        NEW                                              $5      'Door'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   41     7        INIT_METHOD_CALL                                         !1, 'open'
          8        DO_FCALL                                      0          
   43     9        INIT_METHOD_CALL                                         !0, 'unlock'
         10        DO_FCALL                                      0          
   44    11        INIT_METHOD_CALL                                         !1, 'open'
         12        DO_FCALL                                      0          
         13      > RETURN                                                   1

Class Lock:
Function unlock:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  unlock
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'isLocked'
          1        OP_DATA                                                  <false>
    8     2        ECHO                                                     'You+unlocked+the+Lock%0A'
    9     3      > RETURN                                                   null

End of function unlock

Function lock:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  lock
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN_OBJ                                               'isLocked'
          1        OP_DATA                                                  <true>
   13     2        ECHO                                                     'You+locked+the+Lock%0A'
   14     3      > RETURN                                                   null

End of function lock

Function islocked:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  isLocked
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'isLocked'
          1      > RETURN                                                   ~0
   18     2*     > RETURN                                                   null

End of function islocked

End of class Lock.

Class Door:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  __construct
number of ops:  6
compiled vars:  !0 = $lock
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        ASSIGN_OBJ                                               'lock'
          2        OP_DATA                                                  !0
   26     3        ASSIGN_OBJ                                               'connectsTo'
          4        OP_DATA                                                  'bedroom%0A'
   27     5      > RETURN                                                   null

End of function __construct

Function open:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30qZl
function name:  open
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'lock'
          1        INIT_METHOD_CALL                                         ~0, 'isLocked'
          2        DO_FCALL                                      0  $1      
          3      > JMPZ                                                     $1, ->6
   31     4    >   ECHO                                                     'Cannot+open+Door.+It+is+locked.%0A'
          5      > JMP                                                      ->10
   33     6    >   ECHO                                                     'You+opened+the+Door+connecting+to%3A+'
          7        FETCH_OBJ_R                                      ~2      'connectsTo'
          8        CONCAT                                           ~3      ~2, '%0A'
          9        ECHO                                                     ~3
   35    10    > > RETURN                                                   null

End of function open

End of class Door.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.08 ms | 1399 KiB | 13 Q