3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private ?string $b = null; public static function newInstance($args){ return new self($args); } public function __construct($b = 'default') { $this->b = $b; } public function test() { echo("Test:" . $this->b . "\n"); } } $a = new A('test'); $a->test(); var_dump(class_exists('\\A')); $b = new ReflectionClass('A'); $c = $b->newInstance(); $c->test(); var_dump(class_exists('\\A'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RgV7B
function name:  (null)
number of ops:  28
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $3      'A'
          1        SEND_VAL_EX                                              'test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   23     4        INIT_METHOD_CALL                                         !0, 'test'
          5        DO_FCALL                                      0          
   25     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'class_exists'
          8        SEND_VAL                                                 '%5CA'
          9        DO_ICALL                                         $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                                 
   27    12        NEW                                              $9      'ReflectionClass'
         13        SEND_VAL_EX                                              'A'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !1, $9
   28    16        INIT_METHOD_CALL                                         !1, 'newInstance'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !2, $12
   29    19        INIT_METHOD_CALL                                         !2, 'test'
         20        DO_FCALL                                      0          
   31    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'class_exists'
         23        SEND_VAL                                                 '%5CA'
         24        DO_ICALL                                         $15     
         25        SEND_VAR                                                 $15
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class A:
Function newinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RgV7B
function name:  newInstance
number of ops:  6
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        NEW                          self                $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
    9     5*     > RETURN                                                   null

End of function newinstance

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RgV7B
function name:  __construct
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      'default'
   13     1        ASSIGN_OBJ                                               'b'
          2        OP_DATA                                                  !0
   14     3      > RETURN                                                   null

End of function __construct

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RgV7B
function name:  test
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                      ~0      'b'
          1        CONCAT                                           ~1      'Test%3A', ~0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   19     4      > RETURN                                                   null

End of function test

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
232.24 ms | 1019 KiB | 15 Q