3v4l.org

run code in 300+ PHP versions simultaneously
<?php // fake facade / IoC // class app { public static function make() { return new MyJSON; } } class JSON { public function encode($object) { if (function_exists('json_encode')) { return json_encode($object); } return $this->shimJson(); } public function shimJson() { return 'derp'; } } /////////////////////// class MyJSON extends JSON { public function encode($object, $options = JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) { return json_encode($object, $options); } } echo app::make('json')->encode(array('test'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_STATIC_METHOD_CALL                                  'app', 'make'
          1        SEND_VAL                                                 'json'
          2        DO_FCALL                                      0  $0      
          3        INIT_METHOD_CALL                                         $0, 'encode'
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0  $1      
          6        ECHO                                                     $1
          7      > RETURN                                                   1

Class app:
Function make:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  make
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $0      'MyJSON'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function make

End of class app.

Class JSON:
Function encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  encode
number of ops:  13
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'function_exists'
          2        SEND_VAL                                                 'json_encode'
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->9
    9     5    >   INIT_FCALL                                               'json_encode'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   12     9    >   INIT_METHOD_CALL                                         'shimJson'
         10        DO_FCALL                                      0  $3      
         11      > RETURN                                                   $3
   13    12*     > RETURN                                                   null

End of function encode

Function shimjson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  shimJson
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E > > RETURN                                                   'derp'
   17     1*     > RETURN                                                   null

End of function shimjson

End of class JSON.

Class MyJSON:
Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  encode
number of ops:  8
compiled vars:  !0 = $object, !1 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
   26     2        INIT_FCALL                                               'json_encode'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   27     7*     > RETURN                                                   null

End of function encode

Function shimjson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jhfiN
function name:  shimJson
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E > > RETURN                                                   'derp'
   17     1*     > RETURN                                                   null

End of function shimjson

End of class MyJSON.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.62 ms | 1400 KiB | 17 Q