RE: [PHP-DEV] C# properties vs. accessors RFC
| From: | nathan at starin dot biz | Date: | Wed, 23 Jan 2013 20:43:56 +0000 |
| Subject: | RE: [PHP-DEV] C# properties vs. accessors RFC | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65122@lists.php.net to get a copy of this message | ||
>Personally, I don't see why 'default' can't be used:
>class Foo {
> public $bar { get; set; default 5; } }
>
>This solves the var_dump() problem, and if people want dynamic get
returning something other than the property/field value, so be it.
>C# does indeed have an internal field per property though, even if it is an
anonymous backing field.
Is there a reason we cannot just have var_dump/print_r show it more like
this?
object(Time)#1 (2) {
["seconds"]=>
int(16200)
["hours"]=>
NULL
["hours:getter"]=>
float(4.5)
}
(Although I am against the idea of having a *hidden* value accessible inside
the getter/setter)