> On 18 Mar 2015, at 3:44 pm, Yasuo Ohgaki <yohg...@ohgaki.net> wrote:
> 
> Hi Pierre,
> 
>> On Wed, Mar 18, 2015 at 1:35 PM, Pierre Joye <pierre....@gmail.com> wrote:
>> 
>>> On Mar 18, 2015 11:26 AM, "Yasuo Ohgaki" <yohg...@ohgaki.net> wrote:
>>> 
>>> I didn't have my time to spent for the patch. So I don't verify this
>>> by myself, but it seems common sense for this RFC.
>> 
>> So you voted against it without knowing how it actually works or aims to
>> work? I suggest you to do it now then, before going further with this
>> discussion :)
> I know we are better to play with patch before vote.
> I played with Zeev's patch and I was sure it's better ;)
> 
> How many of voters spend enough time for both patches before vote?
> 
> The reason I admit that I didn't spent time to play with the patch is
> following behavior does not make sense to me much and I have
> doubt for it.
> 
> lib.php:
> <?php
>        declare(strict_types = 1);
>        function foo(int $a) {
>        // no function call here
>        }
> ?>
> The declare here does just nothing.

Correct. There are no function calls in the file, so there's nothing for 
declare strict to act on.

> 
> <?php
>        require "lib.php";
>        foo("123"); // will work
> ?>
> 
> <?php
>        declare(strict_types = 1);
>        require "lib.php";
>        foo("123"); // will give an error
> ?>
> 
> Could someone knowledgeable shed light on this?
> 
> Regards,
> 
> --
> Yasuo Ohgaki
> yohg...@ohgaki.net

Shed light on what exactly? Why it behaves this way?

The second file passes because it is in the default weak mode, so it will 
coerce to an int, so the type hint is satisfied.

The third file will error because you have asked it to error when you pass the 
wrong scalar type to a function.

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

Reply via email to