3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace SQLQuery; class SQLQuery { private static $methods = array('select', 'update', 'drop', 'delete', 'create', 'alter', 'set'); private static $char_list = array( 'default' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ), 'mysqli' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ), 'sqlite3' => array( 'escape' => '\\', 'quotes' => '"', 'names' => '`', 'name_separator' => '.' ) ); private $chars = array(); private $type = 'unknown'; private $link = null; function __call($method, $arguments){ if(!in_array($method, self::$methods)) { throw new BadMethodCallException('Method ' . $method . ' does not exist'); } $class = __CLASS__ . ucfirst($method); return new $class($this, $this->chars, $arguments); } function __construct($link = false){ if(is_resource($link)) { $type = get_resource_type($link); if($type !== 'mysql link' || $type !== 'mysql link persistent') { throw new InvalidArgumentException('MySQL resource expected, ' . $type . ' given'); } $this->link = $link; $this->type = 'mysql'; $this->chars = self::$char_list['default']; } else if(is_object($link)) { if(class_exists('PDO') && ($link instanceof \PDO)) { $type = $link->getAttribute(\PDO::ATTR_DRIVER_NAME); } else if(class_exists('mysqli') && ($link instanceof \mysqli)) { $type = 'mysqli'; } else if(class_exists('SQLite3') && ($link instanceof \SQLite3)) { $type = 'sqlite3'; } else { throw new InvalidArgumentException('Unsupported connection type ' . get_class($link)); } $this->link = $link; $this->type = $type; $this->chars = self::$char_list[$type]; } else throw new InvalidArgumentException('Resource or Object excepted, ' . gettype($link) . ' given'); } } if(!@class_alias('SQLQuery\\SQLQuery', '\\SQLQuery')) { // very ugly hack eval('class SQLQuery extends \SQLQuery\SQLQuery{};'); } final class SQLQuerySelect { function __construct(SQLQuery $sql, array $chars, $arguments){ var_dump($chars, $arguments); } } // --------------------------------- $x = new \SQLQuery(new \SQLite3()); $x->select('a');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/6rgvb
function name:  (null)
number of ops:  19
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   BEGIN_SILENCE                                    ~1      
          1        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cclass_alias'
          2        SEND_VAL_EX                                              'SQLQuery%5CSQLQuery'
          3        SEND_VAL_EX                                              '%5CSQLQuery'
          4        DO_FCALL                                      0  $2      
          5        END_SILENCE                                              ~1
          6        BOOL_NOT                                         ~3      $2
          7      > JMPZ                                                     ~3, ->9
   87     8    >   INCLUDE_OR_EVAL                                          'class+SQLQuery+extends+%5CSQLQuery%5CSQLQuery%7B%7D%3B', EVAL
   97     9    >   NEW                                              $5      'SQLQuery'
         10        NEW                                              $6      'SQLite3'
         11        DO_FCALL                                      0          
         12        SEND_VAR_NO_REF_EX                                       $6
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $5
   99    15        INIT_METHOD_CALL                                         !0, 'select'
         16        SEND_VAL_EX                                              'a'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class SQLQuery\SQLQuery:
Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rgvb
function name:  __call
number of ops:  32
compiled vars:  !0 = $method, !1 = $arguments, !2 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   34     2        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cin_array'
          3        SEND_VAR_EX                                              !0
          4        CHECK_FUNC_ARG                                           
          5        FETCH_STATIC_PROP_FUNC_ARG   unknown             $3      'methods'
          6        SEND_FUNC_ARG                                            $3
          7        DO_FCALL                                      0  $4      
          8        BOOL_NOT                                         ~5      $4
          9      > JMPZ                                                     ~5, ->16
   36    10    >   NEW                                              $6      'SQLQuery%5CBadMethodCallException'
         11        CONCAT                                           ~7      'Method+', !0
         12        CONCAT                                           ~8      ~7, '+does+not+exist'
         13        SEND_VAL_EX                                              ~8
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $6
   39    16    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cucfirst'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $10     
         19        CONCAT                                           ~11     'SQLQuery%5CSQLQuery', $10
         20        ASSIGN                                                   !2, ~11
   41    21        FETCH_CLASS                                   0  $13     !2
         22        NEW                                              $14     $13
         23        FETCH_THIS                                       $15     
         24        SEND_VAR_EX                                              $15
         25        CHECK_FUNC_ARG                                           
         26        FETCH_OBJ_FUNC_ARG                               $16     'chars'
         27        SEND_FUNC_ARG                                            $16
         28        SEND_VAR_EX                                              !1
         29        DO_FCALL                                      0          
         30      > RETURN                                                   $14
   42    31*     > RETURN                                                   null

End of function __call

Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 80
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 45
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
Branch analysis from position: 45
2 jumps found. (Code = 46) Position 1 = 49, Position 2 = 51
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 54
2 jumps found. (Code = 46) Position 1 = 58, Position 2 = 60
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 63
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 63
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 51
Branch analysis from position: 39
Branch analysis from position: 80
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/6rgvb
function name:  __construct
number of ops:  90
compiled vars:  !0 = $link, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV_INIT                                        !0      <false>
   45     1        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cis_resource'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4      > JMPZ                                                     $2, ->29
   47     5    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cget_resource_type'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $3      
          8        ASSIGN                                                   !1, $3
   48     9        IS_NOT_IDENTICAL                                 ~5      !1, 'mysql+link'
         10      > JMPNZ_EX                                         ~5      ~5, ->13
         11    >   IS_NOT_IDENTICAL                                 ~6      !1, 'mysql+link+persistent'
         12        BOOL                                             ~5      ~6
         13    > > JMPZ                                                     ~5, ->20
   50    14    >   NEW                                              $7      'SQLQuery%5CInvalidArgumentException'
         15        CONCAT                                           ~8      'MySQL+resource+expected%2C+', !1
         16        CONCAT                                           ~9      ~8, '+given'
         17        SEND_VAL_EX                                              ~9
         18        DO_FCALL                                      0          
         19      > THROW                                         0          $7
   53    20    >   ASSIGN_OBJ                                               'link'
         21        OP_DATA                                                  !0
   54    22        ASSIGN_OBJ                                               'type'
         23        OP_DATA                                                  'mysql'
   55    24        FETCH_STATIC_PROP_R          unknown             ~14     'char_list'
         25        FETCH_DIM_R                                      ~15     ~14, 'default'
         26        ASSIGN_OBJ                                               'chars'
         27        OP_DATA                                                  ~15
         28      > JMP                                                      ->89
   57    29    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cis_object'
         30        SEND_VAR_EX                                              !0
         31        DO_FCALL                                      0  $16     
         32      > JMPZ                                                     $16, ->80
   59    33    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cclass_exists'
         34        SEND_VAL_EX                                              'PDO'
         35        DO_FCALL                                      0  $17     
         36      > JMPZ_EX                                          ~18     $17, ->39
         37    >   INSTANCEOF                                       ~19     !0, 'PDO'
         38        BOOL                                             ~18     ~19
         39    > > JMPZ                                                     ~18, ->45
   61    40    >   INIT_METHOD_CALL                                         !0, 'getAttribute'
         41        SEND_VAL_EX                                              16
         42        DO_FCALL                                      0  $20     
         43        ASSIGN                                                   !1, $20
         44      > JMP                                                      ->71
   63    45    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cclass_exists'
         46        SEND_VAL_EX                                              'mysqli'
         47        DO_FCALL                                      0  $22     
         48      > JMPZ_EX                                          ~23     $22, ->51
         49    >   INSTANCEOF                                       ~24     !0, 'mysqli'
         50        BOOL                                             ~23     ~24
         51    > > JMPZ                                                     ~23, ->54
   65    52    >   ASSIGN                                                   !1, 'mysqli'
         53      > JMP                                                      ->71
   67    54    >   INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cclass_exists'
         55        SEND_VAL_EX                                              'SQLite3'
         56        DO_FCALL                                      0  $26     
         57      > JMPZ_EX                                          ~27     $26, ->60
         58    >   INSTANCEOF                                       ~28     !0, 'SQLite3'
         59        BOOL                                             ~27     ~28
         60    > > JMPZ                                                     ~27, ->63
   69    61    >   ASSIGN                                                   !1, 'sqlite3'
         62      > JMP                                                      ->71
   73    63    >   NEW                                              $30     'SQLQuery%5CInvalidArgumentException'
         64        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cget_class'
         65        SEND_VAR_EX                                              !0
         66        DO_FCALL                                      0  $31     
         67        CONCAT                                           ~32     'Unsupported+connection+type+', $31
         68        SEND_VAL_EX                                              ~32
         69        DO_FCALL                                      0          
         70      > THROW                                         0          $30
   76    71    >   ASSIGN_OBJ                                               'link'
         72        OP_DATA                                                  !0
   77    73        ASSIGN_OBJ                                               'type'
         74        OP_DATA                                                  !1
   78    75        FETCH_STATIC_PROP_R          unknown             ~37     'char_list'
         76        FETCH_DIM_R                                      ~38     ~37, !1
         77        ASSIGN_OBJ                                               'chars'
         78        OP_DATA                                                  ~38
         79      > JMP                                                      ->89
   80    80    >   NEW                                              $39     'SQLQuery%5CInvalidArgumentException'
         81        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cgettype'
         82        SEND_VAR_EX                                              !0
         83        DO_FCALL                                      0  $40     
         84        CONCAT                                           ~41     'Resource+or+Object+excepted%2C+', $40
         85        CONCAT                                           ~42     ~41, '+given'
         86        SEND_VAL_EX                                              ~42
         87        DO_FCALL                                      0          
         88      > THROW                                         0          $39
   81    89    > > RETURN                                                   null

End of function __construct

End of class SQLQuery\SQLQuery.

Class SQLQuery\SQLQuerySelect:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rgvb
function name:  __construct
number of ops:  8
compiled vars:  !0 = $sql, !1 = $chars, !2 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   92     3        INIT_NS_FCALL_BY_NAME                                    'SQLQuery%5Cvar_dump'
          4        SEND_VAR_EX                                              !1
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0          
   93     7      > RETURN                                                   null

End of function __construct

End of class SQLQuery\SQLQuerySelect.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.83 ms | 1400 KiB | 33 Q