diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 4b053feb5b6..d417ea9e364 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -1463,7 +1463,7 @@ ZEND_API int zend_inference_propagate_range(const zend_op_array *op_array, zend_ } call_info = func_info->call_map[opline - op_array->opcodes]; - if (!call_info) { + if (!call_info || call_info->is_prototype) { break; } if (call_info->callee_func->type == ZEND_USER_FUNCTION) { diff --git a/Zend/tests/prototype_range.phpt b/Zend/tests/prototype_range.phpt new file mode 100644 index 00000000000..a0addf4b6cc --- /dev/null +++ b/Zend/tests/prototype_range.phpt @@ -0,0 +1,24 @@ +--TEST-- +Range information from a prototype method should not be used +--FILE-- +getInt(); + } +} + +class Test2 extends Test { + public function getInt(): int { return 1; } +} + +$test2 = new Test2; +var_dump($test2->getInt2()); + +?> +--EXPECT-- +int(1)