On 02/26/2012 04:48 PM, Anthony Ferrara wrote:
>> I have to say, it doesn't get work, thinking this:
>>
>> $mixed1 = new Interger(2);
>> $mixed2 = new Interge(3);
>> $guess_what_type_is = $mixed1 + $mixed2;
>>
>> thanks
> 
> That one is actually pretty straight forward.  Since `+` is a numeric
> operation (with the one exception of array + array), it would call
> castTo('numeric') on both.  Then, the normal type rules would take
> over.  So if it returned an int, the result would be int(5).  If it
> returned a float, it would be float(5)...

Or operator-overlading to the rescue? :-)


(Okay, I know that idea has been burried a long time ago - but might
come in hand here as well.
http://bugs.php.net/bug.php?id=9331
http://pecl.php.net/package/operator
)


Regards,
 Stefan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to