3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); function countAfterHeader(\PDOStatement $stmt): int { if ($stmt->fetch() === false) { return 0; } $count = 0; while ($stmt->fetch() !== false) { $count++; } return $count; } $pdo = new PDO('sqlite::memory:'); $pdo->exec('CREATE TABLE t (id INTEGER)'); $pdo->exec('INSERT INTO t VALUES (1), (2), (3)'); var_dump(countAfterHeader($pdo->query('SELECT id FROM t'))); var_dump(countAfterHeader($pdo->query('SELECT id FROM t WHERE id > 3')));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KT3Vf
function name:  (null)
number of ops:  29
compiled vars:  !0 = $pdo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   NEW                                                  $1      'PDO'
          1        SEND_VAL_EX                                                  'sqlite%3A%3Amemory%3A'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
   18     4        INIT_METHOD_CALL                                             !0, 'exec'
          5        SEND_VAL_EX                                                  'CREATE+TABLE+t+%28id+INTEGER%29'
          6        DO_FCALL                                          0          
   19     7        INIT_METHOD_CALL                                             !0, 'exec'
          8        SEND_VAL_EX                                                  'INSERT+INTO+t+VALUES+%281%29%2C+%282%29%2C+%283%29'
          9        DO_FCALL                                          0          
   20    10        INIT_FCALL                                                   'var_dump'
         11        INIT_FCALL                                                   'countafterheader'
         12        INIT_METHOD_CALL                                             !0, 'query'
         13        SEND_VAL_EX                                                  'SELECT+id+FROM+t'
         14        DO_FCALL                                          0  $6      
         15        SEND_VAR                                                     $6
         16        DO_FCALL                                          0  $7      
         17        SEND_VAR                                                     $7
         18        DO_ICALL                                                     
   21    19        INIT_FCALL                                                   'var_dump'
         20        INIT_FCALL                                                   'countafterheader'
         21        INIT_METHOD_CALL                                             !0, 'query'
         22        SEND_VAL_EX                                                  'SELECT+id+FROM+t+WHERE+id+%3E+3'
         23        DO_FCALL                                          0  $9      
         24        SEND_VAR                                                     $9
         25        DO_FCALL                                          0  $10     
         26        SEND_VAR                                                     $10
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

Function countafterheader:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Branch analysis from position: 8
filename:       /in/KT3Vf
function name:  countAfterHeader
number of ops:  17
compiled vars:  !0 = $stmt, !1 = $count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_METHOD_CALL                                             !0, 'fetch'
          2        DO_FCALL                                          0  $2      
          3        TYPE_CHECK                                        4          $2
          4      > JMPZ                                                         ~3, ->6
    6     5    > > RETURN                                                       0
    9     6    >   ASSIGN                                                       !1, 0
   10     7      > JMP                                                          ->9
   11     8    >   PRE_INC                                                      !1
   10     9    >   INIT_METHOD_CALL                                             !0, 'fetch'
         10        DO_FCALL                                          0  $6      
         11        TYPE_CHECK                                      1018          $6
         12      > JMPNZ                                                        ~7, ->8
   14    13    >   VERIFY_RETURN_TYPE                                           !1
         14      > RETURN                                                       !1
   15    15*       VERIFY_RETURN_TYPE                                           
         16*     > RETURN                                                       null

End of function countafterheader

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
123.12 ms | 493 KiB | 12 Q