1--TEST-- 2Handling of private fields with traits needs to have same semantics as with normal inheritance. 3--FILE-- 4<?php 5error_reporting(E_ALL | E_STRICT); 6 7class BaseWithPropA { 8 private $hello = 0; 9} 10 11// This is how privates are handled in normal inheritance 12class SubclassClassicInheritance extends BaseWithPropA { 13 private $hello = 0; 14} 15 16// And here, we need to make sure, that the traits behave the same 17 18trait AHelloProperty { 19 private $hello = 0; 20} 21 22class BaseWithTPropB { 23 use AHelloProperty; 24} 25 26class SubclassA extends BaseWithPropA { 27 use AHelloProperty; 28} 29 30class SubclassB extends BaseWithTPropB { 31 use AHelloProperty; 32} 33 34$classic = new SubclassClassicInheritance; 35var_dump($classic); 36 37$a = new SubclassA; 38var_dump($a); 39 40$b = new SubclassB; 41var_dump($b); 42 43?> 44--EXPECTF-- 45object(SubclassClassicInheritance)#1 (2) { 46 ["hello":"SubclassClassicInheritance":private]=> 47 int(0) 48 ["hello":"BaseWithPropA":private]=> 49 int(0) 50} 51object(SubclassA)#2 (2) { 52 ["hello":"SubclassA":private]=> 53 int(0) 54 ["hello":"BaseWithPropA":private]=> 55 int(0) 56} 57object(SubclassB)#3 (2) { 58 ["hello":"SubclassB":private]=> 59 int(0) 60 ["hello":"BaseWithTPropB":private]=> 61 int(0) 62} 63