Req #53229 [NEW]: Change of getters and setters

From: Date: Tue, 02 Nov 2010 19:44:30 +0000
Subject: Req #53229 [NEW]: Change of getters and setters
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155716@lists.php.net to get a copy of this message
From:             
Operating system: 
PHP version:      Irrelevant
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Change of getters and setters

Description:
------------
It would be very usefull to have getters in a way like c#.

Example:

Class Test {
  private $_a;
  private $_b;

  public function get a() {
    return $this->_a;
  }
}

this way the private $_b isn't available to the outside world which is the
case with out of the box __get.

It also (in my opinion) gives your code a much cleaner look and you can do
special things if needed in your functions too.

in the __get function you'll have to make if statements or other checks to
get the same result.

You can also just use:

Example:

Class Test {
  private $_a;
  private $_b;

  public function a() {
    return $this->_a;
  }
}

but then you would have to use:
$test->a() instead of $test->a which gives a wrong assumption that you are
calling a function which you are not, you are calling a property of your
object.


-- 
Edit bug report at http://bugs.php.net/bug.php?id=53229&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=53229&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=53229&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=53229&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=53229&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53229&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=53229&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=53229&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=53229&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=53229&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=53229&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=53229&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=53229&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=53229&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=53229&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53229&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53229&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=53229&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=53229&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=53229&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=53229&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=53229&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#155716) next »