3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $box; public function setBox(array $box) { if (count($box) !== 4) { throw new InvalidArgumentException('The "$box" parameter must be an array with 4 values.'); } // Breaks FPM and gives a 502 due to connection reset by peers list($lat1, $lon1, $lat2, $lon2) = $this->box = $box; // Works perfectly fine // $this->box = $box; // list($lat1, $lon1, $lat2, $lon2) = $this->box; // Calculate the central point of the box for distances $this->lat = (float) $lat1 + (($lat2 - $lat1) / 2); $this->lon = (float) $lon1 + (($lon2 - $lon1) / 2); return $this; } public function process() { if ($this->box) { list($lat1, $lon1, $lat2, $lon2) = $this->box; } echo "Success"; } } $foo = new Foo; $foo->setBox(explode(',', '40.688235,-74.013718,40.756427,-73.958770'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Lb5U
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   39     3        INIT_METHOD_CALL                                         !0, 'setBox'
          4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2C'
          6        SEND_VAL                                                 '40.688235%2C-74.013718%2C40.756427%2C-73.958770'
          7        DO_ICALL                                         $4      
          8        SEND_VAR_NO_REF_EX                                       $4
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class Foo:
Function setbox:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Lb5U
function name:  setBox
number of ops:  34
compiled vars:  !0 = $box, !1 = $lat1, !2 = $lon1, !3 = $lat2, !4 = $lon2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        COUNT                                            ~5      !0
          2        IS_NOT_IDENTICAL                                         ~5, 4
          3      > JMPZ                                                     ~6, ->8
    9     4    >   NEW                                              $7      'InvalidArgumentException'
          5        SEND_VAL_EX                                              'The+%22%24box%22+parameter+must+be+an+array+with+4+values.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $7
   13     8    >   ASSIGN_OBJ                                       ~9      'box'
          9        OP_DATA                                                  !0
         10        FETCH_LIST_R                                     $10     ~9, 0
         11        ASSIGN                                                   !1, $10
         12        FETCH_LIST_R                                     $12     ~9, 1
         13        ASSIGN                                                   !2, $12
         14        FETCH_LIST_R                                     $14     ~9, 2
         15        ASSIGN                                                   !3, $14
         16        FETCH_LIST_R                                     $16     ~9, 3
         17        ASSIGN                                                   !4, $16
         18        FREE                                                     ~9
   20    19        CAST                                          5  ~19     !1
         20        SUB                                              ~20     !3, !1
         21        DIV                                              ~21     ~20, 2
         22        ADD                                              ~22     ~19, ~21
         23        ASSIGN_OBJ                                               'lat'
         24        OP_DATA                                                  ~22
   21    25        CAST                                          5  ~24     !2
         26        SUB                                              ~25     !4, !2
         27        DIV                                              ~26     ~25, 2
         28        ADD                                              ~27     ~24, ~26
         29        ASSIGN_OBJ                                               'lon'
         30        OP_DATA                                                  ~27
   23    31        FETCH_THIS                                       ~28     
         32      > RETURN                                                   ~28
   24    33*     > RETURN                                                   null

End of function setbox

Function process:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/4Lb5U
function name:  process
number of ops:  14
compiled vars:  !0 = $lat1, !1 = $lon1, !2 = $lat2, !3 = $lon2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~4      'box'
          1      > JMPZ                                                     ~4, ->12
   30     2    >   FETCH_OBJ_R                                      ~5      'box'
          3        FETCH_LIST_R                                     $6      ~5, 0
          4        ASSIGN                                                   !0, $6
          5        FETCH_LIST_R                                     $8      ~5, 1
          6        ASSIGN                                                   !1, $8
          7        FETCH_LIST_R                                     $10     ~5, 2
          8        ASSIGN                                                   !2, $10
          9        FETCH_LIST_R                                     $12     ~5, 3
         10        ASSIGN                                                   !3, $12
         11        FREE                                                     ~5
   33    12    >   ECHO                                                     'Success'
   34    13      > RETURN                                                   null

End of function process

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.89 ms | 1400 KiB | 15 Q