- 在ClassDef中添加ctorInit、ctorClean属性和propertyContext - 修改编译器在对象创建时执行属性初始化代码 - 添加对默认数组属性的支持和测试 - 实现属性上下文管理以正确处理构造函数逻辑 - 更新预处理器和翻译器以支持新的属性处理机制 - 添加property_exists函数的相关测试用例pull/1/head
parent
fbb68ad689
commit
34e112d697
7 changed files with 139 additions and 7 deletions
@ -0,0 +1,44 @@ |
|||||||
|
--TEST-- |
||||||
|
default array property |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class Test { |
||||||
|
public $empty = array(); |
||||||
|
public $three = array(1, "b"=>"c", 3=>array()); |
||||||
|
|
||||||
|
function bar() { |
||||||
|
echo __METHOD__; |
||||||
|
} |
||||||
|
|
||||||
|
public $four = array('hello' => 'world', 'bar', ); |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
$obj = new Test; |
||||||
|
var_dump(get_object_vars($obj)); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
array(3) { |
||||||
|
["empty"]=> |
||||||
|
array(0) { |
||||||
|
} |
||||||
|
["three"]=> |
||||||
|
array(3) { |
||||||
|
[0]=> |
||||||
|
int(1) |
||||||
|
["b"]=> |
||||||
|
string(1) "c" |
||||||
|
[3]=> |
||||||
|
array(0) { |
||||||
|
} |
||||||
|
} |
||||||
|
["four"]=> |
||||||
|
array(2) { |
||||||
|
["hello"]=> |
||||||
|
string(5) "world" |
||||||
|
[0]=> |
||||||
|
string(3) "bar" |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
--TEST-- |
||||||
|
Testing property_exists() |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class aParent { |
||||||
|
public static function staticTest() { |
||||||
|
$a = new A; |
||||||
|
var_dump(property_exists($a, "prot")); |
||||||
|
var_dump(property_exists($a, "prot2")); |
||||||
|
var_dump(property_exists($a, "prot3")); |
||||||
|
print "------------------\n"; |
||||||
|
var_dump(property_exists("A", "prot")); |
||||||
|
var_dump(property_exists("A", "prot2")); |
||||||
|
var_dump(property_exists("A", "prot3")); |
||||||
|
print "------------------\n"; |
||||||
|
} |
||||||
|
public function nonstaticTest() { |
||||||
|
$a = new A; |
||||||
|
var_dump(property_exists($a, "prot")); |
||||||
|
var_dump(property_exists($a, "prot2")); |
||||||
|
var_dump(property_exists($a, "prot3")); |
||||||
|
print "------------------\n"; |
||||||
|
var_dump(property_exists("A", "prot")); |
||||||
|
var_dump(property_exists("A", "prot2")); |
||||||
|
var_dump(property_exists("A", "prot3")); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class A extends aParent { |
||||||
|
static public $prot = "prot"; |
||||||
|
static protected $prot2 = "prot"; |
||||||
|
static private $prot3 = "prot"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
function main() { |
||||||
|
A::staticTest(); |
||||||
|
|
||||||
|
$a = new a; |
||||||
|
$a->nonstaticTest(); |
||||||
|
} |
||||||
|
|
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
------------------ |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
------------------ |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
------------------ |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
|
bool(true) |
||||||
Loading…
Reference in new issue