Req #54019 [NEW]: synthesize class property setter/getter feature request
| From: | monte at ohrt dot com | Date: | Mon, 14 Feb 2011 17:40:41 +0000 |
| Subject: | Req #54019 [NEW]: synthesize class property setter/getter feature request | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-158772@lists.php.net to get a copy of this message | ||
From:
Operating system: n/a
PHP version: Irrelevant
Package: Unknown/Other Function
Bug Type: Feature/Change Request
Bug description:synthesize class property setter/getter feature request
Description:
------------
This is a take from the objective-c language, and may prove useful in
future
releases of PHP.
Currently, to generate generic setters/getters for class properties, this
must
be done manually in the class declaration:
class Foo {
public $bar
function bar() {
return $this->bar;
}
function setBar($val) {
$this->bar = $val;
}
}
This can be a tedious task when there are many properties, and clutter up
the
class. Using the __call() magic function for manual pseudo-synthesized
functions
is a complexity and extra wrapper call that could be avoided.
Feature request: the ability to have PHP automatically synthesize generic
setters/getters for properties. You would specify which properties are
synthesized. Syntax idea:
class Foo {
synthesize public $bar;
// bar() and setBar() are now automatically synthesized by PHP
}
Manual overrides to these synthesized methods are permissible, in case a
non-
generic method is required. This feature would greatly simplify
boiler-plate
setter/getter setup, and avoid the overhead of using __call() as a wrapper
to
create a manual psuedo-synthesize functionality. PHP IDE's would be able to
identify synthesized properties for auto-completion of available
setter/getter
methods.
--
Edit bug report at http://bugs.php.net/bug.php?id=54019&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54019&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54019&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54019&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54019&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54019&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54019&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54019&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54019&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54019&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54019&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54019&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54019&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54019&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54019&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54019&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54019&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54019&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54019&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54019&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54019&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54019&r=mysqlcfg