3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare (strict_types=1); final class Immutable { private $views; public function __construct(int $views) { $this->views = $views; } public function increaseViews(int $views): self { $this->views += $views; return new self($this->views); } public function getViews(): int { return $this->views; } } $imm = new Immutable(1); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); print $imm->getViews();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HshIo
function name:  (null)
number of ops:  35
compiled vars:  !0 = $imm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Immutable'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   27     4        INIT_METHOD_CALL                                         !0, 'increaseViews'
          5        SEND_VAL_EX                                              3
          6        DO_FCALL                                      0          
   28     7        INIT_METHOD_CALL                                         !0, 'increaseViews'
          8        SEND_VAL_EX                                              3
          9        DO_FCALL                                      0          
   29    10        INIT_METHOD_CALL                                         !0, 'increaseViews'
         11        SEND_VAL_EX                                              3
         12        DO_FCALL                                      0          
   30    13        INIT_METHOD_CALL                                         !0, 'increaseViews'
         14        SEND_VAL_EX                                              3
         15        DO_FCALL                                      0          
   31    16        INIT_METHOD_CALL                                         !0, 'increaseViews'
         17        SEND_VAL_EX                                              3
         18        DO_FCALL                                      0          
   32    19        INIT_METHOD_CALL                                         !0, 'increaseViews'
         20        SEND_VAL_EX                                              3
         21        DO_FCALL                                      0          
   33    22        INIT_METHOD_CALL                                         !0, 'increaseViews'
         23        SEND_VAL_EX                                              3
         24        DO_FCALL                                      0          
   34    25        INIT_METHOD_CALL                                         !0, 'increaseViews'
         26        SEND_VAL_EX                                              3
         27        DO_FCALL                                      0          
   35    28        INIT_METHOD_CALL                                         !0, 'increaseViews'
         29        SEND_VAL_EX                                              3
         30        DO_FCALL                                      0          
   36    31        INIT_METHOD_CALL                                         !0, 'getViews'
         32        DO_FCALL                                      0  $13     
         33        ECHO                                                     $13
         34      > RETURN                                                   1

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

End of function __construct

Function increaseviews:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HshIo
function name:  increaseViews
number of ops:  12
compiled vars:  !0 = $views
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ_OP                                 1          'views'
          2        OP_DATA                                                  !0
   17     3        NEW                          self                $2      
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $3      'views'
          6        SEND_FUNC_ARG                                            $3
          7        DO_FCALL                                      0          
          8        VERIFY_RETURN_TYPE                                       $2
          9      > RETURN                                                   $2
   18    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function increaseviews

Function getviews:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HshIo
function name:  getViews
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~0      'views'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   23     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getviews

End of class Immutable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.51 ms | 1399 KiB | 13 Q