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

 ID:                 46949
 Updated by:         ras...@php.net
 Reported by:        fatih at tullab dot com
 Summary:            New "property" keyword token
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Windows+Linux
 PHP Version:        5.3.0alpha3
-Assigned To:        
+Assigned To:        rasmus
 Block user comment: N
 Private report:     N

 New Comment:

Seems to me that __get/__set accomplishes the same thing.


Previous Comments:
------------------------------------------------------------------------
[2008-12-29 20:33:38] zyss at mail dot zp dot ua

Agree, much more convenient. Delphi rules :-)

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=46949&edit=1

Reply via email to