-
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.
Backport preloading trait fixup fixes
This cherry-picks 33969c2 and 2effbfd from PHP-8.0. The issues these commits fix could also manifest in PHP 7.4, and a commenter on bug #80307 reports this this might indeed be happening.
- Loading branch information
Showing
3 changed files
with
69 additions
and
19 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,33 @@ | ||
<?php | ||
|
||
trait T1 { | ||
public function method() { | ||
// Needs to be optimized somehow. | ||
$str = "Foo"; | ||
echo "$str\n"; | ||
} | ||
} | ||
|
||
trait T2 {} | ||
|
||
class C1 { | ||
use T1; | ||
} | ||
|
||
class C2 extends C1 { | ||
use T2; | ||
} | ||
|
||
trait T3 { | ||
public function method() { | ||
// Prevent trivial inheritance. | ||
static $x; | ||
// Needs to be optimized somehow. | ||
$str = "Foo"; | ||
echo "$str\n"; | ||
} | ||
} | ||
class C3 { | ||
use T3; | ||
} | ||
class C4 extends C3 {} |
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,20 @@ | ||
--TEST-- | ||
Op array fixed up multiple times during preloading | ||
--INI-- | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.optimization_level=-1 | ||
opcache.preload={PWD}/preload_trait_multiple_fixup.inc | ||
--SKIPIF-- | ||
<?php | ||
require_once('skipif.inc'); | ||
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows'); | ||
?> | ||
--FILE-- | ||
<?php | ||
(new C2)->method(); | ||
(new C4)->method(); | ||
?> | ||
--EXPECT-- | ||
Foo | ||
Foo |