ID: 46949
Comment by: zyss at mail dot zp dot ua
Reported By: fatih at tullab dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: Windows+Linux
PHP Version: 5.3.0alpha3
New Comment:
Agree, much more convenient. Delphi rules :-)
Previous Comments:
------------------------------------------------------------------------
[2008-12-26 23:29:23] fatih at tullab dot com
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 this bug report at http://bugs.php.net/?id=46949&edit=1