Browse Source
Merge branch 'PHP-5.5' into PHP-5.6
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Fix bug 666222 Fix bug 666222pull/702/head
12 changed files with 226 additions and 5 deletions
-
22Zend/tests/closure_049.phpt
-
22Zend/tests/closure_050.phpt
-
21Zend/tests/closure_051.phpt
-
21Zend/tests/closure_052.phpt
-
22Zend/tests/closure_053.phpt
-
22Zend/tests/closure_054.phpt
-
21Zend/tests/closure_055.phpt
-
21Zend/tests/closure_056.phpt
-
37Zend/tests/closure_bug66622.phpt
-
4Zend/zend_closures.c
-
9Zend/zend_vm_def.h
-
9Zend/zend_vm_execute.h
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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" |
|||
@ -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 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue