3v4l.org

run code in 500+ PHP versions simultaneously
<?php /** * Sealed class can not be created directly */ class Seal { private function __construct() { // private ctor prevents from direct creation of instance } } #1 Via traditional reflection without constructor $refClass = new ReflectionClass(Seal::class); $instance = $refClass->newInstanceWithoutConstructor(); var_dump($instance); #2 Via closure binding to the sealed class $instantinator = function () { return new static; }; $instantinator = $instantinator->bindTo(null, Seal::class); $instance = $instantinator(); var_dump($instance); #3 Via unserialize hack $instance = unserialize(sprintf('O:%d:"%s":0:{}', strlen(Seal::class), Seal::class)); var_dump($instance); #4 Via PDO, requires pdo_sqlite which is typically available, can be pdo_mysql, then change: SELECT "test" FROM DUAL if (phpversion('pdo_sqlite')) { $database = new PDO('sqlite::memory:'); $result = $database->query('SELECT "test" as field1'); // We can even initialize properties in the object $instance = $result->fetchObject(Seal::class); var_dump($instance); } #5 Via STOMP, requires php_stomp to be loaded if (phpversion('stomp')) { $connection = new Stomp(/* connection args */); $connection->subscribe('Test'); $connection->readFrame(Seal::class); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 55
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 68
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
Branch analysis from position: 55
filename:       /in/cSfPS
function name:  (null)
number of ops:  69
compiled vars:  !0 = $refClass, !1 = $instance, !2 = $instantinator, !3 = $database, !4 = $result, !5 = $connection
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   NEW                                                  $6      'ReflectionClass'
          1        SEND_VAL_EX                                                  'Seal'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $6
   15     4        INIT_METHOD_CALL                                             !0, 'newInstanceWithoutConstructor'
          5        DO_FCALL                                          0  $9      
          6        ASSIGN                                                       !1, $9
   16     7        INIT_FCALL                                                   'var_dump'
          8        SEND_VAR                                                     !1
          9        DO_ICALL                                                     
   19    10        DECLARE_LAMBDA_FUNCTION                              ~12     [0]
         11        ASSIGN                                                       !2, ~12
   22    12        INIT_METHOD_CALL                                             !2, 'bindTo'
         13        SEND_VAL_EX                                                  null
         14        SEND_VAL_EX                                                  'Seal'
         15        DO_FCALL                                          0  $14     
         16        ASSIGN                                                       !2, $14
   23    17        INIT_DYNAMIC_CALL                                            !2
         18        DO_FCALL                                          0  $16     
         19        ASSIGN                                                       !1, $16
   24    20        INIT_FCALL                                                   'var_dump'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                                     
   27    23        INIT_FCALL                                                   'unserialize'
         24        ROPE_INIT                                         5  ~21     'O%3A'
         25        CAST                                              4  ~19     4
         26        ROPE_ADD                                          1  ~21     ~21, ~19
         27        ROPE_ADD                                          2  ~21     ~21, '%3A%22'
         28        ROPE_ADD                                          3  ~21     ~21, 'Seal'
         29        ROPE_END                                          4  ~20     ~21, '%22%3A0%3A%7B%7D'
         30        SEND_VAL                                                     ~20
         31        DO_ICALL                                             $24     
         32        ASSIGN                                                       !1, $24
   28    33        INIT_FCALL                                                   'var_dump'
         34        SEND_VAR                                                     !1
         35        DO_ICALL                                                     
   31    36        INIT_FCALL                                                   'phpversion'
         37        SEND_VAL                                                     'pdo_sqlite'
         38        DO_ICALL                                             $27     
         39      > JMPZ                                                         $27, ->55
   32    40    >   NEW                                                  $28     'PDO'
         41        SEND_VAL_EX                                                  'sqlite%3A%3Amemory%3A'
         42        DO_FCALL                                          0          
         43        ASSIGN                                                       !3, $28
   33    44        INIT_METHOD_CALL                                             !3, 'query'
         45        SEND_VAL_EX                                                  'SELECT+%22test%22+as+field1'
         46        DO_FCALL                                          0  $31     
         47        ASSIGN                                                       !4, $31
   34    48        INIT_METHOD_CALL                                             !4, 'fetchObject'
         49        SEND_VAL_EX                                                  'Seal'
         50        DO_FCALL                                          0  $33     
         51        ASSIGN                                                       !1, $33
   35    52        INIT_FCALL                                                   'var_dump'
         53        SEND_VAR                                                     !1
         54        DO_ICALL                                                     
   39    55    >   INIT_FCALL                                                   'phpversion'
         56        SEND_VAL                                                     'stomp'
         57        DO_ICALL                                             $36     
         58      > JMPZ                                                         $36, ->68
   40    59    >   NEW                                                  $37     'Stomp'
         60        DO_FCALL                                          0          
         61        ASSIGN                                                       !5, $37
   41    62        INIT_METHOD_CALL                                             !5, 'subscribe'
         63        SEND_VAL_EX                                                  'Test'
         64        DO_FCALL                                          0          
   42    65        INIT_METHOD_CALL                                             !5, 'readFrame'
         66        SEND_VAL_EX                                                  'Seal'
         67        DO_FCALL                                          0          
   43    68    > > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cSfPS
function name:  {closure:/in/cSfPS:19}
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   NEW                              static              $0      
          1        DO_FCALL                                          0          
          2      > RETURN                                                       $0
   21     3*     > RETURN                                                       null

End of Dynamic Function 0

Class Seal:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cSfPS
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                       null

End of function __construct

End of class Seal.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
181.24 ms | 1435 KiB | 16 Q