- 添加 bug27443 测试:验证 defined() 函数返回正确的布尔类型 - 添加 bug27535 测试:验证循环引用对象不会导致崩溃问题 - 添加 bug29944 测试:验证 switch 语句中定义函数的功能正常 - 添加 bug30578 测试:验证析构函数调用时机与输出缓冲区处理pull/1/head
parent
27060d9b87
commit
60298d9461
4 changed files with 86 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||||||
|
--TEST-- |
||||||
|
Bug #27443 (defined() returns wrong type) |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
echo gettype(defined('test')); |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
boolean |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
--TEST-- |
||||||
|
Bug #27535 (Objects pointing to each other cause Apache to crash) |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class Class1 |
||||||
|
{ |
||||||
|
public $_Class2_obj; |
||||||
|
} |
||||||
|
|
||||||
|
class Class2 |
||||||
|
{ |
||||||
|
public $storage = ''; |
||||||
|
|
||||||
|
function __construct() |
||||||
|
{ |
||||||
|
$this->storage = new Class1(); |
||||||
|
|
||||||
|
$this->storage->_Class2_obj = $this; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
$foo = new Class2(); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
--TEST-- |
||||||
|
Bug #29944 (function defined in switch crashes PHP) |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
function foo($bar) { |
||||||
|
if (preg_match('/\d/', $bar)) return true; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
$a = 1; |
||||||
|
$b = "1"; |
||||||
|
switch ($a) { |
||||||
|
case 1: |
||||||
|
echo foo($b); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
1 |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
--TEST-- |
||||||
|
Bug #30578 (Output buffers flushed before calling __destruct functions) |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class Example |
||||||
|
{ |
||||||
|
function __construct() |
||||||
|
{ |
||||||
|
ob_start(); |
||||||
|
echo "This should be displayed last.\n"; |
||||||
|
} |
||||||
|
|
||||||
|
function __destruct() |
||||||
|
{ |
||||||
|
$buffered_data = ob_get_contents(); |
||||||
|
ob_end_clean(); |
||||||
|
|
||||||
|
echo "This should be displayed first.\n"; |
||||||
|
echo "Buffered data: $buffered_data"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
error_reporting(E_ALL); |
||||||
|
$obj = new Example; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
This should be displayed first. |
||||||
|
Buffered data: This should be displayed last. |
||||||
Loading…
Reference in new issue