3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Json { public function toJSON() { return json_encode(get_object_vars($this)); } } class A extends Json { private $a; function __construct($input = null) { $this->a = $input; } //getter & setter } class B extends Json { private $b; function __construct($input = null) { $this->b = $input; } //getter & setter } $a = (new A("A"))->toJSON(); var_dump($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vhr9M
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'A'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $1, 'toJSON'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !0, $3
   33     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class Json:
Function tojson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vhr9M
function name:  toJSON
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'json_encode'
          1        INIT_FCALL                                               'get_object_vars'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    7     8*     > RETURN                                                   null

End of function tojson

End of class Json.

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

End of function __construct

Function tojson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vhr9M
function name:  toJSON
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'json_encode'
          1        INIT_FCALL                                               'get_object_vars'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    7     8*     > RETURN                                                   null

End of function tojson

End of class A.

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

End of function __construct

Function tojson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vhr9M
function name:  toJSON
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'json_encode'
          1        INIT_FCALL                                               'get_object_vars'
          2        FETCH_THIS                                       ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    7     8*     > RETURN                                                   null

End of function tojson

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.29 ms | 1017 KiB | 16 Q