-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed type inference that may cause JIT failure
PHP allows to override a method that returns non-reference with a method that returns a reference. This mean that we cannot use prototypes to predict return types of a child functions.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--TEST-- | ||
JIT RET: 004 Return a reference when it's not expected | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.file_update_protection=0 | ||
opcache.jit_buffer_size=32M | ||
--FILE-- | ||
<?php | ||
class A { | ||
function foo() { | ||
} | ||
function bar() { | ||
$x = $this->foo(); | ||
var_dump(str_repeat($x,5)); | ||
} | ||
} | ||
class B extends A { | ||
public $prop = "x"; | ||
function &foo() { | ||
return $this->prop; | ||
} | ||
} | ||
$b = new B; | ||
$b->bar(); | ||
?> | ||
--EXPECT-- | ||
string(5) "xxxxx" |