Bug #5142 Updated: Allow properties and methods of a class to be declared as public or private

From: Date: Sat, 27 Apr 2002 17:34:47 +0000
Subject: Bug #5142 Updated: Allow properties and methods of a class to be declared as public or private
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-6244@lists.php.net to get a copy of this message
ID: 5142 Updated by: jimw@php.net Reported By: juhl@eisenstein.dk -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.0.0 Release New Comment: implemented in ZE2. Previous Comments: ------------------------------------------------------------------------ [2000-06-20 11:33:17] juhl@eisenstein.dk 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=5142&edit=1

« previous php.bugs (#6244) next »