PHP 4.0 Bug #5142: Allow properties and methods of a class to be declared as public or private
| From: | juhl at eisenstein dot dk | Date: | Tue, 20 Jun 2000 09:33:17 +0000 |
| Subject: | PHP 4.0 Bug #5142: Allow properties and methods of a class to be declared as public or private | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-21806@lists.php.net to get a copy of this message | ||
From: juhl@eisenstein.dk
Operating system: Linux
PHP version: 4.0.0 Release
PHP Bug Type: Feature/Change Request
Bug description: Allow properties and methods of a class to be declared as public or private
This is just a simple feature request.
I would like to be able to define methods and properties of a class as either public or private
(public could be the default if not specified, to maintain backwards compatibility with the current
syntax).
Being able to declare methods/properties as private to a class makes a lot of sense if many people
are sharing the same codebase and use classes they have not written themselves. If all properties
and/or methods of a class are public, then people could possibly set a property or call a method
that would cause the class to misbehave. I know this can be guarded against by programming the class
"defensively", and also that people could just read the class definition to learn its
proper use, but being able to just declare some parts of the class as private solves the above
problems nicely and easily.
A syntax such as the following would make sense to me:
class myClass
{
public {
var $myPublicProperty;
function myPublicMethod()
{
}
}
private {
var $myPrivateProperty;
function myPrivateMethod()
{
}
}
}
Please consider this :-)
Best regards
Jesper Juhl
juhl@eisenstein.dk