On Sat, Jul 7, 2018 at 5:26 AM Dustin Wheeler <mdwhe...@ncsu.edu> wrote:

> Hello,
>
> I've let this RFC linger for a long time and finally wrapped up the
> remaining administrative items to put it to vote. This has been
> discussed a few times in the past:
>
> https://externals.io/message/89732
> https://externals.io/message/90311
>
> I would like to open the vote for an RFC to support Class Friendship in
> PHP:
>
> https://wiki.php.net/rfc/friend-classes
>
> The vote ends 2018-07-13 21:00 UTC.
>
>
"Friend" is powerful feature when classes are required to have "tight
coupling",
even if "tight coupling" is bad thing to have in general.

Most obvious use case is "testing classes".
Tests require tight coupling because tests have to know and test class
internals
to perform detailed tests.

With "friend", we can remove A LOT of access methods solely for testing
class.
Less codes means less complexity. Having many codes for tests in production
classes does not make much sense also. Having a lot of getter/setter
methods
for testing is pain and this fact leads developers to write inferior tests.

"Friend" makes UNIT test and Contract Programming much simpler and easier.
Therefore, it helps to develop more robust apps.

Obvious risk is "friend abuse" where "tight coupling" isn't required nor
useful.
Big warning in the doc would be enough to prevent users from shooting their
own foot. There are features like "friend", e.g. $GLOBALS

I understand concerns, however simpler/cleaner production classes without
test only methods and having detailed tests is worth to have.

 I would like to vote to "yes".
However, RFC does not have benchmark result. Do you have some results?

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

Reply via email to