#46949 [Com]: New "property" keyword token

From: Date: Mon, 29 Dec 2008 20:33:39 +0000
Subject: #46949 [Com]: New "property" keyword token
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132392@lists.php.net to get a copy of this message
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

« previous php.bugs (#132392) next »