@@ -47,12 +47,13 @@ public function __construct(
4747 ) {
4848 }
4949
50- public function getOutput ( ): string
50+ public function write ( string $ dbFile , string $ schemaFile ): void
5151 {
5252 $ schema = '' ;
5353 foreach ($ this ->outputSchema as $ constructor => $ params ) {
5454 $ schema .= self ::stringifySchema ($ constructor , $ params )."\n" ;
5555 }
56+ file_put_contents ($ schemaFile , $ schema );
5657 $ value = ['_ ' => 'fileReferenceOrigins ' , 'db_schema ' => $ schema , 'ctxs ' => $ this ->output ];
5758 Magic::start (false );
5859
@@ -61,8 +62,9 @@ public function getOutput(): string
6162 $ TL = new TL ((new ReflectionClass (MTProto::class))->newInstanceWithoutConstructor ());
6263 $ TL ->init ($ s );
6364 $ serialized = $ TL ->serializeObject (['type ' => 'FileReferenceOrigins ' ], $ value , '' );
64- //$valueDe = $TL->deserialize($serialized, ['type' => '', 'connection' => null, 'encrypted' => true]);
65- return $ serialized ;
65+ $ valueDe = $ TL ->deserialize ($ serialized , ['type ' => '' , 'connection ' => null , 'encrypted ' => true ]);
66+ Assert::true ($ value == $ valueDe );
67+ file_put_contents ($ dbFile , $ serialized );
6668 }
6769
6870 private static function stringifySchema (string $ constructor , array $ params ): string
@@ -94,6 +96,7 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
9496 '_ ' => 'origin ' ,
9597 'predicate ' => $ ctx ->position ,
9698 'is_constructor ' => $ ctx ->isConstructor ,
99+ 'parent_is_constructor ' => false ,
97100 ];
98101 if ($ this ->needsParent !== null ) {
99102 $ out ['needs_parent ' ] = $ this ->needsParent ;
0 commit comments