|
361 | 361 | $stackTypes = [$type => true];
|
362 | 362 | $recurse(
|
363 | 363 | static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMethods, $starMethods): void {
|
364 |
| - foreach ([false, true] as $ignoreFlagged) { |
365 |
| - $slice = []; |
366 |
| - $hadAll = true; |
367 |
| - $hadAny = false; |
368 |
| - $top = end($stack)[0]; |
369 |
| - for ($x = count($stack)-1; $x >= 0; $x--) { |
370 |
| - $pair = $stack[$x]; |
371 |
| - foreach ($locations[$pair[0]] ?? [] as $op) { |
372 |
| - $normalized = $op->normalize($slice, $pair[0], $ignoreFlagged); |
373 |
| - if ($normalized === null) { |
374 |
| - $hadAll = false; |
375 |
| - continue; |
376 |
| - } |
377 |
| - $hadAny = true; |
378 |
| - $normalized->build(new TLContext($TL, $tmp, $top)); |
379 |
| - $validated[$pair[0]][spl_object_id($op)] = $op; |
| 364 | + $slice = []; |
| 365 | + $hadAny = false; |
| 366 | + $skippedDueToFlags = []; |
| 367 | + $top = end($stack)[0]; |
| 368 | + for ($x = count($stack)-1; $x >= 0; $x--) { |
| 369 | + $pair = $stack[$x]; |
| 370 | + foreach ($locations[$pair[0]] ?? [] as $op) { |
| 371 | + $normalized = $op->normalize($slice, $pair[0], false); |
| 372 | + if ($normalized === null) { |
| 373 | + continue; |
| 374 | + } |
| 375 | + $hadAny = true; |
| 376 | + $normalized->build(new TLContext($TL, $tmp, $top)); |
| 377 | + $validated[$pair[0]][spl_object_id($op)] = $op; |
| 378 | + |
| 379 | + $normalized = $op->normalize($slice, $pair[0], true); |
| 380 | + if ($normalized === null) { |
| 381 | + $skippedDueToFlags []= $op; |
| 382 | + continue; |
380 | 383 | }
|
381 |
| - $slice[] = $pair; |
382 |
| - } |
383 |
| - if (!$ignoreFlagged && !$hadAny) { |
384 |
| - throw new AssertionError("Uncovered path: " . json_encode($stack)); |
385 | 384 | }
|
386 |
| - if ($ignoreFlagged && !$hadAll) { |
387 |
| - if ($top === 'updateStory' |
388 |
| - || $top === 'peerStories' |
389 |
| - // The two above always have the story peer flag set. |
| 385 | + $slice[] = $pair; |
| 386 | + } |
| 387 | + if (!$hadAny) { |
| 388 | + throw new AssertionError("Uncovered path: " . json_encode($stack)); |
| 389 | + } |
| 390 | + if ($skippedDueToFlags) { |
| 391 | + if ($top === 'updateStory' |
| 392 | + || $top === 'peerStories' |
| 393 | + // The two above always have the story peer flag set. |
390 | 394 |
|
391 |
| - || isset($storyMethods[$top]) |
392 |
| - || isset($starMethods[$top]) |
| 395 | + || isset($storyMethods[$top]) |
| 396 | + || isset($starMethods[$top]) |
393 | 397 |
|
394 |
| - // The two above always have the story peer/all star flags set. |
| 398 | + // The two above always have the story peer/all star flags set. |
395 | 399 |
|
396 |
| - || $top === 'messages.getFullChat' |
397 |
| - || $top === 'channels.getFullChannel' |
398 |
| - || $top === 'users.getFullUser' |
399 |
| - // The two above are related to botInfo, ignore as we already store a context for the chat info. |
| 400 | + || $top === 'messages.getFullChat' |
| 401 | + || $top === 'channels.getFullChannel' |
| 402 | + || $top === 'users.getFullUser' |
| 403 | + // The two above are related to botInfo, ignore as we already store a context for the chat info. |
| 404 | + ) { |
| 405 | + return; |
| 406 | + } |
| 407 | + foreach ($slice as [$cons]) { |
| 408 | + if ($cons === 'webPageAttributeStory' |
| 409 | + || $cons === 'foundStory' |
| 410 | + || $cons === 'publicForwardStory' |
400 | 411 | ) {
|
401 |
| - continue; |
402 |
| - } |
403 |
| - foreach ($slice as [$cons]) { |
404 |
| - if ($cons === 'webPageAttributeStory' |
405 |
| - || $cons === 'foundStory' |
406 |
| - || $cons === 'publicForwardStory' |
407 |
| - ) { |
408 |
| - continue 2; |
409 |
| - } |
| 412 | + return; |
410 | 413 | }
|
411 |
| - throw new AssertionError("Uncovered path (didn't have at least one unflagged context): " . json_encode($stack)); |
412 | 414 | }
|
| 415 | + var_dump($skippedDueToFlags); |
| 416 | + throw new AssertionError("Uncovered path (didn't have at least one unflagged context): " . json_encode($stack)); |
413 | 417 | }
|
414 | 418 | },
|
415 | 419 | $type,
|
|
0 commit comments