mirror of
https://github.com/php/php-src.git
synced 2025-01-08 12:04:24 +08:00
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix lsp error in eval'd code referring to incorrect class for static type
This commit is contained in:
commit
580c29e1a2
24
Zend/tests/gh9407.phpt
Normal file
24
Zend/tests/gh9407.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
GH-9407: LSP error in eval'd code refers to wrong class for static type
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A {
|
||||
public function duplicate(): static {}
|
||||
}
|
||||
|
||||
class C {
|
||||
public static function generate() {
|
||||
eval(<<<PHP
|
||||
class B extends A {
|
||||
public function duplicate(): A {}
|
||||
}
|
||||
PHP);
|
||||
}
|
||||
}
|
||||
|
||||
C::generate();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Declaration of B::duplicate(): A must be compatible with A::duplicate(): static in %s : eval()'d code on line %d
|
@ -1259,7 +1259,8 @@ zend_string *zend_type_to_string_resolved(zend_type type, zend_class_entry *scop
|
||||
}
|
||||
if (type_mask & MAY_BE_STATIC) {
|
||||
zend_string *name = ZSTR_KNOWN(ZEND_STR_STATIC);
|
||||
if (scope) {
|
||||
// During compilation of eval'd code the called scope refers to the scope calling the eval
|
||||
if (scope && !zend_is_compiling()) {
|
||||
zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data));
|
||||
if (called_scope) {
|
||||
name = called_scope->name;
|
||||
|
Loading…
Reference in New Issue
Block a user