3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum ReturnValueType { case NumRows; case GetAffectedRows; case GetLastInsertedId; // Instead of just "null" use a more specific value case Nothing; } function runQuery($query, $values = NULL, ReturnValueType $returnValue = ReturnValueType::Nothing) { $ret = match($returnValue){ //query will run here and return the number of rows that are selected ReturnValueType::NumRows => 'Something', //query will run here and return the number of affected rows (for example to check if a create, update or delete is succesfull) ReturnValueType::GetAffectedRows => 'Something else', // query will run and return the ID of the inserted row ReturnValueType::GetLastInsertedId => 'Something else again', // query will execute without any returns ReturnValueType::Nothing => ReturnValueType::Nothing, }; if($ret !== ReturnValueType::Nothing){ return $ret; } } runQuery('', '');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3QetC
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'returnvaluetype'
   32     1        INIT_FCALL                                               'runquery'
          2        SEND_VAL                                                 ''
          3        SEND_VAL                                                 ''
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function runquery:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 197) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
filename:       /in/3QetC
function name:  runQuery
number of ops:  32
compiled vars:  !0 = $query, !1 = $values, !2 = $returnValue, !3 = $ret
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      <const ast>
   15     3        FETCH_CLASS_CONSTANT                             ~5      'ReturnValueType', 'NumRows'
          4        IS_IDENTICAL                                             !2, ~5
          5      > JMPNZ                                                    ~4, ->17
   18     6    >   FETCH_CLASS_CONSTANT                             ~6      'ReturnValueType', 'GetAffectedRows'
          7        IS_IDENTICAL                                             !2, ~6
          8      > JMPNZ                                                    ~4, ->19
   21     9    >   FETCH_CLASS_CONSTANT                             ~7      'ReturnValueType', 'GetLastInsertedId'
         10        IS_IDENTICAL                                             !2, ~7
         11      > JMPNZ                                                    ~4, ->21
   24    12    >   FETCH_CLASS_CONSTANT                             ~8      'ReturnValueType', 'Nothing'
         13        IS_IDENTICAL                                             !2, ~8
         14      > JMPNZ                                                    ~4, ->23
         15    > > JMP                                                      ->16
         16    > > MATCH_ERROR                                              !2
   15    17    >   QM_ASSIGN                                        ~9      'Something'
         18      > JMP                                                      ->26
   18    19    >   QM_ASSIGN                                        ~9      'Something+else'
         20      > JMP                                                      ->26
   21    21    >   QM_ASSIGN                                        ~9      'Something+else+again'
         22      > JMP                                                      ->26
   24    23    >   FETCH_CLASS_CONSTANT                             ~10     'ReturnValueType', 'Nothing'
         24        QM_ASSIGN                                        ~9      ~10
         25      > JMP                                                      ->26
   13    26    >   ASSIGN                                                   !3, ~9
   27    27        FETCH_CLASS_CONSTANT                             ~12     'ReturnValueType', 'Nothing'
         28        IS_NOT_IDENTICAL                                         !3, ~12
         29      > JMPZ                                                     ~13, ->31
   28    30    > > RETURN                                                   !3
   30    31    > > RETURN                                                   null

End of function runquery

Class ReturnValueType: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.05 ms | 1016 KiB | 14 Q