From a5e3210741d355d724c8569b0ee062d2fe17fc16 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 21 Oct 2024 16:57:11 +0200 Subject: [PATCH] Fix lineno for inheritance errors of early bound classes Fixes GH-16508 --- Zend/tests/gh16508.phpt | 20 ++++++++++++++++++++ Zend/zend_inheritance.c | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 Zend/tests/gh16508.phpt diff --git a/Zend/tests/gh16508.phpt b/Zend/tests/gh16508.phpt new file mode 100644 index 000000000000..e5b89b602904 --- /dev/null +++ b/Zend/tests/gh16508.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-16508: Missing lineno in inheritance errors of delayed early bound classes +--EXTENSIONS-- +opcache +--INI-- +opcache.enable_cli=1 +--FILE-- + +--EXPECTF-- +Fatal error: Class Test2 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Test::foo) in %s on line 5 diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 2e9bf25b59c4..8548d7fe3a01 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -3222,6 +3222,8 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_ CG(current_linking_class) = is_cacheable ? ce : NULL; zend_try{ + CG(zend_lineno) = ce->info.user.line_start; + if (is_cacheable) { zend_begin_record_errors(); }