????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.37 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/reflection/tests/ |
Upload File : |
--TEST--
Test ReflectionProperty::setValue() error cases.
--FILE--
<?php
class TestClass {
public $pub;
public $pub2 = 5;
static public $stat = "static property";
protected $prot = 4;
private $priv = "keepOut";
}
class AnotherClass {
}
$instance = new TestClass();
$instanceWithNoProperties = new AnotherClass();
$propInfo = new ReflectionProperty('TestClass', 'pub2');
echo "Too few args:\n";
var_dump($propInfo->setValue());
var_dump($propInfo->setValue($instance));
echo "\nToo many args:\n";
var_dump($propInfo->setValue($instance, "NewValue", true));
echo "\nWrong type of arg:\n";
var_dump($propInfo->setValue(true, "NewValue"));
$propInfo = new ReflectionProperty('TestClass', 'stat');
echo "\nStatic property / too many args:\n";
var_dump($propInfo->setValue($instance, "NewValue", true));
echo "\nStatic property / too few args:\n";
var_dump($propInfo->setValue("A new value"));
var_dump(TestClass::$stat);
var_dump($propInfo->setValue());
var_dump(TestClass::$stat);
echo "\nStatic property / wrong type of arg:\n";
var_dump($propInfo->setValue(true, "Another new value"));
var_dump(TestClass::$stat);
echo "\nProtected property:\n";
try {
$propInfo = new ReflectionProperty('TestClass', 'prot');
var_dump($propInfo->setValue($instance, "NewValue"));
}
catch(Exception $exc) {
echo $exc->getMessage();
}
echo "\n\nInstance without property:\n";
$propInfo = new ReflectionProperty('TestClass', 'pub2');
var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue"));
var_dump($instanceWithNoProperties->pub2);
?>
--EXPECTF--
Too few args:
Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d
NULL
Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 1 given in %s on line %d
NULL
Too many args:
Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d
NULL
Wrong type of arg:
Warning: ReflectionProperty::setValue() expects parameter 1 to be object, boolean given in %s on line %d
NULL
Static property / too many args:
Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 3 given in %s on line %d
NULL
Static property / too few args:
NULL
string(11) "A new value"
Warning: ReflectionProperty::setValue() expects exactly 2 parameters, 0 given in %s on line %d
NULL
string(11) "A new value"
Static property / wrong type of arg:
NULL
string(17) "Another new value"
Protected property:
Cannot access non-public member TestClass::prot
Instance without property:
NULL
string(8) "NewValue"