3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ColorChanger { public $lastColors = []; public function blackMethod() { $colors = implode(', ', $this->lastColors); echo "blackMethod(); Last colors: {$colors}\n"; $this->lastColors[] = 'black'; return $this; } public function whiteMethod() { $colors = implode(', ', $this->lastColors); echo "whiteMethod(); Last colors: {$colors}\n"; $this->lastColors[] = 'white'; return $this; } public function colourMethod() { $colors = implode(', ', $this->lastColors); $lastColor = $this->lastColors[count($this->lastColors)-1]; echo "colourMethod(): {$colors} (Last: $lastColor)\n"; $this->lastColors = []; } } $c = new ColorChanger(); $c->blackMethod()->colourMethod(); $c->whiteMethod()->colourMethod(); $c->blackMethod()->whiteMethod()->blackMethod()->colourMethod();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hKiu6
function name:  (null)
number of ops:  20
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $1      'ColorChanger'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   31     3        INIT_METHOD_CALL                                         !0, 'blackMethod'
          4        DO_FCALL                                      0  $4      
          5        INIT_METHOD_CALL                                         $4, 'colourMethod'
          6        DO_FCALL                                      0          
   32     7        INIT_METHOD_CALL                                         !0, 'whiteMethod'
          8        DO_FCALL                                      0  $6      
          9        INIT_METHOD_CALL                                         $6, 'colourMethod'
         10        DO_FCALL                                      0          
   34    11        INIT_METHOD_CALL                                         !0, 'blackMethod'
         12        DO_FCALL                                      0  $8      
         13        INIT_METHOD_CALL                                         $8, 'whiteMethod'
         14        DO_FCALL                                      0  $9      
         15        INIT_METHOD_CALL                                         $9, 'blackMethod'
         16        DO_FCALL                                      0  $10     
         17        INIT_METHOD_CALL                                         $10, 'colourMethod'
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Class ColorChanger:
Function blackmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hKiu6
function name:  blackMethod
number of ops:  16
compiled vars:  !0 = $colors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'implode'
          1        SEND_VAL                                                 '%2C+'
          2        FETCH_OBJ_R                                      ~1      'lastColors'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
    9     6        ROPE_INIT                                     3  ~5      'blackMethod%28%29%3B+Last+colors%3A+'
          7        ROPE_ADD                                      1  ~5      ~5, !0
          8        ROPE_END                                      2  ~4      ~5, '%0A'
          9        ECHO                                                     ~4
   10    10        FETCH_OBJ_W                                      $7      'lastColors'
         11        ASSIGN_DIM                                               $7
         12        OP_DATA                                                  'black'
   11    13        FETCH_THIS                                       ~9      
         14      > RETURN                                                   ~9
   12    15*     > RETURN                                                   null

End of function blackmethod

Function whitemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hKiu6
function name:  whiteMethod
number of ops:  16
compiled vars:  !0 = $colors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'implode'
          1        SEND_VAL                                                 '%2C+'
          2        FETCH_OBJ_R                                      ~1      'lastColors'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   16     6        ROPE_INIT                                     3  ~5      'whiteMethod%28%29%3B+Last+colors%3A+'
          7        ROPE_ADD                                      1  ~5      ~5, !0
          8        ROPE_END                                      2  ~4      ~5, '%0A'
          9        ECHO                                                     ~4
   17    10        FETCH_OBJ_W                                      $7      'lastColors'
         11        ASSIGN_DIM                                               $7
         12        OP_DATA                                                  'white'
   18    13        FETCH_THIS                                       ~9      
         14      > RETURN                                                   ~9
   19    15*     > RETURN                                                   null

End of function whitemethod

Function colourmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hKiu6
function name:  colourMethod
number of ops:  21
compiled vars:  !0 = $colors, !1 = $lastColor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'implode'
          1        SEND_VAL                                                 '%2C+'
          2        FETCH_OBJ_R                                      ~2      'lastColors'
          3        SEND_VAL                                                 ~2
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !0, $3
   23     6        FETCH_OBJ_R                                      ~6      'lastColors'
          7        COUNT                                            ~7      ~6
          8        SUB                                              ~8      ~7, 1
          9        FETCH_OBJ_R                                      ~5      'lastColors'
         10        FETCH_DIM_R                                      ~9      ~5, ~8
         11        ASSIGN                                                   !1, ~9
   24    12        ROPE_INIT                                     5  ~12     'colourMethod%28%29%3A+'
         13        ROPE_ADD                                      1  ~12     ~12, !0
         14        ROPE_ADD                                      2  ~12     ~12, '+%28Last%3A+'
         15        ROPE_ADD                                      3  ~12     ~12, !1
         16        ROPE_END                                      4  ~11     ~12, '%29%0A'
         17        ECHO                                                     ~11
   25    18        ASSIGN_OBJ                                               'lastColors'
         19        OP_DATA                                                  <array>
   26    20      > RETURN                                                   null

End of function colourmethod

End of class ColorChanger.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.65 ms | 1015 KiB | 14 Q