3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Based { private array $arr = ["zero", "one", "two", "three", "four", "five"]; public function removeElementFromArr (int $index): void { array_splice($this->arr, $index, 1); if ($index === 0) { throw new Exception("Cannot remove the first element of an array, reason: https://www.youtube.com/watch?v=bvlSQz7cBr0"); } } public function getArr (): array { return $this->arr; } public function setArr (array $newArr) { $this->arr = $newArr; } } $obj = new Based(); var_dump($obj->getArr()); $obj->removeElementFromArr(3); var_dump($obj->getArr()); $obj->removeElementFromArr(0);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44QFC
function name:  (null)
number of ops:  20
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $1      'Based'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   24     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getArr'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   25     8        INIT_METHOD_CALL                                         !0, 'removeElementFromArr'
          9        SEND_VAL_EX                                              3
         10        DO_FCALL                                      0          
   26    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getArr'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   27    16        INIT_METHOD_CALL                                         !0, 'removeElementFromArr'
         17        SEND_VAL_EX                                              0
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Class Based:
Function removeelementfromarr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44QFC
function name:  removeElementFromArr
number of ops:  14
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'array_splice'
          2        FETCH_OBJ_W                                      $1      'arr'
          3        SEND_REF                                                 $1
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 1
          6        DO_ICALL                                                 
    9     7        IS_IDENTICAL                                             !0, 0
          8      > JMPZ                                                     ~3, ->13
   10     9    >   NEW                                              $4      'Exception'
         10        SEND_VAL_EX                                              'Cannot+remove+the+first+element+of+an+array%2C+reason%3A+https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbvlSQz7cBr0'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
   12    13    > > RETURN                                                   null

End of function removeelementfromarr

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

End of function getarr

Function setarr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/44QFC
function name:  setArr
number of ops:  4
compiled vars:  !0 = $newArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        ASSIGN_OBJ                                               'arr'
          2        OP_DATA                                                  !0
   20     3      > RETURN                                                   null

End of function setarr

End of class Based.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.44 ms | 1004 KiB | 15 Q