3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Database { protected static $instance; protected $pdo; protected function __construct() { $this->pdo = new PDO('sqlite::memory:'); } public static function instance() { if (null === self::$instance) { self::$instance = new self; } return self::$instance; } /** * @return PDOStatement|false */ public function run($sql, $args = []) { if (!$args) { return $this->query($sql); } if ($stmt = $this->prepare($sql)) { if ($stmt->execute($args)) { return $stmt; } } return false; } public function __call($method, $args) { if (is_callable([$this->pdo, $method])) { //php 5.6+ variadic optimization (aka splat operator) return $this->pdo->$method(...$args); //PHP <= 5.5 //return call_user_func_array(array($this->pdo, $method), $args); } throw new \BadMethodCallException(sprintf('Unknown method PDO::%s called!', $method)); } } //RunTime code $db = Database::instance(); var_dump($db->run('SELECT ?', ['foo', 'bar'])); //false
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OnDdn
function name:  (null)
number of ops:  11
compiled vars:  !0 = $db
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   INIT_STATIC_METHOD_CALL                                  'Database', 'instance'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   54     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'run'
          5        SEND_VAL_EX                                              'SELECT+%3F'
          6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class Database:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OnDdn
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $1      'PDO'
          1        SEND_VAL_EX                                              'sqlite%3A%3Amemory%3A'
          2        DO_FCALL                                      0          
          3        ASSIGN_OBJ                                               'pdo'
          4        OP_DATA                                                  $1
   11     5      > RETURN                                                   null

End of function __construct

Function instance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/OnDdn
function name:  instance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   16     3    >   NEW                          self                $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   19     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   20     9*     > RETURN                                                   null

End of function instance

Function run:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
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 = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/OnDdn
function name:  run
number of ops:  20
compiled vars:  !0 = $sql, !1 = $args, !2 = $stmt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   27     2        BOOL_NOT                                         ~3      !1
          3      > JMPZ                                                     ~3, ->8
   28     4    >   INIT_METHOD_CALL                                         'query'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
   30     8    >   INIT_METHOD_CALL                                         'prepare'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $5      
         11        ASSIGN                                           ~6      !2, $5
         12      > JMPZ                                                     ~6, ->18
   31    13    >   INIT_METHOD_CALL                                         !2, 'execute'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $7      
         16      > JMPZ                                                     $7, ->18
   32    17    > > RETURN                                                   !2
   36    18    > > RETURN                                                   <false>
   37    19*     > RETURN                                                   null

End of function run

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/OnDdn
function name:  __call
number of ops:  24
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   41     2        INIT_FCALL                                               'is_callable'
          3        FETCH_OBJ_R                                      ~2      'pdo'
          4        INIT_ARRAY                                       ~3      ~2
          5        ADD_ARRAY_ELEMENT                                ~3      !0
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8      > JMPZ                                                     $4, ->15
   43     9    >   FETCH_OBJ_R                                      ~5      'pdo'
         10        INIT_METHOD_CALL                                         ~5, !0
         11        SEND_UNPACK                                              !1
         12        CHECK_UNDEF_ARGS                                         
         13        DO_FCALL                                      1  $6      
         14      > RETURN                                                   $6
   47    15    >   NEW                                              $7      'BadMethodCallException'
         16        INIT_FCALL                                               'sprintf'
         17        SEND_VAL                                                 'Unknown+method+PDO%3A%3A%25s+called%21'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $8      
         20        SEND_VAR_NO_REF_EX                                       $8
         21        DO_FCALL                                      0          
         22      > THROW                                         0          $7
   48    23*     > RETURN                                                   null

End of function __call

End of class Database.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.17 ms | 1448 KiB | 16 Q