3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface BuilderObject { public function start(array $array): BuilderObject; public function addString(array $array): BuilderObject; public function end(string $str): BuilderObject; public function getData(): string; } class BuilderHtml implements BuilderObject { private string $data; public function start(array $array): BuilderObject { foreach ($array as $key => $value) { $this->data = $this->parseData($key, $value); } return $this; } private function parseData(string $key, array $value): string { $body = '<' . $key . ' '; foreach ($value as $k => $v) { $body .= $k . '="' . $v . '" '; } $body .= ">"; return $body; } public function addString(array $array): BuilderObject { foreach ($array as $key => $value) { $this->data = $this->parseData($key, $value); } return $this; } public function end(string $str): BuilderObject { $this->data .= $str; return $this; } public function getData(): string { return $this->data; } } $builderHtml = new BuilderHtml(); $resultHtml = $builderHtml->start(['form' => ['action' => 'actice.php', 'method' => 'GET']]) ->addString(['input' => ['type' => 'text', 'name' => 'name', 'value' => 'default']]) ->addString(['input' => ['type' => 'hidden', 'name' => 'id', 'value' => 1]]) ->addString(['input' => ['type' => 'date', 'name' => 'date_start', 'value' => date("Y-m-d")]]) ->end('</form>'); var_dump($resultHtml->getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  (null)
number of ops:  33
compiled vars:  !0 = $builderHtml, !1 = $resultHtml
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   DECLARE_CLASS                                                'builderhtml'
   56     1        NEW                                                  $2      'BuilderHtml'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   57     4        INIT_METHOD_CALL                                             !0, 'start'
          5        SEND_VAL_EX                                                  <array>
          6        DO_FCALL                                          0  $5      
   58     7        INIT_METHOD_CALL                                             $5, 'addString'
          8        SEND_VAL_EX                                                  <array>
          9        DO_FCALL                                          0  $6      
   59    10        INIT_METHOD_CALL                                             $6, 'addString'
         11        SEND_VAL_EX                                                  <array>
         12        DO_FCALL                                          0  $7      
   60    13        INIT_METHOD_CALL                                             $7, 'addString'
         14        INIT_ARRAY                                           ~8      'date', 'type'
         15        ADD_ARRAY_ELEMENT                                    ~8      'date_start', 'name'
         16        INIT_FCALL                                                   'date'
         17        SEND_VAL                                                     'Y-m-d'
         18        DO_ICALL                                             $9      
         19        ADD_ARRAY_ELEMENT                                    ~8      $9, 'value'
         20        INIT_ARRAY                                           ~10     ~8, 'input'
         21        SEND_VAL_EX                                                  ~10
         22        DO_FCALL                                          0  $11     
   61    23        INIT_METHOD_CALL                                             $11, 'end'
         24        SEND_VAL_EX                                                  '%3C%2Fform%3E'
         25        DO_FCALL                                          0  $12     
   57    26        ASSIGN                                                       !1, $12
   62    27        INIT_FCALL                                                   'var_dump'
         28        INIT_METHOD_CALL                                             !1, 'getData'
         29        DO_FCALL                                          0  $14     
         30        SEND_VAR                                                     $14
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

Class BuilderObject:
Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  start
number of ops:  3
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function start

Function addstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  addString
number of ops:  3
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function addstring

Function end:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  end
number of ops:  3
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1        VERIFY_RETURN_TYPE                                           
          2      > RETURN                                                       null

End of function end

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  getData
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   VERIFY_RETURN_TYPE                                           
          1      > RETURN                                                       null

End of function getdata

End of class BuilderObject.

Class BuilderHtml:
Function start:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/PFvLV
function name:  start
number of ops:  17
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1      > FE_RESET_R                                           $3      !0, ->11
          2    > > FE_FETCH_R                                           ~4      $3, !1, ->11
          3    >   ASSIGN                                                       !2, ~4
   21     4        INIT_METHOD_CALL                                             'parseData'
          5        SEND_VAR_EX                                                  !2
          6        SEND_VAR_EX                                                  !1
          7        DO_FCALL                                          0  $7      
          8        ASSIGN_OBJ                                                   'data'
          9        OP_DATA                                                      $7
   20    10      > JMP                                                          ->2
         11    >   FE_FREE                                                      $3
   23    12        FETCH_THIS                                           ~8      
         13        VERIFY_RETURN_TYPE                                           ~8
         14      > RETURN                                                       ~8
   24    15*       VERIFY_RETURN_TYPE                                           
         16*     > RETURN                                                       null

End of function start

Function parsedata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/PFvLV
function name:  parseData
number of ops:  19
compiled vars:  !0 = $key, !1 = $value, !2 = $body, !3 = $v, !4 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   28     2        CONCAT                                               ~5      '%3C', !0
          3        CONCAT                                               ~6      ~5, '+'
          4        ASSIGN                                                       !2, ~6
   29     5      > FE_RESET_R                                           $8      !1, ->13
          6    > > FE_FETCH_R                                           ~9      $8, !3, ->13
          7    >   ASSIGN                                                       !4, ~9
   30     8        CONCAT                                               ~11     !4, '%3D%22'
          9        CONCAT                                               ~12     ~11, !3
         10        CONCAT                                               ~13     ~12, '%22+'
         11        ASSIGN_OP                                         8          !2, ~13
   29    12      > JMP                                                          ->6
         13    >   FE_FREE                                                      $8
   32    14        ASSIGN_OP                                         8          !2, '%3E'
   33    15        VERIFY_RETURN_TYPE                                           !2
         16      > RETURN                                                       !2
   34    17*       VERIFY_RETURN_TYPE                                           
         18*     > RETURN                                                       null

End of function parsedata

Function addstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/PFvLV
function name:  addString
number of ops:  17
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   38     1      > FE_RESET_R                                           $3      !0, ->11
          2    > > FE_FETCH_R                                           ~4      $3, !1, ->11
          3    >   ASSIGN                                                       !2, ~4
   39     4        INIT_METHOD_CALL                                             'parseData'
          5        SEND_VAR                                                     !2
          6        SEND_VAR                                                     !1
          7        DO_FCALL                                          0  $7      
          8        ASSIGN_OBJ                                                   'data'
          9        OP_DATA                                                      $7
   38    10      > JMP                                                          ->2
         11    >   FE_FREE                                                      $3
   41    12        FETCH_THIS                                           ~8      
         13        VERIFY_RETURN_TYPE                                           ~8
         14      > RETURN                                                       ~8
   42    15*       VERIFY_RETURN_TYPE                                           
         16*     > RETURN                                                       null

End of function addstring

Function end:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PFvLV
function name:  end
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   RECV                                                 !0      
   46     1        ASSIGN_OBJ_OP                                     8          'data'
          2        OP_DATA                                                      !0
   47     3        FETCH_THIS                                           ~2      
          4        VERIFY_RETURN_TYPE                                           ~2
          5      > RETURN                                                       ~2
   48     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function end

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

End of function getdata

End of class BuilderHtml.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.39 ms | 1370 KiB | 15 Q