- 添加 Bug #21094 关于 set_error_handler 不接受方法的测试 - 添加 Bug #21961 关于 get_parent_class() 段错误的测试 - 添加 Bug #23624 关于 foreach 留下当前数组键为 null 的测试 - 添加 Bug #26869 关于常量作为静态数组键的测试 - 添加 Bug #30726 关于 -.1 类似数字处理不当的测试 - 添加 Cannot re-assign $this 的测试用例和相关代码文件 - 更新编译器默认原生类型设置为 true - 添加 strlen 函数调用优化处理pull/1/head
parent
a8483af474
commit
c53e7afdb5
10 changed files with 140 additions and 1 deletions
@ -0,0 +1,15 @@ |
||||
<?php |
||||
class Foo { |
||||
function Bar() { |
||||
$__this = $this; |
||||
$this = null; |
||||
debug_backtrace(); |
||||
$this = $__this; |
||||
} |
||||
} |
||||
|
||||
function main() { |
||||
$f = new Foo; |
||||
$f->Bar(); |
||||
echo "OK\n"; |
||||
} |
||||
@ -0,0 +1,10 @@ |
||||
<?php |
||||
|
||||
class ClassTest extends \BaseTest |
||||
{ |
||||
public function testReAssignThis() |
||||
{ |
||||
$this->exec('Cannot re-assign $this', 're-assign-this.php'); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,17 @@ |
||||
--TEST-- |
||||
Bug #21094 (set_error_handler not accepting methods) |
||||
--FILE-- |
||||
<?php |
||||
class test { |
||||
function hdlr($errno, $errstr, $errfile, $errline) { |
||||
printf("[%d] errstr: %s, errfile: %s, errline: %d\n", $errno, $errstr, $errfile, $errline, $errstr); |
||||
} |
||||
} |
||||
|
||||
function main() { |
||||
set_error_handler(array(new test(), "hdlr")); |
||||
trigger_error("test"); |
||||
} |
||||
?> |
||||
--EXPECTF-- |
||||
[1024] errstr: test, errfile: %s, errline: %d |
||||
@ -0,0 +1,58 @@ |
||||
--TEST-- |
||||
Bug #21961 (get_parent_class() segfault) |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class man |
||||
{ |
||||
public $name, $bars; |
||||
function __construct() |
||||
{ |
||||
$this->name = 'Mr. X'; |
||||
$this->bars = array(); |
||||
} |
||||
|
||||
function getdrunk($where) |
||||
{ |
||||
$this->bars[] = new bar($where); |
||||
} |
||||
|
||||
function getName() |
||||
{ |
||||
return $this->name; |
||||
} |
||||
} |
||||
|
||||
class bar extends man |
||||
{ |
||||
public $name; |
||||
|
||||
function __construct($w) |
||||
{ |
||||
$this->name = $w; |
||||
} |
||||
|
||||
function getName() |
||||
{ |
||||
return $this->name; |
||||
} |
||||
|
||||
function whosdrunk() |
||||
{ |
||||
$who = get_parent_class($this); |
||||
if($who == NULL) |
||||
{ |
||||
return 'nobody'; |
||||
} |
||||
return eval("return ".$who.'::getName();'); |
||||
} |
||||
} |
||||
|
||||
function main() { |
||||
$x = new man; |
||||
$x->getdrunk('The old Tavern'); |
||||
var_dump($x->bars[0]->whosdrunk()); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(14) "The old Tavern" |
||||
@ -0,0 +1,12 @@ |
||||
--TEST-- |
||||
Bug #23624 (foreach leaves current array key as null) |
||||
--FILE-- |
||||
<?php |
||||
$arr = array ('one', 'two', 'three'); |
||||
var_dump(current($arr)); |
||||
foreach($arr as $key => $value); |
||||
var_dump(current($arr)); |
||||
?> |
||||
--EXPECT-- |
||||
string(3) "one" |
||||
string(3) "one" |
||||
@ -0,0 +1,15 @@ |
||||
--TEST-- |
||||
Bug #26869 (constant as the key of static array) |
||||
--FILE-- |
||||
<?php |
||||
define("A", "1"); |
||||
static $a=array(A => 1); |
||||
var_dump($a); |
||||
var_dump(isset($a[A])); |
||||
?> |
||||
--EXPECT-- |
||||
array(1) { |
||||
[1]=> |
||||
int(1) |
||||
} |
||||
bool(true) |
||||
@ -0,0 +1,8 @@ |
||||
--TEST-- |
||||
Bug #30726 (-.1 like numbers are not being handled correctly) |
||||
--FILE-- |
||||
<?php |
||||
echo (int) is_float('-.1' * 2), "\n"; |
||||
?> |
||||
--EXPECT-- |
||||
1 |
||||
Loading…
Reference in new issue