forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also adds some smaller, isolated tests related to bug 66622.
- Loading branch information
1 parent
3834385
commit f47976d
Showing
12 changed files
with
226 additions
and
5 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,22 @@ | ||
--TEST-- | ||
Closure 049: static::class in static closure in non-static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
function foo() { | ||
$f = static function() { | ||
return static::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
$b = new B; | ||
|
||
var_dump($b->foo()); | ||
--EXPECT-- | ||
string(1) "B" |
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,22 @@ | ||
--TEST-- | ||
Closure 050: static::class in non-static closure in non-static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
function foo() { | ||
$f = function() { | ||
return static::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
$b = new B; | ||
var_dump($b->foo()); | ||
|
||
--EXPECT-- | ||
string(1) "B" |
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-- | ||
Closure 051: static::class in static closure in static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
static function foo() { | ||
$f = static function() { | ||
return static::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
var_dump(B::foo()); | ||
|
||
--EXPECT-- | ||
string(1) "B" |
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-- | ||
Closure 052: static::class in non-static closure in static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
static function foo() { | ||
$f = function() { | ||
return static::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
var_dump(B::foo()); | ||
|
||
--EXPECT-- | ||
string(1) "B" |
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,22 @@ | ||
--TEST-- | ||
Closure 053: self::class in static closure in non-static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
function foo() { | ||
$f = static function() { | ||
return self::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
$b = new B; | ||
var_dump($b->foo()); | ||
|
||
--EXPECT-- | ||
string(1) "A" |
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,22 @@ | ||
--TEST-- | ||
Closure 054: self::class in non-static closure in non-static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
function foo() { | ||
$f = function() { | ||
return self::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
$b = new B; | ||
var_dump($b->foo()); | ||
|
||
--EXPECT-- | ||
string(1) "A" |
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-- | ||
Closure 055: self::class in static closure in static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
static function foo() { | ||
$f = static function() { | ||
return self::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
var_dump(B::foo()); | ||
|
||
--EXPECT-- | ||
string(1) "A" |
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-- | ||
Closure 056: self::class in non-static closure in static method. | ||
|
||
--FILE-- | ||
<?php | ||
|
||
class A { | ||
static function foo() { | ||
$f = function() { | ||
return self::class; | ||
}; | ||
return $f(); | ||
} | ||
} | ||
|
||
class B extends A {} | ||
|
||
var_dump(B::foo()); | ||
|
||
--EXPECT-- | ||
string(1) "A" |
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,37 @@ | ||
--TEST-- | ||
Bug 66622: Closures do not correctly capture the late bound class (static::) in some cases | ||
|
||
--FILE-- | ||
<?php | ||
class A { | ||
static function name() { return 'A'; } | ||
function foo() { | ||
$fn = function() { return static::name(); }; | ||
echo static::name() . ' vs ' . $fn() . "\n"; | ||
} | ||
function bar() { | ||
$fn = static function() { return static::name(); }; | ||
echo static::name() . ' vs ' . $fn() . "\n"; | ||
} | ||
static function baz() { | ||
$fn = function() { return static::name(); }; | ||
echo static::name() . ' vs ' . $fn() . "\n"; | ||
} | ||
} | ||
class B extends A { | ||
static function name() { return 'B'; } | ||
} | ||
|
||
function test() { | ||
(new B)->foo(); | ||
(new B)->bar(); | ||
(new B)->baz(); | ||
B::baz(); | ||
} | ||
test(); | ||
|
||
--EXPECT-- | ||
B vs B | ||
B vs B | ||
B vs B | ||
B vs B |
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