xref: /php-src/Zend/tests/gh9407.phpt (revision 6d596207)
1--TEST--
2GH-9407: LSP error in eval'd code refers to wrong class for static type
3--SKIPIF--
4<?php
5$tracing = extension_loaded("Zend OPcache")
6    && ($conf = opcache_get_configuration()["directives"])
7    && array_key_exists("opcache.jit", $conf)
8    &&  $conf["opcache.jit"] === "tracing";
9if (PHP_OS_FAMILY === "Windows" && PHP_INT_SIZE == 8 && $tracing) {
10    $url = "https://github.com/php/php-src/pull/14919#issuecomment-2259003979";
11    die("xfail Test fails on Windows x64 (VS17) and tracing JIT; see $url");
12}
13?>
14--FILE--
15<?php
16
17class A {
18    public function duplicate(): static {}
19}
20
21class C {
22    public static function generate() {
23        eval(<<<PHP
24            class B extends A {
25                public function duplicate(): A {}
26            }
27        PHP);
28    }
29}
30
31C::generate();
32
33?>
34--EXPECTF--
35Fatal error: Declaration of B::duplicate(): A must be compatible with A::duplicate(): static in %s : eval()'d code on line %d
36