Hi everyone, I've got an idea for an RFC proposal and from reading the instructions it looks like I should run it past you guys first.
I have not made any contributions to PHP before although I have made some custom modifications in house in the past and while I'm no longer familiar with the PHP code base I am confident I have the skills to implement this should it be accepted. What I want to propose is a new assignment operator which rather than setting the variable to completely new value it would update the value while maintaining the type. The main motivation for this is for easy assignment to value objects aka assignment operator overloading via a magic method (prehaps called __assign). Here is an example ( for now I will use the PASCAL style assignment operator := as the new operator as it is a know assignment operator and currently not used in PHP): // For a class defined like so... class MoneyValue { protected $amount; public function __assign($value) { $this->amount = $value; } } // The amount could then be assigned using the new operator like this $price = new MoneyValue(); $price := 29.99; While the primary focus would be for assignment operator overloading as I just displayed in the previous example, for consistency it could be used with scalar values to preserve type like so: // $str is now a string $str = 'Original String'; // Using the new assignment variable would cast the value being assigned to the variable's type // (in this case a string). So $str := 7; // Would be the equivalent to // // $str = (string) 7; // // $str === "7" Another quick example: $num = 5; $num := '12'; // Equivalent to // // $num = (int) '12'; // // $num === 12; So what do you guys think? If I get a good response I'll look into how to create a proper RFC and start trying to work out how to implement it. Many thanks and look forward to some responses, Tom -- **************************************************** PLEASE NOTE: For support requests please use supp...@scl.co.uk instead of emailing staff directly, this way your request is likely to be dealt with more efficiently. **************************************************** Tom Oram - SCL Internet Services PO Box 8, Cardigan, Ceredigion, SA41 3YA Website: http://www.scl.co.uk/ Tel: +44 (0) 1239 622 411 Fax: +44 (0) 1239 622428 Company Reg. No. 2441708 ****************************************************