Re: [RFC][Accepted] Scalar Type Declarations V0.5

From: Date: Wed, 18 Mar 2015 11:31:17 +0000
Subject: Re: [RFC][Accepted] Scalar Type Declarations V0.5
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-85182@lists.php.net to get a copy of this message
On Wednesday, March 18, 2015, Patrick ALLAERT <patrickallaert@php.net> wrote: > Le mer. 18 mars 2015 à 10:56, Pavel Kouřil <pajousek@gmail.com> a écrit : >> >> Hello, >> >> how will these examples work btw? >> >> // a.php >> <?php >> declare(strict_types=1); >> function foo($fn) { >> $fn("1"); >> }; >> >> // b.php >> <?php >> require 'a.php'; >> foo(function (int $a) { return $a * 2; }); >> >> >> >> // c.php >> <?php >> function foo($fn) { >> $fn("1"); >> }; >> >> // d.php >> <?php >> declare(strict_types=1); >> require 'c.php'; >> foo(function (int $a) { return $a * 2; }); >> >> I can't find this in the RFC. I'd intuitively expect error in the >> first example and the second one to work OK. > > Your intuition is correct. > >> >> But at the same time, if there will be an error in the first example, >> it is IMHO a huge flaw with this RFC. :/ > > Flaw vs. design choice. This is one of the reason that this aspect, amongst others, has been very debated. But if it works this way, the strict mode isn't optional and users of a library NEED to care which mode the library uses?

« previous php.internals (#85182) next »