我正在創建一個新的ReflectionClass
,然後將受保護的屬性_products
設置爲可訪問。它總是返回null
我在這裏做錯了什麼?我在5.4.11爲什麼getProperty通過PHP ReflectionClass返回null
$project = new ReflectionClass($instance_of_object);
$property = $project->getProperty('_products');
$property->setAccessible(true);
$products = $property->getValue($project);
我想,以確保財產在我的單元測試正確設置...
編輯有答案以上:) 5.4.11 – 2013-04-24 23:03:29
你** **肯定的屬性不是'null' ? – hek2mgl 2013-04-24 23:04:19
你有涉及的任何命名空間嗎? – bestprogrammerintheworld 2013-04-24 23:06:33