12
12
13
13
$ locations = [];
14
14
15
- final class TLContext
15
+ final readonly class TLContext
16
16
{
17
17
public function __construct (
18
18
public readonly TLInterface $ tl ,
@@ -144,7 +144,7 @@ interface ActionOp extends Op
144
144
{
145
145
}
146
146
147
- final class Noop implements ActionOp
147
+ final readonly class Noop implements ActionOp
148
148
{
149
149
public function __construct (private readonly string $ why )
150
150
{
@@ -171,7 +171,7 @@ public function build(TLContext $tl): array
171
171
}
172
172
}
173
173
174
- final class CopyMethodCallOp implements ActionOp
174
+ final readonly class CopyMethodCallOp implements ActionOp
175
175
{
176
176
public function __construct (private readonly string $ method )
177
177
{
@@ -198,7 +198,7 @@ public function build(TLContext $tl): array
198
198
}
199
199
}
200
200
201
- final class ThemeFormatOp implements ExtractorOrLiteralOp
201
+ final readonly class ThemeFormatOp implements ExtractorOrLiteralOp
202
202
{
203
203
public function __construct ()
204
204
{
@@ -225,7 +225,7 @@ public function build(TLContext $tl): array
225
225
}
226
226
}
227
227
228
- final class ExtractFromHereOp implements SimpleExtractorOp
228
+ final readonly class ExtractFromHereOp implements SimpleExtractorOp
229
229
{
230
230
public function __construct (
231
231
/** @var string[] */
@@ -286,7 +286,7 @@ public function build(TLContext $tl): array
286
286
}
287
287
}
288
288
289
- final class ExtractFromMethodCallOp implements SimpleExtractorOp
289
+ final readonly class ExtractFromMethodCallOp implements SimpleExtractorOp
290
290
{
291
291
public function __construct (
292
292
/** @var string[] */
@@ -347,7 +347,7 @@ public function build(TLContext $tl): array
347
347
}
348
348
}
349
349
350
- final class ExtractStickerSetFromDocumentAttributesOp implements SimpleExtractorOp
350
+ final readonly class ExtractStickerSetFromDocumentAttributesOp implements SimpleExtractorOp
351
351
{
352
352
public function __construct (
353
353
private readonly SimpleExtractorOp $ path ,
@@ -386,7 +386,7 @@ public function build(TLContext $tl): array
386
386
}
387
387
}
388
388
389
- final class GetInputPeerOp implements ExtractorOrLiteralOp
389
+ final readonly class GetInputPeerOp implements ExtractorOrLiteralOp
390
390
{
391
391
public function __construct (private readonly SimpleExtractorOp $ path )
392
392
{
@@ -425,7 +425,7 @@ public function build(TLContext $tl): array
425
425
];
426
426
}
427
427
}
428
- final class GetInputUserOp implements ExtractorOrLiteralOp
428
+ final readonly class GetInputUserOp implements ExtractorOrLiteralOp
429
429
{
430
430
public function __construct (private readonly SimpleExtractorOp $ path )
431
431
{
@@ -470,7 +470,7 @@ public function build(TLContext $tl): array
470
470
];
471
471
}
472
472
}
473
- final class GetInputChannelOp implements ExtractorOrLiteralOp
473
+ final readonly class GetInputChannelOp implements ExtractorOrLiteralOp
474
474
{
475
475
public function __construct (private readonly SimpleExtractorOp $ path )
476
476
{
@@ -516,7 +516,7 @@ public function build(TLContext $tl): array
516
516
}
517
517
}
518
518
519
- final class ArrayOp implements ExtractorOrLiteralOp
519
+ final readonly class ArrayOp implements ExtractorOrLiteralOp
520
520
{
521
521
/** @var Op[] */
522
522
private readonly array $ values ;
@@ -571,7 +571,7 @@ public function build(TLContext $tl): array
571
571
}
572
572
}
573
573
574
- final class LiteralOp implements ExtractorOrLiteralOp
574
+ final readonly class LiteralOp implements ExtractorOrLiteralOp
575
575
{
576
576
public function __construct (private readonly string $ type , private readonly mixed $ value )
577
577
{
@@ -601,7 +601,7 @@ public function build(TLContext $tl): array
601
601
}
602
602
}
603
603
604
- final class GetMessageOp implements ActionOp
604
+ final readonly class GetMessageOp implements ActionOp
605
605
{
606
606
public function __construct (
607
607
private readonly Op $ peer ,
@@ -644,7 +644,7 @@ public function build(TLContext $tl): array
644
644
}
645
645
}
646
646
647
- final class CallOp implements ActionOp
647
+ final readonly class CallOp implements ActionOp
648
648
{
649
649
/** @param Op[] $args */
650
650
public function __construct (
@@ -711,7 +711,7 @@ public function build(TLContext $tl): array
711
711
];
712
712
}
713
713
}
714
- final class ConstructorOp implements ExtractorOrLiteralOp
714
+ final readonly class ConstructorOp implements ExtractorOrLiteralOp
715
715
{
716
716
/** @param Op[] $args */
717
717
public function __construct (
@@ -978,6 +978,8 @@ public function build(TLContext $tl): array
978
978
'limit ' => new LiteralOp ('int ' , 1 ),
979
979
]
980
980
);
981
+ $ locations ['messages.getInlineBotResults ' ][]= new Noop ('Inline bot results are ephemeral ' );
982
+ $ locations ['messages.getPreparedInlineMessage ' ][]= new Noop ('Inline bot results are ephemeral ' );
981
983
982
984
$ locations ['messages.uploadMedia ' ][]= new Noop ('A freshly uploaded media file will obtain a context only once it is sent to a chat ' );
983
985
@@ -999,6 +1001,11 @@ public function build(TLContext $tl): array
999
1001
}
1000
1002
1001
1003
$ recurse = static function (Closure $ onStackEnd , string $ type , array &$ stack , array &$ stackTypes ) use ($ TL , &$ recurse ): void {
1004
+ if ($ type === 'Update ' || $ type === 'Updates ' ) {
1005
+ $ onStackEnd ($ stack );
1006
+ return ;
1007
+ }
1008
+
1002
1009
$ pos = count ($ stack );
1003
1010
$ found = false ;
1004
1011
foreach ([...$ TL ->getConstructors ()->by_id , ...$ TL ->getMethods ()->by_id ] as $ constructor ) {
@@ -1086,20 +1093,10 @@ public function build(TLContext $tl): array
1086
1093
$ stack = [$ constructor ];
1087
1094
$ stackTypes = [$ type => true ];
1088
1095
$ recurse (
1089
- static function (array $ stack ) use ($ locations ): void {
1096
+ static function (array $ stack ) use ($ locations, $ TL , & $ normalizedLocations ): void {
1090
1097
if (end ($ stack ) === 'messages.getWebPagePreview '
1091
- || end ($ stack ) === 'help.appUpdate '
1092
- || (
1093
- in_array ($ stack [0 ], ['photo ' , 'document ' ], true )
1094
- && ($ stack [1 ] ?? null ) === 'game '
1095
- && in_array (end ($ stack ), [
1096
- 'messages.getWebPagePreview ' ,
1097
- 'messages.invitedUsers ' ,
1098
- 'payments.paymentResult ' ,
1099
- ], true )
1100
- ) || array_intersect (
1098
+ || array_intersect (
1101
1099
[
1102
- 'updateServiceNotification ' ,
1103
1100
'updateShortSentMessage ' ,
1104
1101
'updateShortMessage ' ,
1105
1102
'updateShortChatMessage ' ,
@@ -1111,19 +1108,20 @@ static function (array $stack) use ($locations): void {
1111
1108
}
1112
1109
$ slice = [];
1113
1110
$ had = false ;
1111
+ $ top = $ stack [0 ];
1114
1112
for ($ x = count ($ stack )-1 ; $ x >= 0 ; $ x --) {
1115
1113
$ constructor = $ stack [$ x ];
1116
- $ slice [] = $ constructor ;
1117
1114
if (isset ($ locations [$ constructor ])) {
1118
1115
foreach ($ locations [$ constructor ] as $ op ) {
1119
1116
$ normalized = $ op ->normalize ($ slice );
1120
1117
if ($ normalized === null ) {
1121
1118
continue ;
1122
1119
}
1123
1120
$ had = true ;
1124
- $ normalizedLocations [$ constructor ][] = $ normalized ;
1121
+ $ normalizedLocations [$ top ][] = $ normalized; //->build(new TLContext($TL, $constructor)) ;
1125
1122
}
1126
1123
}
1124
+ $ slice [] = $ constructor ;
1127
1125
}
1128
1126
if (!$ had ) {
1129
1127
throw new AssertionError ("Uncovered path: " . json_encode ($ stack ));
@@ -1134,3 +1132,5 @@ static function (array $stack) use ($locations): void {
1134
1132
$ stackTypes ,
1135
1133
);
1136
1134
}
1135
+
1136
+ var_dump ($ normalizedLocations );
0 commit comments