3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ [], // expect null [true, true], // expect true [false, false], // expect false [true, false, true], // expect null [false, true, false], // expect null ]; foreach ($tests as $bools) { echo "\n"; var_export( !$bools || ( ($hasTrues = array_any($bools, fn($b) => $b === true)) && array_any($bools, fn($b) => $b === false) ) ? null : $hasTrues ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 28
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
Branch analysis from position: 21
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/uNdNI
function name:  (null)
number of ops:  30
compiled vars:  !0 = $tests, !1 = $bools, !2 = $hasTrues
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1      > FE_RESET_R                                       $4      !0, ->28
          2    > > FE_FETCH_R                                               $4, !1, ->28
   12     3    >   ECHO                                                     '%0A'
   13     4        INIT_FCALL                                               'var_export'
   14     5        BOOL_NOT                                         ~5      !1
          6      > JMPNZ_EX                                         ~5      ~5, ->21
   16     7    >   INIT_FCALL_BY_NAME                                       'array_any'
          8        SEND_VAR_EX                                              !1
          9        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
         10        SEND_VAL_EX                                              ~6
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                           ~8      !2, $7
         13      > JMPZ_EX                                          ~8      ~8, ->20
   17    14    >   INIT_FCALL_BY_NAME                                       'array_any'
         15        SEND_VAR_EX                                              !1
         16        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
         17        SEND_VAL_EX                                              ~9
         18        DO_FCALL                                      0  $10     
         19        BOOL                                             ~8      $10
         20    >   BOOL                                             ~5      ~8
         21    > > JMPZ                                                     ~5, ->24
   19    22    >   QM_ASSIGN                                        ~11     null
         23      > JMP                                                      ->25
   20    24    >   QM_ASSIGN                                        ~11     !2
         25    >   SEND_VAL                                                 ~11
   13    26        DO_ICALL                                                 
   11    27      > JMP                                                      ->2
         28    >   FE_FREE                                                  $4
   22    29      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uNdNI
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        TYPE_CHECK                                    8  ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uNdNI
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        TYPE_CHECK                                    4  ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.16 ms | 1015 KiB | 14 Q