3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { class Bar { function baz() { return time(); } } } namespace { class Test { public static $now; function register() { $namespace = '\\Foo'; eval('namespace '.$namespace.' { function time() { return \\'.__CLASS__.'::$now ?: \time(); } }'); } } $b = new Foo\Bar(); $t = new Test(); $t->register(); Test::$now = 'xxx'; $b->baz(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Pnl1
function name:  (null)
number of ops:  13
compiled vars:  !0 = $b, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'Foo%5CBar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   26     3        NEW                                              $5      'Test'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   28     6        INIT_METHOD_CALL                                         !1, 'register'
          7        DO_FCALL                                      0          
   29     8        ASSIGN_STATIC_PROP                                       'now', 'Test'
          9        OP_DATA                                                  'xxx'
   31    10        INIT_METHOD_CALL                                         !0, 'baz'
         11        DO_FCALL                                      0          
   33    12      > RETURN                                                   1

Class Foo\Bar:
Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Pnl1
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_NS_FCALL_BY_NAME                                    'Foo%5Ctime'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
    7     3*     > RETURN                                                   null

End of function baz

End of class Foo\Bar.

Class Test:
Function register:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Pnl1
function name:  register
number of ops:  7
compiled vars:  !0 = $namespace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, '%5CFoo'
   17     1        CONCAT                                           ~2      'namespace+', !0
          2        CONCAT                                           ~3      ~2, '+%7B%0A++++++++++++++++function+time%28%29+%7B%0A++++++++++++++++++++return+%5C'
   19     3        CONCAT                                           ~4      ~3, 'Test'
          4        CONCAT                                           ~5      ~4, '%3A%3A%24now+%3F%3A+%5Ctime%28%29%3B%0A++++++++++++++++%7D%0A++++++++++++%7D'
          5        INCLUDE_OR_EVAL                                          ~5, EVAL
   22     6      > RETURN                                                   null

End of function register

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.67 ms | 1401 KiB | 15 Q