-
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.
Closures will now use the called_scope from their instantiation site. If they are rebound either the class of $this is used or if no $this is provided the bound scope is used. With this change the scope for static closures can be changed back to use EG(scope) rather than EX(called_scope), thus fixing bug #69568.
- Loading branch information
Showing
6 changed files
with
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Bug #69568: call a private function in closure failed | ||
--FILE-- | ||
<?php | ||
class A { | ||
|
||
private static function testprivate() { | ||
return 1; | ||
} | ||
public static function test() { | ||
return function() { | ||
return self::testprivate(); | ||
}; | ||
} | ||
} | ||
|
||
class B extends A { | ||
} | ||
|
||
$fn = B::test(); | ||
echo $fn(); | ||
|
||
?> | ||
--EXPECT-- | ||
1 |
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,21 @@ | ||
--TEST-- | ||
Getting parent class name when there is no parent generates an error | ||
--FILE-- | ||
<?php | ||
|
||
trait T { | ||
public function f() { | ||
var_dump(parent::class); | ||
} | ||
} | ||
|
||
class C { | ||
use T; | ||
} | ||
|
||
(new C)->f(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Cannot use "parent" when current class scope has no parent in %s on line 5 | ||
|
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
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