3v4l.org

run code in 500+ PHP versions simultaneously
<?php function redirextExceptions(Throwable $exception) { echo 'Perevodim na strnicu oshibki.' . PHP_EOL. 'Error: ' . $exception->getMessage() . PHP_EOL; } set_exception_handler('redirextExceptions'); class Schema { private static array $tables = [ 'user' => [ 'id' => 'int', 'name' => 'string', ] ]; public static function getTableColumnByName(string $tableName, string $columnName): TableColumn { if (false === array_key_exists($tableName, static::$tables)) { throw new Exception(static::class . ' table "' . $tableName . '" not found.'); } if (false === array_key_exists($columnName, static::$tables[$tableName])) { throw new Exception('Table "' . $tableName . '" column "' . $columnName . '" not found.'); } return new TableColumn($columnName, static::$tables[$tableName][$columnName]); } } class UserTableGateway { public function update(int $id, TableColumn $column, mixed $value): void { echo 'Zaebis! Sohranil: "' . $value . '"' . PHP_EOL; } } class TableColumn { public function __construct( public readonly string $name, public readonly string $type, ) {} } $gateway = new UsertableGateway; $gateway->update(33, Schema::getTableColumnByName('user', 'name'), 'Vasya'); $gateway->update(33, Schema::getTableColumnByName('user', 'familiya'), 'Vasya');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUCBB
function name:  (null)
number of ops:  25
compiled vars:  !0 = $gateway
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                                   'set_exception_handler'
          1        SEND_VAL                                                     'redirextExceptions'
          2        DO_ICALL                                                     
   44     3        NEW                                                  $2      'UsertableGateway'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !0, $2
   45     6        INIT_METHOD_CALL                                             !0, 'update'
          7        SEND_VAL_EX                                                  33
          8        INIT_STATIC_METHOD_CALL                                      'Schema', 'getTableColumnByName'
          9        SEND_VAL                                                     'user'
         10        SEND_VAL                                                     'name'
         11        DO_FCALL                                          0  $5      
         12        SEND_VAR_NO_REF_EX                                           $5
         13        SEND_VAL_EX                                                  'Vasya'
         14        DO_FCALL                                          0          
   46    15        INIT_METHOD_CALL                                             !0, 'update'
         16        SEND_VAL_EX                                                  33
         17        INIT_STATIC_METHOD_CALL                                      'Schema', 'getTableColumnByName'
         18        SEND_VAL                                                     'user'
         19        SEND_VAL                                                     'familiya'
         20        DO_FCALL                                          0  $7      
         21        SEND_VAR_NO_REF_EX                                           $7
         22        SEND_VAL_EX                                                  'Vasya'
         23        DO_FCALL                                          0          
         24      > RETURN                                                       1

Function redirextexceptions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUCBB
function name:  redirextExceptions
number of ops:  7
compiled vars:  !0 = $exception
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_METHOD_CALL                                             !0, 'getMessage'
          2        DO_FCALL                                          0  $1      
          3        CONCAT                                               ~2      'Perevodim+na+strnicu+oshibki.%0AError%3A+', $1
          4        CONCAT                                               ~3      ~2, '%0A'
          5        ECHO                                                         ~3
    6     6      > RETURN                                                       null

End of function redirextexceptions

Class Schema:
Function gettablecolumnbyname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUCBB
function name:  getTableColumnByName
number of ops:  39
compiled vars:  !0 = $tableName, !1 = $columnName
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   19     2        FETCH_STATIC_PROP_R              unknown             ~2      'tables'
          3        ARRAY_KEY_EXISTS                                     ~3      !0, ~2
          4        TYPE_CHECK                                        4          ~3
          5      > JMPZ                                                         ~4, ->14
   20     6    >   NEW                                                  $5      'Exception'
          7        FETCH_CLASS_NAME                                     ~6      
          8        CONCAT                                               ~7      ~6, '+table+%22'
          9        CONCAT                                               ~8      ~7, !0
         10        CONCAT                                               ~9      ~8, '%22+not+found.'
         11        SEND_VAL_EX                                                  ~9
         12        DO_FCALL                                          0          
         13      > THROW                                             0          $5
   23    14    >   FETCH_STATIC_PROP_R              unknown             ~11     'tables'
         15        FETCH_DIM_R                                          ~12     ~11, !0
         16        ARRAY_KEY_EXISTS                                     ~13     !1, ~12
         17        TYPE_CHECK                                        4          ~13
         18      > JMPZ                                                         ~14, ->27
   24    19    >   NEW                                                  $15     'Exception'
         20        CONCAT                                               ~16     'Table+%22', !0
         21        CONCAT                                               ~17     ~16, '%22+column+%22'
         22        CONCAT                                               ~18     ~17, !1
         23        CONCAT                                               ~19     ~18, '%22+not+found.'
         24        SEND_VAL_EX                                                  ~19
         25        DO_FCALL                                          0          
         26      > THROW                                             0          $15
   27    27    >   NEW                                                  $21     'TableColumn'
         28        SEND_VAR_EX                                                  !1
         29        CHECK_FUNC_ARG                                               
         30        FETCH_STATIC_PROP_FUNC_ARG       unknown             $22     'tables'
         31        FETCH_DIM_FUNC_ARG                                   $23     $22, !0
         32        FETCH_DIM_FUNC_ARG                                   $24     $23, !1
         33        SEND_FUNC_ARG                                                $24
         34        DO_FCALL                                          0          
         35        VERIFY_RETURN_TYPE                                           $21
         36      > RETURN                                                       $21
   28    37*       VERIFY_RETURN_TYPE                                           
         38*     > RETURN                                                       null

End of function gettablecolumnbyname

End of class Schema.

Class UserTableGateway:
Function update:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUCBB
function name:  update
number of ops:  8
compiled vars:  !0 = $id, !1 = $column, !2 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   33     3        CONCAT                                               ~3      'Zaebis%21+Sohranil%3A+%22', !2
          4        CONCAT                                               ~4      ~3, '%22'
          5        CONCAT                                               ~5      ~4, '%0A'
          6        ECHO                                                         ~5
   34     7      > RETURN                                                       null

End of function update

End of class UserTableGateway.

Class TableColumn:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KUCBB
function name:  __construct
number of ops:  7
compiled vars:  !0 = $name, !1 = $type
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   RECV                                                 !0      
   40     1        RECV                                                 !1      
   39     2        ASSIGN_OBJ                                                   'name'
          3        OP_DATA                                                      !0
   40     4        ASSIGN_OBJ                                                   'type'
          5        OP_DATA                                                      !1
   41     6      > RETURN                                                       null

End of function __construct

End of class TableColumn.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.69 ms | 1550 KiB | 14 Q