3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $a = 'a'; } class B implements \JsonSerialize { protected $a; function __construct(A $a) { $this->a = $a; } public function jsonSerialize() { return [ 'a' => $this->a ]; } } $b = new B(new A()); echo json_encode($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/31Ft8
function name:  (null)
number of ops:  12
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'b'
   25     1        NEW                                              $1      'B'
          2        NEW                                              $2      'A'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   27     7        INIT_FCALL                                               'json_encode'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        ECHO                                                     $6
         11      > RETURN                                                   1

Class A: [no user functions]
Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/31Ft8
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
   14     3      > RETURN                                                   null

End of function __construct

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/31Ft8
function name:  jsonSerialize
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        INIT_ARRAY                                       ~1      ~0, 'a'
          2      > RETURN                                                   ~1
   21     3*     > RETURN                                                   null

End of function jsonserialize

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.19 ms | 1387 KiB | 15 Q