#50589 [NEW]: Feature request: Short way for multiple set of class properties

From: Date: Mon, 28 Dec 2009 12:34:25 +0000
Subject: #50589 [NEW]: Feature request: Short way for multiple set of class properties
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146151@lists.php.net to get a copy of this message
From: toorion at gmail dot com Operating system: All PHP version: 5.3.2RC1 PHP Bug Type: Feature/Change Request Bug description: Feature request: Short way for multiple set of class properties Description: ------------ Background: Wery often set plenty of properties together is necessary. So, for traditional way it is requre many of copy-paste action and produce much of code. Actualy, excellent way for that - short syntax of class property settings. Reproduce code: --------------- Unliked case: $myLongNameObject = new MyLongNameObject(); $myLongNameObject->property1 = '11111'; $myLongNameObject->property2 = '22222'; $myLongNameObject->property3 = '33333'; $myLongNameObject->property4 = '44444'; $myLongNameObject->property5 = '55555'; ... Match worse (sometime necessary): $myLongNameObject = new MyLongNameObject(); // Proxy pattern $myLongNameObject->insideObject->propertyOne = '1111'; $myLongNameObject->insideObject->propertyTwo = '2222'; $myLongNameObject->insideObject->propertyThree = '3334'; $myLongNameObject->insideObject->propertyFour = '4444'; ... Expected result: ---------------- More likely way: $MyLongNameObject = new MyLongNameObject() { $property1 = '1111'; $property2 = '2222'; $property3 = '4444'; $property4 = '5555'; } Or: $MyLongNameObject = new MyLongNameObject() { $insideObject = { $propertyOne = '1111'; $propertyTwo = '2222'; $propertyThree = '3333'; $propertyFour = '4444'; } } Something like this looks better :) Actual result: -------------- Now i use array and class constructor for avoid plenty of code: $MyLongNameObject = new MyLongNameObject( array( 'property1' = '1111', 'property2' = '2222', 'property3' = '3333', 'property4' = '4444' )); But, has many complications: - Cannot initialize properties of nested object - Reduce productivity - Cannot work with IDE Code Completion like in PhpEd, NetBeans, Eclipse.... - Don't work with already initialized object. -- Edit bug report at http://bugs.php.net/?id=50589&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50589&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50589&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50589&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50589&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50589&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50589&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50589&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50589&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50589&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50589&r=support Expected behavior: http://bugs.php.net/fix.php?id=50589&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50589&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50589&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50589&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50589&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50589&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50589&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50589&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50589&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50589&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50589&r=mysqlcfg

« previous php.bugs (#146151) next »