Don't use range information from a prototype method

The method may be overridden.
This commit is contained in:
Nikita Popov 2021-04-12 10:30:04 +02:00
parent 70bb12feec
commit 6bd46d2f68
2 changed files with 25 additions and 1 deletions

View file

@ -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) {

View file

@ -0,0 +1,24 @@
--TEST--
Range information from a prototype method should not be used
--FILE--
<?php
class Test
{
public function getInt(): int { return 0; }
public function getInt2() {
return $this->getInt();
}
}
class Test2 extends Test {
public function getInt(): int { return 1; }
}
$test2 = new Test2;
var_dump($test2->getInt2());
?>
--EXPECT--
int(1)