@@ -55,24 +55,30 @@ public static function crc(string $schema): string
5555 return $ id ;
5656 }
5757
58- public function finalize (string $ refMapFile , string $ dbSchemaFile ): void
58+ public function finalize (string $ refMapFile , string $ refMapFileJson ): void
5959 {
6060 $ dbSchema = '' ;
6161 foreach ($ this ->outputSchema as $ constructor => $ params ) {
6262 $ dbSchema .= self ::stringifySchema ($ constructor , $ params )."\n" ;
6363 }
64- file_put_contents ($ dbSchemaFile , $ dbSchema );
65- $ value = ['_ ' => 'fileReferenceOrigins ' , 'db_schema ' => $ dbSchema , 'ctxs ' => $ this ->output ];
64+ $ dbSchemaJSON = (new TL (null ))->toJson ($ dbSchema );
65+ $ value = [
66+ '_ ' => 'fileReferenceOrigins ' ,
67+ 'db_schema ' => $ dbSchema ,
68+ 'db_schema_json ' => json_encode ($ dbSchemaJSON , flags: JSON_THROW_ON_ERROR ),
69+ 'ctxs ' => $ this ->output ,
70+ ];
6671 Magic::start (false );
6772
6873 $ s = new TLSchema ;
69- $ s = $ s ->setOther (['filerefs ' => __DIR__ . '/../../../src/TL_filerefs .tl ' ]);
74+ $ s = $ s ->setOther (['filerefs ' => __DIR__ . '/../../../src/TL_file_ref_map_schema .tl ' ]);
7075 $ TL = new TL ((new ReflectionClass (MTProto::class))->newInstanceWithoutConstructor ());
7176 $ TL ->init ($ s );
7277 $ serialized = $ TL ->serializeObject (['type ' => 'FileReferenceOrigins ' ], $ value , '' );
7378 $ valueDe = $ TL ->deserialize ($ serialized , ['type ' => '' , 'connection ' => null , 'encrypted ' => true ]);
7479 Assert::true ($ value == $ valueDe );
7580 file_put_contents ($ refMapFile , $ serialized );
81+ file_put_contents ($ refMapFileJson , json_encode ($ valueDe , flags: JSON_THROW_ON_ERROR ));
7682 }
7783
7884 private static function stringifySchema (string $ constructor , array $ params ): string
0 commit comments