1--TEST-- 2Test ReflectionProperty::setValue() error cases. 3--FILE-- 4<?php 5 6class TestClass { 7 public $pub; 8 public $pub2 = 5; 9 static public $stat = "static property"; 10 protected $prot = 4; 11 private $priv = "keepOut"; 12} 13 14class AnotherClass { 15} 16 17$instance = new TestClass(); 18$instanceWithNoProperties = new AnotherClass(); 19$propInfo = new ReflectionProperty('TestClass', 'pub2'); 20 21echo "\nProtected property:\n"; 22 23$propInfo = new ReflectionProperty('TestClass', 'prot'); 24$propInfo->setValue($instance, "NewValue"); 25var_dump($propInfo->getValue($instance)); 26 27echo "\n\nInstance without property:\n"; 28$propInfo = new ReflectionProperty('TestClass', 'pub2'); 29var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue")); 30var_dump($instanceWithNoProperties->pub2); 31?> 32--EXPECT-- 33Protected property: 34string(8) "NewValue" 35 36 37Instance without property: 38NULL 39string(8) "NewValue" 40