On 25/02/2015 12:30, Dmitry Stogov wrote:
anyone may tell, what this will print without running :)
main.php
========
<?php
declare(strict_types=1)
include "a.php";
include "b.php";
var_dump(foo("5"));
?>
a.php
=====
<?php
declare(strict_types=0)
function foo(string $a): string {
bar($a);
return $a;
}
?>
b.php
=====
<?php
declare(strict_types=1)
function bar(int &$a) {
var_dump($a);
}
?>
I am not sure if we really need to focus the discussion on whether edge
cases using references are confusing or not. They already are confusing
even without scalar hints (of any kind), and that's why most people know
to stay away from refs in PHP.
PHP5 would behave the same if you did an explicit $a = (int) $a; in
bar() for example, and the same WTF happens with the other RFC, so I am
not really sure what you are trying to point out here.
Cheers
--
Jordi Boggiano
@seldaek - http://nelm.io/jordi
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php