xref: /php-src/ext/opcache/tests/jit/gh15101.phpt (revision 53b329e2)
1--TEST--
2GH-15101: _ir_RSTORE: Assertion `ctx->control' failed
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.file_update_protection=0
9opcache.revalidate_freq=0
10opcache.protect_memory=1
11--FILE--
12<?php
13class 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}
33class Document {
34}
35final class TreeBuilderContext {
36    public $document;
37    public function __construct() {
38        $this->document = new Document;
39    }
40}
41abstract class Node {
42    public const DOCUMENT_TYPE_NODE = 10;
43
44    protected function __construct(Document $document, int $nodeType)
45    {
46    }
47}
48class 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}
61class 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";
71foreach ([$doc, $t] as $token) {
72	$a->test($doc, $token);
73}
74?>
75DONE
76--EXPECT--
77DONE
78