3v4l.org

run code in 500+ PHP versions simultaneously
<?php function method_a(&$links, ?bool $indexable) { $links[] = [ 'indexable === ' => as_string($indexable), // very long list... and: ...(null !== $indexable ? ['indexable' => $indexable] : []), ]; } function method_b(&$links, ?bool $indexable) { $link = [ 'indexable === ' => as_string($indexable), // very long list... and: ]; if (null !== $indexable) { $link['indexable'] = $indexable; } $links[] = $link; } function as_string($v) { if (null === $v) { return 'null'; } if (false === $v) { return 'false'; } if (true === $v) { return 'true'; } } $links = []; method_a($links, null); method_a($links, true); method_a($links, false); var_dump($links); $links = []; method_b($links, null); method_b($links, true); method_b($links, false); var_dump($links);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lRha
function name:  (null)
number of ops:  33
compiled vars:  !0 = $links
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                       !0, <array>
   38     1        INIT_FCALL                                                   'method_a'
          2        SEND_REF                                                     !0
          3        SEND_VAL                                                     null
          4        DO_FCALL                                          0          
   39     5        INIT_FCALL                                                   'method_a'
          6        SEND_REF                                                     !0
          7        SEND_VAL                                                     <true>
          8        DO_FCALL                                          0          
   40     9        INIT_FCALL                                                   'method_a'
         10        SEND_REF                                                     !0
         11        SEND_VAL                                                     <false>
         12        DO_FCALL                                          0          
   41    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !0
         15        DO_ICALL                                                     
   43    16        ASSIGN                                                       !0, <array>
   44    17        INIT_FCALL                                                   'method_b'
         18        SEND_REF                                                     !0
         19        SEND_VAL                                                     null
         20        DO_FCALL                                          0          
   45    21        INIT_FCALL                                                   'method_b'
         22        SEND_REF                                                     !0
         23        SEND_VAL                                                     <true>
         24        DO_FCALL                                          0          
   46    25        INIT_FCALL                                                   'method_b'
         26        SEND_REF                                                     !0
         27        SEND_VAL                                                     <false>
         28        DO_FCALL                                          0          
   47    29        INIT_FCALL                                                   'var_dump'
         30        SEND_VAR                                                     !0
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

Function method_a:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lRha
function name:  method_a
number of ops:  16
compiled vars:  !0 = $links, !1 = $indexable
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    6     2        INIT_FCALL_BY_NAME                                           'as_string'
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0  $3      
          5        INIT_ARRAY                                           ~4      $3, 'indexable+%3D%3D%3D+'
    8     6        TYPE_CHECK                                      1020          !1
          7      > JMPZ                                                         ~5, ->11
          8    >   INIT_ARRAY                                           ~6      !1, 'indexable'
          9        QM_ASSIGN                                            ~7      ~6
         10      > JMP                                                          ->12
    6    11    >   QM_ASSIGN                                            ~7      <array>
         12    >   ADD_ARRAY_UNPACK                                     ~4      ~7
    5    13        ASSIGN_DIM                                                   !0
    6    14        OP_DATA                                                      ~4
   10    15      > RETURN                                                       null

End of function method_a

Function method_b:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/6lRha
function name:  method_b
number of ops:  14
compiled vars:  !0 = $links, !1 = $indexable, !2 = $link
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   15     2        INIT_FCALL_BY_NAME                                           'as_string'
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0  $3      
          5        INIT_ARRAY                                           ~4      $3, 'indexable+%3D%3D%3D+'
   14     6        ASSIGN                                                       !2, ~4
   18     7        TYPE_CHECK                                      1020          !1
          8      > JMPZ                                                         ~6, ->11
   19     9    >   ASSIGN_DIM                                                   !2, 'indexable'
         10        OP_DATA                                                      !1
   21    11    >   ASSIGN_DIM                                                   !0
         12        OP_DATA                                                      !2
   22    13      > RETURN                                                       null

End of function method_b

Function as_string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lRha
function name:  as_string
number of ops:  11
compiled vars:  !0 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV                                                 !0      
   26     1        TYPE_CHECK                                        2          !0
          2      > JMPZ                                                         ~1, ->4
   27     3    > > RETURN                                                       'null'
   29     4    >   TYPE_CHECK                                        4          !0
          5      > JMPZ                                                         ~2, ->7
   30     6    > > RETURN                                                       'false'
   32     7    >   TYPE_CHECK                                        8          !0
          8      > JMPZ                                                         ~3, ->10
   33     9    > > RETURN                                                       'true'
   35    10    > > RETURN                                                       null

End of function as_string

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
137.82 ms | 1798 KiB | 20 Q