Edit report at http://bugs.php.net/bug.php?id=50589&edit=1
ID: 50589 Updated by: [email protected] Reported by: toorion at gmail dot com Summary: Feature request: Short way for multiple set of class properties -Status: Open +Status: Wont fix Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: All PHP Version: 5.3.2RC1 Block user comment: N Private report: N New Comment: Use arrays instead. Previous Comments: ------------------------------------------------------------------------ [2010-01-05 14:00:31] toorion at gmail dot com Actualy not a $insideObject = { $propertyOne = '1111'; $propertyTwo = '2222'; $propertyThree = '3333'; $propertyFour = '4444'; } it seems like store data to object, but only few properties neccesary to set: $insideObject->{ $propertyOne = '1111'; $propertyTwo = '2222'; $propertyThree = '3333'; $propertyFour = '4444'; } ------------------------------------------------------------------------ [2009-12-28 12:34:24] toorion at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=50589&edit=1
