| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2011-02-14 19:09 UTC] monte at ohrt dot com
  [2015-03-20 15:11 UTC] levim@php.net
 
-Status:  Open
+Status:  Duplicate
-Package: Unknown/Other Function
+Package: *General Issues
  [2015-03-20 15:11 UTC] levim@php.net
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 09:00:01 2025 UTC | 
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.