3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace OK { class ServiceOK { public function __construct() { time(); } public function time() { return time(); } } } namespace KO { class ServiceKO { public function __construct() { $this->time(); } public function time() { return time(); } } } namespace { // From https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/PhpUnit/ClockMock.php // An simplified a lot :) class ClockMock { public static function register(string $ns) { eval(<<<EOPHP namespace $ns; function time() { return 0; } EOPHP ); } } $service = new OK\ServiceOK(); ClockMock::register('OK'); var_dump($service->time()); $service = new KO\ServiceKO(); ClockMock::register('KO'); var_dump($service->time()); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QvsTk
function name:  (null)
number of ops:  23
compiled vars:  !0 = $service
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   NEW                                              $1      'OK%5CServiceOK'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   55     3        INIT_STATIC_METHOD_CALL                                  'ClockMock', 'register'
          4        SEND_VAL                                                 'OK'
          5        DO_FCALL                                      0          
   56     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'time'
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
   58    11        NEW                                              $7      'KO%5CServiceKO'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $7
   59    14        INIT_STATIC_METHOD_CALL                                  'ClockMock', 'register'
         15        SEND_VAL                                                 'KO'
         16        DO_FCALL                                      0          
   60    17        INIT_FCALL                                               'var_dump'
         18        INIT_METHOD_CALL                                         !0, 'time'
         19        DO_FCALL                                      0  $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                                 
   61    22      > RETURN                                                   1

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

End of function __construct

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

End of function time

End of class OK\ServiceOK.

Class KO\ServiceKO:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QvsTk
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_METHOD_CALL                                         'time'
          1        DO_FCALL                                      0          
   26     2      > RETURN                                                   null

End of function __construct

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

End of function time

End of class KO\ServiceKO.

Class ClockMock:
Function register:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QvsTk
function name:  register
number of ops:  6
compiled vars:  !0 = $ns
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   43     1        ROPE_INIT                                     3  ~2      'namespace+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%3B%0A%0Afunction+time%28%29%0A%7B%0A++++return+0%3B%0A%7D'
          4        INCLUDE_OR_EVAL                                          ~1, EVAL
   51     5      > RETURN                                                   null

End of function register

End of class ClockMock.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.14 ms | 1400 KiB | 17 Q