Friend class/function

From: Date: Sun, 01 Nov 2015 16:04:24 +0000
Subject: Friend class/function
Groups: php.internals 
Request: Send a blank email to internals+get-89024@lists.php.net to get a copy of this message
​Hi php internals, I recently discovered ​the "friendship concept" in c++ and i really love the concept. And i wonder if the php internals would be interested to implements it in the next 7.x major version. ​The concept is simple: It would allow declared "friend"​class method/function to call a private/protected member of an other class: The syntax could be like this (for a single friendship): private function extractDataFromCache() friend myFriendClass1 { } or like this for many friendships: private function extractDataFromCache() friend {myFriendClass1::method1, myFriendClass2::method1, myFriendClass3::method1} { } In this way extractDataFromCache() could be called directly by method1 in myFriendClass1 and myFriendClass2 etc.... Off course deep calling should not be allowed. (E.g a function inside myFriendClass1 that will call extractDataFromCache() won't inherit the friendship. Regards, Georges

« previous php.internals (#89024) next »