#46949 [NEW]: New "property" keyword token
| From: | fatih at tullab dot com | Date: | Fri, 26 Dec 2008 23:29:24 +0000 |
| Subject: | #46949 [NEW]: New "property" keyword token | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-132323@lists.php.net to get a copy of this message | ||
From: fatih at tullab dot com
Operating system: Windows+Linux
PHP version: 5.3.0alpha3
PHP Bug Type: Feature/Change Request
Bug description: New "property" keyword token
Description:
------------
Hi,
It is hard to write and read this getter and setter codes:
private $_aProperty = "";
public getAProperty(){
return $this->_aProperty;
}
public setAProperty($value){
$this->_aProperty = $value;
}
And if we want to use this getter and setter, we will write like this:
$value = $anObject->getAProperty();
$anObject->setAProperty("something");
It is hard to read and confusing because of "set" and "get" prefixes.
But if we have a "property" keyword, we can use same name without "get"
and "set" prefixes.
class AClass
{
private $_name;
protected getName(){
return $this->_name;
}
protected setName($value){
$this->_name = $value
}
/*****/
public property Name get getName set setName;
/*****/
}
anObject = new AClass();
anObject->Name = "something"; //triggering setName function.
echo anObject->Name; //triggering getName function.
Regards..
--
Edit bug report at http://bugs.php.net/?id=46949&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46949&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46949&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46949&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46949&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46949&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46949&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46949&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46949&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46949&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46949&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46949&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46949&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46949&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46949&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46949&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46949&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46949&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46949&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46949&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46949&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46949&r=mysqlcfg