Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Shashank Kumar
On Wed, Feb 25, 2015 at 4:30 AM, Dmitry Stogov dmi...@zend.com 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

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Niktia Nefedov
On Wed, 25 Feb 2015 16:55:57 +0400, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com wrote: anyone may tell, what this will print without running :) main.php

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
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

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 3:54 PM, Shashank Kumar shashankkumar...@gmail.com wrote: On Wed, Feb 25, 2015 at 4:30 AM, Dmitry Stogov dmi...@zend.com wrote: anyone may tell, what this will print without running :) main.php ?php declare(strict_types=1) include a.php; include b.php;

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 3:15 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:55:57 +0400, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
Hi Anthony, Few notes: - first of all, it would be great to split the voting questions: 2/3 - implement scalar type hinting + 1/2 - in addition add strict type hinting as you propose. I think, the concept of run-time declare() switch is not designed well. It just affects VM and JITed code in

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Florian Margaine
Hi, Le 25 févr. 2015 13:31, Dmitry Stogov dmi...@zend.com a écrit : 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

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com wrote: anyone may tell, what this will print without running :) main.php ?php declare(strict_types=1) include a.php; include b.php;

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Niktia Nefedov
On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com 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):

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Niktia Nefedov
On Wed, 25 Feb 2015 15:42:11 +0400, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com wrote: anyone may tell, what this will print without running :) main.php ?php declare(strict_types=1) include a.php; include b.php;

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry On Wed, Feb 25, 2015 at 10:20 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 6:06 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry: On Wed, Feb 25, 2015 at 7:55 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry: On Wed, Feb 25, 2015 at 7:55 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov dmi...@zend.com wrote: anyone may tell, what this will print without running :)

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 6:06 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry: On Wed, Feb 25, 2015 at 7:55 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov inefe...@gmail.com wrote: On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 6:03 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, On Wed, Feb 25, 2015 at 7:19 AM, Dmitry Stogov dmi...@zend.com wrote: Hi Anthony, Few notes: - first of all, it would be great to split the voting questions: 2/3 - implement scalar type hinting +

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Lester Caine
On 25/02/15 12:58, Dmitry Stogov wrote: Does that mean when reading or writing code, in addition to checking the signature of a function, I have to check the 'strict_types' setting at the top as well, to understand how that signature behaves? I think you should check it in the top line

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry, The object on the call-site should remain to be an object (if it's not passed by reference), however the called function will receive a string. It works in PHP-5 and PHP-7. Nothing should be changed. $ sapi/cli/php -r 'class X {function __toString(){return abc;}} $x=new X;

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry, But checks are performed not in the caller but in RECV opcode at called function. And in this function we don't know id it's going to be called only in strict mode or in weak as well. Currently, yes. However, by the time we enter ZEND_DO_FCALL, we know which function we're going to

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry, On Wed, Feb 25, 2015 at 7:19 AM, Dmitry Stogov dmi...@zend.com wrote: Hi Anthony, Few notes: - first of all, it would be great to split the voting questions: 2/3 - implement scalar type hinting + 1/2 - in addition add strict type hinting as I've mentioned this a few times, but I

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Anthony Ferrara
Dmitry, On Wed, Feb 25, 2015 at 10:13 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 6:03 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, On Wed, Feb 25, 2015 at 7:19 AM, Dmitry Stogov dmi...@zend.com wrote: Hi Anthony, Few notes: - first of all, it

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 6:47 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, On Wed, Feb 25, 2015 at 10:13 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 6:03 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, On Wed, Feb 25, 2015 at 7:19 AM,

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 6:09 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, The object on the call-site should remain to be an object (if it's not passed by reference), however the called function will receive a string. It works in PHP-5 and PHP-7. Nothing should be changed. $

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 6:24 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry On Wed, Feb 25, 2015 at 10:20 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 6:06 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry: On Wed, Feb 25, 2015 at 7:55 AM, Dmitry

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Pierre Joye
On Wed, Feb 25, 2015 at 7:29 AM, Dmitry Stogov dmi...@zend.com wrote: On Wed, Feb 25, 2015 at 6:09 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, The object on the call-site should remain to be an object (if it's not passed by reference), however the called function will receive a

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Jordi Boggiano
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);

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Dmitry Stogov
On Wed, Feb 25, 2015 at 7:06 PM, Anthony Ferrara ircmax...@gmail.com wrote: Dmitry, But checks are performed not in the caller but in RECV opcode at called function. And in this function we don't know id it's going to be called only in strict mode or in weak as well. Currently, yes.

RE: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread Zeev Suraski
-Original Message- From: Shashank Kumar [mailto:shashankkumar...@gmail.com] Sent: Wednesday, February 25, 2015 2:54 PM To: Dmitry Stogov Cc: Anthony Ferrara; internals@lists.php.net Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 On Wed, Feb 25, 2015 at 4:30

RE: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-25 Thread François Laupretre
De : Anthony Ferrara [mailto:ircmax...@gmail.com] Additionally, it presents a problem when it comes to voting. What if a person wants strict types. And it looks like it's overall going to pass, but that weak types is winning. What's the best way for them to vote? No. For the entire proposal.

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-24 Thread Leigh
I've been having a play around with the implementation, and it's been behaving pretty solidly, nothing unexpected so far. I've even gotten around my issue regarding no strict-by-default option for those of us who want it. Maybe this will sway a few voters. I'll put the source up if this

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-21 Thread Anthony Ferrara
All, I have updated the RFC to re-target 7.0. I have also added a new behavior: Currently, if you install an error handler that returns true, you can bypass type checking in userland functions. set_error_handler(function() { return true; }); function foo(int $abc) { var_dump($abc); }

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-20 Thread Anthony Ferrara
All, An interesting point was brought up related to block mode: https://twitter.com/drrotmos/status/568540722586107904 Namely that generated file caches may need the ability to switch block mode on-and-off. I'm considering making the change to add that. If that happens, declare must be

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-19 Thread Lester Caine
On 19/02/15 01:33, Christoph Becker wrote: Lester Caine wrote: On 18/02/15 23:09, Christoph Becker wrote: It seems to me that this behavior is hard to deal with generally for programmers as well as static analyzers. Andreas' bigint RFC[1] would solve that issue, but it has been withdrawn,

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-19 Thread Anthony Ferrara
All, An interesting point was brought up related to block mode: https://twitter.com/drrotmos/status/568540722586107904 Namely that generated file caches may need the ability to switch block mode on-and-off. I'm considering making the change to add that. If that happens, declare must be the

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-19 Thread Pádraic Brady
On 19 February 2015 at 23:07, Anthony Ferrara ircmax...@gmail.com wrote: All, An interesting point was brought up related to block mode: https://twitter.com/drrotmos/status/568540722586107904 Namely that generated file caches may need the ability to switch block mode on-and-off. I'm

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Rick Widmer
On 2/18/2015 6:33 PM, Christoph Becker wrote: It seems to me you're thinking too much (maybe only?) about database types. IMHO PHP can be used more versatile, and there might be issues which are exemplified in the RFC[1]: Maybe PHP can be more versatile, but what percentage of PHP code sits

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Christoph Becker
Anthony Ferrara wrote: 3. int typed variables can resolve a parameter type of float So calling requiresAFloat(10) will work even in strict mode. Have you considered the overflow behavior of ints resulting in a float? For instance, the following code would produce E_RECOVERABLE_ERROR, AIUI:

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Anthony Ferrara
Christoph, On Wed, Feb 18, 2015 at 6:09 PM, Christoph Becker cmbecke...@gmx.de wrote: Anthony Ferrara wrote: 3. int typed variables can resolve a parameter type of float So calling requiresAFloat(10) will work even in strict mode. Have you considered the overflow behavior of ints resulting

[PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Christoph Becker
Anthony, Anthony Ferrara wrote: On Wed, Feb 18, 2015 at 6:09 PM, Christoph Becker cmbecke...@gmx.de wrote: Have you considered the overflow behavior of ints resulting in a float? For instance, the following code would produce E_RECOVERABLE_ERROR, AIUI: ?php declare(strict_types=1);

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Christoph Becker
Lester Caine wrote: On 18/02/15 23:09, Christoph Becker wrote: It seems to me that this behavior is hard to deal with generally for programmers as well as static analyzers. Andreas' bigint RFC[1] would solve that issue, but it has been withdrawn, and AFAIK nobody is working on it. OTOH,

Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5

2015-02-18 Thread Lester Caine
On 18/02/15 23:09, Christoph Becker wrote: It seems to me that this behavior is hard to deal with generally for programmers as well as static analyzers. Andreas' bigint RFC[1] would solve that issue, but it has been withdrawn, and AFAIK nobody is working on it. OTOH, bigint would make the