Req #34194 [Opn->Bgs]: Real properties in PHP classes
| From: | johannes@php.net | Date: | Wed, 22 Dec 2010 02:52:49 +0000 |
| Subject: | Req #34194 [Opn->Bgs]: Real properties in PHP classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157206@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=34194&edit=1
ID: 34194
Updated by: johannes@php.net
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