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

 ID:                 34194
 Updated by:         [email protected]
 Reported by:        stochnagara at hotmail dot com
 Summary:            Real properties in PHP classes
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 PHP Version:        5CVS-2005-08-19 (CVS)
 Block user comment: N
 Private report:     N

 New Comment:

This request is covered by this RFC:
http://wiki.php.net/rfc/propertygetsetsyntax


Previous Comments:
------------------------------------------------------------------------
[2005-08-19 16:41:21] stochnagara at hotmail dot com

Description:
------------
I think that it would be nice to have real properties present in PHP. I
mean properties like those in C# but a little more flexible by allowing
getter and setter to have different visibility. See sample code below:



Reproduce code:
---------------
class person {

  public $firstName, $lastName;



  public getter fullName { // may also have ()

   return "{$this->firstName} {$this->lastName}";

  }



  public setter fullName ($value) { // may also not have ($value) but a
special var.

   list ($this->firstName, $this->lastName) = explode (' ', $value, 2);

  }

}



 $p = new person;

 $p->fullName = "Foo bar";

 echo $p->firstName . "\n";

 echo $p->lastName . "\n";

 echo $p->fullName . "\n";



Expected result:
----------------
Foo

bar

Foo bar

Actual result:
--------------
n/a


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



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

Reply via email to