002.phpt
来自「PHP v6.0 For Linux 运行环境:Win9X/ WinME/ Wi」· PHPT 代码 · 共 79 行
PHPT
79 行
--TEST--
Reflection properties are read only
--SKIPIF--
<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class ReflectionMethodEx extends ReflectionMethod
{
public $foo = "xyz";
function __construct($c,$m)
{
echo __METHOD__ . "\n";
parent::__construct($c,$m);
}
}
$r = new ReflectionMethodEx('ReflectionMethodEx','getName');
var_dump($r->class);
var_dump($r->name);
var_dump($r->foo);
@var_dump($r->bar);
try
{
$r->class = 'bullshit';
}
catch(ReflectionException $e)
{
echo $e->getMessage() . "\n";
}
try
{
$r->name = 'bullshit';
}
catch(ReflectionException $e)
{
echo $e->getMessage() . "\n";
}
$r->foo = 'bar';
$r->bar = 'baz';
var_dump($r->class);
var_dump($r->name);
var_dump($r->foo);
var_dump($r->bar);
?>
===DONE===
--EXPECTF--
ReflectionMethodEx::__construct
string(18) "ReflectionMethodEx"
string(7) "getName"
string(3) "xyz"
NULL
Cannot set read-only property ReflectionMethodEx::$class
Cannot set read-only property ReflectionMethodEx::$name
string(18) "ReflectionMethodEx"
string(7) "getName"
string(3) "bar"
string(3) "baz"
===DONE===
--UEXPECTF--
ReflectionMethodEx::__construct
unicode(18) "ReflectionMethodEx"
unicode(7) "getName"
unicode(3) "xyz"
NULL
Cannot set read-only property ReflectionMethodEx::$class
Cannot set read-only property ReflectionMethodEx::$name
unicode(18) "ReflectionMethodEx"
unicode(7) "getName"
unicode(3) "bar"
unicode(3) "baz"
===DONE===
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?