3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace X; $val = '1 '; $type = 'double'; function convertType(& $val, $type) { if ($val === NULL || is_object($val)) { // ignore } elseif ($type === 'array') { if (!is_array($val)) { return FALSE; } } elseif (!is_scalar($val)) { return FALSE; } elseif ($type !== 'NULL') { $old = $val = ($val === FALSE ? '0' : (string) $val); settype($val, $type); if ($old !== ($val === FALSE ? '0' : (string) $val)) { return FALSE; // data-loss occurs } } return TRUE; } var_dump(convertType($val, $type)); var_dump($val);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XhVol
function name:  (null)
number of ops:  13
compiled vars:  !0 = $val, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '1+'
    5     1        ASSIGN                                                   !1, 'double'
   28     2        INIT_NS_FCALL_BY_NAME                                    'X%5Cvar_dump'
          3        INIT_NS_FCALL_BY_NAME                                    'X%5CconvertType'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR_NO_REF_EX                                       $4
          8        DO_FCALL                                      0          
   29     9        INIT_NS_FCALL_BY_NAME                                    'X%5Cvar_dump'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Function x%5Cconverttype:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 49
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
Branch analysis from position: 49
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
Branch analysis from position: 44
Branch analysis from position: 49
Branch analysis from position: 8
filename:       /in/XhVol
function name:  X\convertType
number of ops:  51
compiled vars:  !0 = $val, !1 = $type, !2 = $old
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        TYPE_CHECK                                    2  ~3      !0
          3      > JMPNZ_EX                                         ~3      ~3, ->8
          4    >   INIT_NS_FCALL_BY_NAME                                    'X%5Cis_object'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7        BOOL                                             ~3      $4
          8    > > JMPZ                                                     ~3, ->10
          9    > > JMP                                                      ->49
   11    10    >   IS_IDENTICAL                                             !1, 'array'
         11      > JMPZ                                                     ~5, ->19
   12    12    >   INIT_NS_FCALL_BY_NAME                                    'X%5Cis_array'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $6      
         15        BOOL_NOT                                         ~7      $6
         16      > JMPZ                                                     ~7, ->18
   13    17    > > RETURN                                                   <false>
         18    > > JMP                                                      ->49
   15    19    >   INIT_NS_FCALL_BY_NAME                                    'X%5Cis_scalar'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $8      
         22        BOOL_NOT                                         ~9      $8
         23      > JMPZ                                                     ~9, ->26
   16    24    > > RETURN                                                   <false>
         25*       JMP                                                      ->49
   18    26    >   IS_NOT_IDENTICAL                                         !1, 'NULL'
         27      > JMPZ                                                     ~10, ->49
   19    28    >   TYPE_CHECK                                    4          !0
         29      > JMPZ                                                     ~11, ->32
         30    >   QM_ASSIGN                                        ~12     '0'
         31      > JMP                                                      ->34
         32    >   CAST                                          6  ~13     !0
         33        QM_ASSIGN                                        ~12     ~13
         34    >   ASSIGN                                           ~14     !0, ~12
         35        ASSIGN                                                   !2, ~14
   20    36        INIT_NS_FCALL_BY_NAME                                    'X%5Csettype'
         37        SEND_VAR_EX                                              !0
         38        SEND_VAR_EX                                              !1
         39        DO_FCALL                                      0          
   21    40        TYPE_CHECK                                    4          !0
         41      > JMPZ                                                     ~17, ->44
         42    >   QM_ASSIGN                                        ~18     '0'
         43      > JMP                                                      ->46
         44    >   CAST                                          6  ~19     !0
         45        QM_ASSIGN                                        ~18     ~19
         46    >   IS_NOT_IDENTICAL                                         !2, ~18
         47      > JMPZ                                                     ~20, ->49
   22    48    > > RETURN                                                   <false>
   25    49    > > RETURN                                                   <true>
   26    50*     > RETURN                                                   null

End of function x%5Cconverttype

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.36 ms | 1407 KiB | 24 Q