3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( 'TESTDOX', true ); function wp_is_development_mode( $mode = null ) { $current_mode = wp_get_development_mode(); if ( empty( $current_mode ) ) { return '' === $mode; } // Return true if the current mode encompasses all modes. if ( 'all' === $current_mode ) { return true; } // Return true if the current mode is the given mode. return $mode === $current_mode; } // Polyfill. global $test_development_mode; function wp_get_development_mode() { global $test_development_mode; return $test_development_mode; } // Test cases. $dataset = array( 'both are empty strings' => array( 'mode' => '', 'dev' => '', 'expected' => true, ), 'both are non-empty, matching strings' => array( 'mode' => 'plugin', 'dev' => 'plugin', 'expected' => true, ), 'both are non-empty, unmatching strings' => array( 'mode' => 'core', 'dev' => 'theme', 'expected' => false, ), '$mode is null and development mode is an empty string' => array( 'mode' => null, 'dev' => '', 'expected' => false, ), '$mode is an empty string, development mode is a non-empty string' => array( 'mode' => '', 'dev' => 'core', 'expected' => false, ), '$mode is a non-empty string, development mode is an empty string' => array( 'mode' => 'core', 'dev' => '', 'expected' => false, ), ); foreach ( $dataset as $name => $data ) { $test_development_mode = $data['dev']; $actual = null === $data['mode'] ? wp_is_development_mode() : wp_is_development_mode( $data['mode'] ); $result = $actual === $data['expected'] ? '.' : 'F'; if ( defined( 'TESTDOX' ) && TESTDOX ) { echo '.' === $result ? 'PASS' : 'FAIL', ': ', $name, ' (', var_export( $data['expected'], true ), ')', PHP_EOL; } else { echo $result; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 56
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 56
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 54
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 35
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
Branch analysis from position: 35
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
Branch analysis from position: 29
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/dvnNh
function name:  (null)
number of ops:  58
compiled vars:  !0 = $test_development_mode, !1 = $dataset, !2 = $data, !3 = $name, !4 = $actual, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'TESTDOX'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   21     4        BIND_GLOBAL                                              !0, 'test_development_mode'
   28     5        ASSIGN                                                   !1, <array>
   61     6      > FE_RESET_R                                       $8      !1, ->56
          7    > > FE_FETCH_R                                       ~9      $8, !2, ->56
          8    >   ASSIGN                                                   !3, ~9
   62     9        FETCH_DIM_R                                      ~11     !2, 'dev'
         10        ASSIGN                                                   !0, ~11
   64    11        FETCH_DIM_R                                      ~13     !2, 'mode'
         12        TYPE_CHECK                                    2          ~13
         13      > JMPZ                                                     ~14, ->18
         14    >   INIT_FCALL                                               'wp_is_development_mode'
         15        DO_FCALL                                      0  $15     
         16        QM_ASSIGN                                        ~16     $15
         17      > JMP                                                      ->23
         18    >   INIT_FCALL                                               'wp_is_development_mode'
         19        FETCH_DIM_R                                      ~17     !2, 'mode'
         20        SEND_VAL                                                 ~17
         21        DO_FCALL                                      0  $18     
         22        QM_ASSIGN                                        ~16     $18
         23    >   ASSIGN                                                   !4, ~16
   65    24        FETCH_DIM_R                                      ~20     !2, 'expected'
         25        IS_IDENTICAL                                             !4, ~20
         26      > JMPZ                                                     ~21, ->29
         27    >   QM_ASSIGN                                        ~22     '.'
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~22     'F'
         30    >   ASSIGN                                                   !5, ~22
   67    31        DEFINED                                          ~24     'TESTDOX'
         32      > JMPZ_EX                                          ~24     ~24, ->35
         33    >   FETCH_CONSTANT                                   ~25     'TESTDOX'
         34        BOOL                                             ~24     ~25
         35    > > JMPZ                                                     ~24, ->54
   68    36    >   IS_IDENTICAL                                             !5, '.'
         37      > JMPZ                                                     ~26, ->40
         38    >   QM_ASSIGN                                        ~27     'PASS'
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~27     'FAIL'
         41    >   ECHO                                                     ~27
         42        ECHO                                                     '%3A+'
         43        ECHO                                                     !3
         44        ECHO                                                     '+%28'
         45        INIT_FCALL                                               'var_export'
         46        FETCH_DIM_R                                      ~28     !2, 'expected'
         47        SEND_VAL                                                 ~28
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $29     
         50        ECHO                                                     $29
         51        ECHO                                                     '%29'
         52        ECHO                                                     '%0A'
   67    53      > JMP                                                      ->55
   70    54    >   ECHO                                                     !5
   61    55    > > JMP                                                      ->7
         56    >   FE_FREE                                                  $8
   72    57      > RETURN                                                   1

Function wp_is_development_mode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dvnNh
function name:  wp_is_development_mode
number of ops:  14
compiled vars:  !0 = $mode, !1 = $current_mode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_INIT                                        !0      null
    6     1        INIT_FCALL_BY_NAME                                       'wp_get_development_mode'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
    7     4        ISSET_ISEMPTY_CV                                         !1
          5      > JMPZ                                                     ~4, ->8
    8     6    >   IS_IDENTICAL                                     ~5      !0, ''
          7      > RETURN                                                   ~5
   12     8    >   IS_IDENTICAL                                             !1, 'all'
          9      > JMPZ                                                     ~6, ->11
   13    10    > > RETURN                                                   <true>
   17    11    >   IS_IDENTICAL                                     ~7      !0, !1
         12      > RETURN                                                   ~7
   18    13*     > RETURN                                                   null

End of function wp_is_development_mode

Function wp_get_development_mode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dvnNh
function name:  wp_get_development_mode
number of ops:  3
compiled vars:  !0 = $test_development_mode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   BIND_GLOBAL                                              !0, 'test_development_mode'
   24     1      > RETURN                                                   !0
   25     2*     > RETURN                                                   null

End of function wp_get_development_mode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
133.38 ms | 1471 KiB | 17 Q