3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Stringable { const HOGE = 'hoge'; public function __toString(): string { return 'HOGE'; } } function f(Stringable $name): void { var_dump(Foo::{(string)$name}); var_dump(Foo::{$name}); } f(new Foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WZTCC
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   17     1        INIT_FCALL                                               'f'
          2        NEW                                              $0      'Foo'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $0
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WZTCC
function name:  f
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'var_dump'
          2        CAST                                          6  ~1      !0
          3        FETCH_CLASS_CONSTANT                             ~2      'Foo', ~1
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   14     6        INIT_FCALL                                               'var_dump'
          7        FETCH_CLASS_CONSTANT                             ~4      'Foo', !0
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                                 
   15    10      > RETURN                                                   null

End of function f

Class Foo:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WZTCC
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   'HOGE'
    9     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.42 ms | 1002 KiB | 15 Q