3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ColorShifter{ private $colors; public function __construct($colors) { $this->colors = new ArrayObject($colors); } public function getNext() { $this->colors->getIterator()->next(); return $this->colors->getIterator()->current(); } } $imageWidth = 300; $imageHeight = 350; $image = imagecreate($imageWidth, $imageHeight); $red = imagecolorallocate($image, 255, 10 , 10); $blue = imagecolorallocate($image, 10, 10 , 255); $gold = imagecolorallocate($image, 255, 240, 0); $colors = new ArrayObject(array($red, $blue, $gold)); $iterator = $colors->getIterator(); for($i = 0; $i<$imageWidth; $i += 10){ if(!$iterator->valid()) $iterator->rewind(); $iterator->next(); imagefilledrectangle($image, 0 , 0, $imageWidth - $i , $imageHeight-$i, $iterator->current()); } $iterator->next(); imagefilledrectangle($image, 0, 0, 10, 10, $iterator->current()); imagepng($image); header('Content-Type: image/png'); echo $image;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 40
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 40
Branch analysis from position: 63
Branch analysis from position: 40
Branch analysis from position: 46
filename:       /in/5hYuX
function name:  (null)
number of ops:  83
compiled vars:  !0 = $imageWidth, !1 = $imageHeight, !2 = $image, !3 = $red, !4 = $blue, !5 = $gold, !6 = $colors, !7 = $iterator, !8 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 300
   17     1        ASSIGN                                                   !1, 350
   21     2        INIT_FCALL_BY_NAME                                       'imagecreate'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $11     
          6        ASSIGN                                                   !2, $11
   22     7        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAL_EX                                              255
         10        SEND_VAL_EX                                              10
         11        SEND_VAL_EX                                              10
         12        DO_FCALL                                      0  $13     
         13        ASSIGN                                                   !3, $13
   23    14        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAL_EX                                              10
         17        SEND_VAL_EX                                              10
         18        SEND_VAL_EX                                              255
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !4, $15
   24    21        INIT_FCALL_BY_NAME                                       'imagecolorallocate'
         22        SEND_VAR_EX                                              !2
         23        SEND_VAL_EX                                              255
         24        SEND_VAL_EX                                              240
         25        SEND_VAL_EX                                              0
         26        DO_FCALL                                      0  $17     
         27        ASSIGN                                                   !5, $17
   26    28        NEW                                              $19     'ArrayObject'
         29        INIT_ARRAY                                       ~20     !3
         30        ADD_ARRAY_ELEMENT                                ~20     !4
         31        ADD_ARRAY_ELEMENT                                ~20     !5
         32        SEND_VAL_EX                                              ~20
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !6, $19
   27    35        INIT_METHOD_CALL                                         !6, 'getIterator'
         36        DO_FCALL                                      0  $23     
         37        ASSIGN                                                   !7, $23
   30    38        ASSIGN                                                   !8, 0
         39      > JMP                                                      ->61
   31    40    >   INIT_METHOD_CALL                                         !7, 'valid'
         41        DO_FCALL                                      0  $26     
         42        BOOL_NOT                                         ~27     $26
         43      > JMPZ                                                     ~27, ->46
         44    >   INIT_METHOD_CALL                                         !7, 'rewind'
         45        DO_FCALL                                      0          
   32    46    >   INIT_METHOD_CALL                                         !7, 'next'
         47        DO_FCALL                                      0          
   33    48        INIT_FCALL_BY_NAME                                       'imagefilledrectangle'
         49        SEND_VAR_EX                                              !2
         50        SEND_VAL_EX                                              0
         51        SEND_VAL_EX                                              0
         52        SUB                                              ~30     !0, !8
         53        SEND_VAL_EX                                              ~30
         54        SUB                                              ~31     !1, !8
         55        SEND_VAL_EX                                              ~31
         56        INIT_METHOD_CALL                                         !7, 'current'
         57        DO_FCALL                                      0  $32     
         58        SEND_VAR_NO_REF_EX                                       $32
         59        DO_FCALL                                      0          
   30    60        ASSIGN_OP                                     1          !8, 10
         61    >   IS_SMALLER                                               !8, !0
         62      > JMPNZ                                                    ~35, ->40
   35    63    >   INIT_METHOD_CALL                                         !7, 'next'
         64        DO_FCALL                                      0          
   36    65        INIT_FCALL_BY_NAME                                       'imagefilledrectangle'
         66        SEND_VAR_EX                                              !2
         67        SEND_VAL_EX                                              0
         68        SEND_VAL_EX                                              0
         69        SEND_VAL_EX                                              10
         70        SEND_VAL_EX                                              10
         71        INIT_METHOD_CALL                                         !7, 'current'
         72        DO_FCALL                                      0  $37     
         73        SEND_VAR_NO_REF_EX                                       $37
         74        DO_FCALL                                      0          
   37    75        INIT_FCALL_BY_NAME                                       'imagepng'
         76        SEND_VAR_EX                                              !2
         77        DO_FCALL                                      0          
   38    78        INIT_FCALL                                               'header'
         79        SEND_VAL                                                 'Content-Type%3A+image%2Fpng'
         80        DO_ICALL                                                 
   39    81        ECHO                                                     !2
         82      > RETURN                                                   1

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

End of function __construct

Function getnext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5hYuX
function name:  getNext
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~0      'colors'
          1        INIT_METHOD_CALL                                         ~0, 'getIterator'
          2        DO_FCALL                                      0  $1      
          3        INIT_METHOD_CALL                                         $1, 'next'
          4        DO_FCALL                                      0          
   11     5        FETCH_OBJ_R                                      ~3      'colors'
          6        INIT_METHOD_CALL                                         ~3, 'getIterator'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'current'
          9        DO_FCALL                                      0  $5      
         10      > RETURN                                                   $5
   12    11*     > RETURN                                                   null

End of function getnext

End of class ColorShifter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.52 ms | 1404 KiB | 15 Q