ID:               37814
 Updated by:       [EMAIL PROTECTED]
 Reported By:      henke dot andersson at comhem dot se
-Status:           Open
+Status:           Wont fix
 Bug Type:         Feature/Change Request
-Operating System: Linux Redhat 9
+Operating System: *
-PHP Version:      6CVS-2006-06-15 (CVS)
+PHP Version:      *
 New Comment:

We decided against those complex features.


Previous Comments:
------------------------------------------------------------------------

[2007-08-06 22:29:49] michael at chunkycow dot com dot au

The whole C++ friends thing is a mess, use an interface between your
super friendly classes and simply don`t use it if the classes aren`t
joined at the hip, this would even help to keep nice low coupling and
aid re-use.
Private inner classes have some merit but are not a cure for common
sense.

------------------------------------------------------------------------

[2006-06-15 10:33:27] henke dot andersson at comhem dot se

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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37814&edit=1

Reply via email to