On Sun, 26 Feb 2012 16:39:10 +0100, Laruence <larue...@php.net> wrote:

On Sun, Feb 26, 2012 at 10:57 PM, Anthony Ferrara <ircmax...@gmail.com> 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;


Actually, this part of the problem can be pretty much be implemented today for internal classes with the cast_object[1] or get[2] handlers. There are of course some difficulties, like the nonexistence of a numeric cast, which, by the way, has caused some trouble because the Zend Engine defaults to cast to an integer in a numerical situation instead of a float. This has causes a known bug in SimpleXML:

<?php
$xml = <<<XML
<a>6.5</a>
XML;

$sxml = new simplexmlelement($xml);
$r = 4 + $sxml;
echo $r; //10, not 10.5

The other side (cast from) is more problematic, not entirely satisfactory to the people that have proposed autoboxing in the past, which would like to be able to do $a = 1; $a->blah().

[1] https://wiki.php.net/internals/engine/objects#cast_object
[2] https://wiki.php.net/internals/engine/objects#get


--
Gustavo Lopes

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

Reply via email to