1--TEST-- 2Bug #71018 (ReflectionProperty::setValue() behavior changed) 3--FILE-- 4<?php 5class T1 { 6 public static $data; 7 8 public static function getDataBySelf() 9 { 10 return self::$data; 11 } 12 13 public static function getDataByStatic() 14 { 15 return static::$data; 16 } 17} 18 19class T2 extends T1 {} 20 21$Prop1 = new ReflectionProperty(T1::class, 'data'); 22$Prop2 = new ReflectionProperty(T2::class, 'data'); 23 24// #1 25// prints: hello, hello in PHP5, but world, hello in PHP7 - not OK 26$Prop1->setValue(\T1::class, "world"); 27$Prop2->setValue(\T2::class, 'hello'); 28var_dump("T2::self = " . T2::getDataBySelf()); 29var_dump("T2::static = " . T2::getDataByStatic()); 30 31set_error_handler(function ($severity, $message, $file, $line) { 32 throw new Exception($message); 33}); 34try { 35 $Prop2->setValue(\T2::class, 'hi'); 36} catch (Exception $e) { 37 echo $e->getMessage() . "\n"; 38} 39 40var_dump("T2::self = " . T2::getDataByStatic()); 41 42// #2 43// prints: hello, hello in both PHP5 and PHP7 - OK 44T1::$data = "world"; 45T2::$data = 'hello'; 46 47var_dump("T2::self = " . T2::getDataBySelf()); 48var_dump("T2::static = " . T2::getDataByStatic()); 49?> 50--EXPECTF-- 51Deprecated: Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated in %s on line %d 52 53Deprecated: Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated in %s on line %d 54string(16) "T2::self = hello" 55string(18) "T2::static = hello" 56Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated 57string(16) "T2::self = hello" 58string(16) "T2::self = hello" 59string(18) "T2::static = hello" 60