3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements JsonSerializable{ public $baz = 10; function jsonSerialize(){ return ['bar' => 20]; } } class B implements JsonSerializable{ function jsonSerialize(){ return ['foo' => new A]; } } echo json_encode(new B, JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XTWcj
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   10     1        DECLARE_CLASS                                            'b'
   16     2        INIT_FCALL                                               'json_encode'
          3        NEW                                              $0      'B'
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $0
          6        SEND_VAL                                                 128
          7        DO_ICALL                                         $2      
          8        ECHO                                                     $2
          9      > RETURN                                                   1

Class A:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XTWcj
function name:  jsonSerialize
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   <array>
    7     1*     > RETURN                                                   null

End of function jsonserialize

End of class A.

Class B:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XTWcj
function name:  jsonSerialize
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $0      'A'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~2      $0, 'foo'
          3      > RETURN                                                   ~2
   13     4*     > RETURN                                                   null

End of function jsonserialize

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.36 ms | 1000 KiB | 14 Q