3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Recursion implements JsonSerializable { public function __construct() { $this->cnt = 10; } public function jsonSerialize() { if ($this->cnt < 1) { return null; } $this->cnt--; return array($this->cnt => $this); } } var_dump(json_encode(new Recursion()));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NZDAB
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'recursion'
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'json_encode'
          3        NEW                                              $0      'Recursion'
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class Recursion:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NZDAB
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN_OBJ                                               'cnt'
          1        OP_DATA                                                  10
    7     2      > RETURN                                                   null

End of function __construct

Function jsonserialize:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NZDAB
function name:  jsonSerialize
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~0      'cnt'
          1        IS_SMALLER                                               ~0, 1
          2      > JMPZ                                                     ~1, ->4
   11     3    > > RETURN                                                   null
   13     4    >   PRE_DEC_OBJ                                              'cnt'
   14     5        FETCH_OBJ_R                                      ~3      'cnt'
          6        FETCH_THIS                                       ~4      
          7        INIT_ARRAY                                       ~5      ~4, ~3
          8      > RETURN                                                   ~5
   15     9*     > RETURN                                                   null

End of function jsonserialize

End of class Recursion.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.79 ms | 1396 KiB | 17 Q