|
| 1 | +--TEST-- |
| 2 | +GH-15101: _ir_RSTORE: Assertion `ctx->control' failed |
| 3 | +--EXTENSIONS-- |
| 4 | +opcache |
| 5 | +--INI-- |
| 6 | +opcache.enable=1 |
| 7 | +opcache.enable_cli=1 |
| 8 | +opcache.file_update_protection=0 |
| 9 | +opcache.revalidate_freq=0 |
| 10 | +opcache.protect_memory=1 |
| 11 | +--FILE-- |
| 12 | +<?php |
| 13 | +class A { |
| 14 | + function test($context, $token) { |
| 15 | + if ($token instanceof DoctypeToken) { |
| 16 | + $this->processDoctypeToken($context, $token); |
| 17 | + } |
| 18 | + } |
| 19 | + private function processDoctypeToken(TreeBuilderContext $context, DoctypeToken $token): void |
| 20 | + { |
| 21 | + $publicId = $token->publicIdentifier; |
| 22 | + $systemId = $token->systemIdentifier; |
| 23 | + $name = $token->name; |
| 24 | + |
| 25 | + if ($name !== 'html' |
| 26 | + || $publicId !== null |
| 27 | + || ($systemId !== null && $systemId !== 'about:legacy-compat')) { |
| 28 | + } |
| 29 | + |
| 30 | + $doctype = new DocumentType($context->document, $name ?? '', $publicId ?? '', $systemId ?? ''); |
| 31 | + } |
| 32 | +} |
| 33 | +class Document { |
| 34 | +} |
| 35 | +final class TreeBuilderContext { |
| 36 | + public $document; |
| 37 | + public function __construct() { |
| 38 | + $this->document = new Document; |
| 39 | + } |
| 40 | +} |
| 41 | +abstract class Node { |
| 42 | + public const DOCUMENT_TYPE_NODE = 10; |
| 43 | + |
| 44 | + protected function __construct(Document $document, int $nodeType) |
| 45 | + { |
| 46 | + } |
| 47 | +} |
| 48 | +class DocumentType extends Node { |
| 49 | + public readonly string $name; |
| 50 | + public readonly string $publicId; |
| 51 | + public readonly string $systemId; |
| 52 | + |
| 53 | + public function __construct( |
| 54 | + Document $document, |
| 55 | + string $name, |
| 56 | + string $publicId = '', |
| 57 | + string $systemId = '') { |
| 58 | + parent::__construct($document, self::DOCUMENT_TYPE_NODE); |
| 59 | + } |
| 60 | +} |
| 61 | +class DoctypeToken { |
| 62 | + public $publicIdentifier; |
| 63 | + public $name; |
| 64 | + public $systemIdentifier; |
| 65 | +} |
| 66 | + |
| 67 | +$a = new A; |
| 68 | +$doc = new TreeBuilderContext(); |
| 69 | +$t = new DoctypeToken(); |
| 70 | +$t->name = "html"; |
| 71 | +foreach ([$doc, $t] as $token) { |
| 72 | + $a->test($doc, $token); |
| 73 | +} |
| 74 | +?> |
| 75 | +DONE |
| 76 | +--EXPECT-- |
| 77 | +DONE |
0 commit comments