#37814 [NEW]: Php shoul have class friends
| From: | henke dot andersson at comhem dot se | Date: | Thu, 15 Jun 2006 10:33:27 +0000 |
| Subject: | #37814 [NEW]: Php shoul have class friends | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-98388@lists.php.net to get a copy of this message | ||
From: henke dot andersson at comhem dot se
Operating system: Linux Redhat 9
PHP version: 6CVS-2006-06-15 (CVS)
PHP Bug Type: Class/Object related
Bug description: Php shoul have class friends
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 bug report at http://bugs.php.net/?id=37814&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37814&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37814&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37814&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37814&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37814&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37814&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37814&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37814&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37814&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37814&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37814&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37814&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37814&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37814&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37814&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37814&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37814&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37814&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37814&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37814&r=mysqlcfg