3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ [], // expect null [true, true], // expect true [false, false], // expect false [true, true, false, true], // expect null [false, false, true, false], // expect null ]; foreach ($tests as $bools) { echo "\n"; var_export( (function($bools) { foreach ($bools as $b) { $first ??= $b; if ($first !== $b) { return null; } } return $first ?? null; })($bools) ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/1Rvs5
function name:  (null)
number of ops:  14
compiled vars:  !0 = $tests, !1 = $bools
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   12     3    >   ECHO                                                     '%0A'
   13     4        INIT_FCALL                                               'var_export'
   14     5        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   22     6        INIT_DYNAMIC_CALL                                        ~4
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
   13    10        DO_ICALL                                                 
   11    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   24    13      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
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
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/1Rvs5
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $bools, !1 = $b, !2 = $first
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   16     3    >   COALESCE                                         ~4      !2
          4        ASSIGN                                           ~5      !2, !1
          5        QM_ASSIGN                                        ~4      ~5
          6        FREE                                                     ~4
   17     7        IS_NOT_IDENTICAL                                         !2, !1
          8      > JMPZ                                                     ~6, ->11
   18     9    >   FE_FREE                                                  $3
         10      > RETURN                                                   null
   15    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   21    13        COALESCE                                         ~7      !2
         14        QM_ASSIGN                                        ~7      null
         15      > RETURN                                                   ~7
   22    16*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.59 ms | 1015 KiB | 14 Q