On Sat Dec 18 10:29 AM, Stefan Marr wrote: > At least I do not find an argument for either way that completely > convinces me. > At the moment, the main reason is that 'public' can be considered to > be the default visibility modifier. > Based on the semantics of 'var' and dynamic properties. > Thus, private tends to imply that an additional constraint was > consciously applied to the property, which should be preserved. > Well, but as I said, thats kind of arbitrary and if you look at the > inheritance rules and try to reason from the view of clients with > respect to the external interface, then going with public as the > chosen modifier also starts to sound reasonable... >
Does the order of the declaration matter? trait THello1 { public $foo; } trait THello2 { private $foo; } trait THello3 { protected $foo; } class TraitsTest { use THello1; use THello2; // E_NOTICE: TraitTest conflict, THello2(private $foo) ignored, already declared THello1(public $foo) use THello3; // E_NOTICE: TraitTest conflict, THello3(protected $foo) ignored, already declared THello1(public $foo) } class TraitsTest2 { use THello3; use THello2; // E_NOTICE: .. use THello1; // E_NOTICE: .. } It could be that the first property 'wins' and an E_NOTICE is raised about the property conflict. Result: class TraitsTest { public $foo; } class TraitsTest2 { protected $foo; } It would seem to fit php, though I'd be happy with simply E_FATAL until people start using traits The same for: trait THelloA { public $foo = 'a'; } trait THelloB { public $foo = 'b'; } class TraitsTest3 { use THelloA; use THelloB; // E_NOTICE: TraitTest3 conflict, THelloB(public $foo) ignored, already declared THelloA(public $foo) } class TraitsTest4 { use THelloB; use THelloA; // E_NOTICE: TraitTest3 conflict, THelloA(public $foo) ignored, already declared THelloB(public $foo) } class TraitsTest5 { public $foo = 'c'; use THelloB; // E_NOTICE: TraitTest3 conflict, THelloB(public $foo) ignored, already declared TraitsTest5(public $foo) use THelloA; // E_NOTICE: TraitTest3 conflict, THelloA(public $foo) ignored, already declared THelloB(public $foo) } -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php