|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-06 22:29 UTC] michael at chunkycow dot com dot au
[2007-08-07 12:05 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 06:00:01 2025 UTC |
Description: ------------ Php should have a friend structure for classes, like c++. That way some normaly private things can be used by selected other classes and functions. An alternative would be to do it like Java with inner classes, but personaly I think that while inner classes could be usefull in php, friend classes should also exist like in c++. Reproduce code: --------------- <?php //my suggestion for the syntax class A { static function callB(B $b) { $b->privatefunction(); } } class B { friend class A; friend function C; private function privatefunction() { echo 'privatefunction!'; } } function C(B $b) { $b->privatefunction(); } $b=new B(); A::callB($b); C($b); Expected result: ---------------- Class A and function C should be able to call B::privatefunction. Actual result: -------------- Since this functionality doesn't exist the code wont even compile.