Re: Class Friendship in PHP

From: Date: Tue, 08 Dec 2015 11:01:34 +0000
Subject: Re: Class Friendship in PHP
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-89737@lists.php.net to get a copy of this message
Hi, Thanks for this interesting and well-documented message. When looking at the history about class friendship, you may have seen that the concept was globally rejected in favor of Guilherme's project of 'package-privacy'. I personnally think friend classes are a different and more powerful concept and, if you feel strong enough to write and defend an RFC and defend it, I encourage you to go on. These are details: - I would prefer providing the same access to friend classes as parents and descendants : that is allow 'protected' but keep private reserved to the class. This way, when looking at the class code, you know that private data cannot be accessed, even by friends. - I would extend the syntax to namespaces. For examples, '\MyNS\' (syntax to dicuss) would declare every class in the '\MyNS' namespaces or sub-namespaces as friends. Must support 'friend __NAMESPACE__' or something equivalent. This, coupled with a protected __construct() method would provide something quite similar to package-private access, but more extensible and powerful. Regards François

« previous php.internals (#89737) next »